Skip to content

Commit a902622

Browse files
committed
Declare tentative return types for ext/xmlreader
Relates to GH-6995
1 parent 940f599 commit a902622

File tree

2 files changed

+78
-69
lines changed

2 files changed

+78
-69
lines changed

ext/xmlreader/php_xmlreader.stub.php

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -33,77 +33,77 @@ class XMLReader
3333
public string $xmlLang;
3434

3535
/** @return bool */
36-
public function close() {}
36+
public function close() {} // TODO make the return type void
3737

38-
/** @return string|null */
39-
public function getAttribute(string $name) {}
38+
/** @tentative-return-type */
39+
public function getAttribute(string $name): ?string {}
4040

41-
/** @return string|null */
42-
public function getAttributeNo(int $index) {}
41+
/** @tentative-return-type */
42+
public function getAttributeNo(int $index): ?string {}
4343

44-
/** @return string|null */
45-
public function getAttributeNs(string $name, string $namespace) {}
44+
/** @tentative-return-type */
45+
public function getAttributeNs(string $name, string $namespace): ?string {}
4646

47-
/** @return bool */
48-
public function getParserProperty(int $property) {}
47+
/** @tentative-return-type */
48+
public function getParserProperty(int $property): bool {}
4949

50-
/** @return bool */
51-
public function isValid() {}
50+
/** @tentative-return-type */
51+
public function isValid(): bool {}
5252

53-
/** @return string|null */
54-
public function lookupNamespace(string $prefix) {}
53+
/** @tentative-return-type */
54+
public function lookupNamespace(string $prefix): ?string {}
5555

56-
/** @return bool */
57-
public function moveToAttribute(string $name) {}
56+
/** @tentative-return-type */
57+
public function moveToAttribute(string $name): bool {}
5858

59-
/** @return bool */
60-
public function moveToAttributeNo(int $index) {}
59+
/** @tentative-return-type */
60+
public function moveToAttributeNo(int $index): bool {}
6161

62-
/** @return bool */
63-
public function moveToAttributeNs(string $name, string $namespace) {}
62+
/** @tentative-return-type */
63+
public function moveToAttributeNs(string $name, string $namespace): bool {}
6464

65-
/** @return bool */
66-
public function moveToElement() {}
65+
/** @tentative-return-type */
66+
public function moveToElement(): bool {}
6767

68-
/** @return bool */
69-
public function moveToFirstAttribute() {}
68+
/** @tentative-return-type */
69+
public function moveToFirstAttribute(): bool {}
7070

71-
/** @return bool */
72-
public function moveToNextAttribute() {}
71+
/** @tentative-return-type */
72+
public function moveToNextAttribute(): bool {}
7373

74-
/** @return bool */
75-
public function read() {}
74+
/** @tentative-return-type */
75+
public function read(): bool {}
7676

77-
/** @return bool */
78-
public function next(?string $name = null) {}
77+
/** @tentative-return-type */
78+
public function next(?string $name = null): bool {}
7979

8080
/** @return bool|XMLReader */
81-
public static function open(string $uri, ?string $encoding = null, int $flags = 0) {}
81+
public static function open(string $uri, ?string $encoding = null, int $flags = 0) {} // TODO Return type shouldn't be dependent on the call scope
8282

83-
/** @return string */
84-
public function readInnerXml() {}
83+
/** @tentative-return-type */
84+
public function readInnerXml(): string {}
8585

86-
/** @return string */
87-
public function readOuterXml() {}
86+
/** @tentative-return-type */
87+
public function readOuterXml(): string {}
8888

89-
/** @return string */
90-
public function readString() {}
89+
/** @tentative-return-type */
90+
public function readString(): string {}
9191

92-
/** @return bool */
93-
public function setSchema(?string $filename) {}
92+
/** @tentative-return-type */
93+
public function setSchema(?string $filename): bool {}
9494

95-
/** @return bool */
96-
public function setParserProperty(int $property, bool $value) {}
95+
/** @tentative-return-type */
96+
public function setParserProperty(int $property, bool $value): bool {}
9797

98-
/** @return bool */
99-
public function setRelaxNGSchema(?string $filename) {}
98+
/** @tentative-return-type */
99+
public function setRelaxNGSchema(?string $filename): bool {}
100100

101-
/** @return bool */
102-
public function setRelaxNGSchemaSource(?string $source) {}
101+
/** @tentative-return-type */
102+
public function setRelaxNGSchemaSource(?string $source): bool {}
103103

104104
/** @return bool|XMLReader */
105-
public static function XML(string $source, ?string $encoding = null, int $flags = 0) {}
105+
public static function XML(string $source, ?string $encoding = null, int $flags = 0) {} // TODO Return type shouldn't be dependent on the call scope
106106

107-
/** @return DOMNode|false */
108-
public function expand(?DOMNode $baseNode = null) {}
107+
/** @tentative-return-type */
108+
public function expand(?DOMNode $baseNode = null): DOMNode|false {}
109109
}

ext/xmlreader/php_xmlreader_arginfo.h

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 49adb3008ade3f92f9b764ead9366efc6681e46f */
2+
* Stub hash: 1601e86ad66e337a6af7d09ec7ba703926bdb8c7 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_close, 0, 0, 0)
55
ZEND_END_ARG_INFO()
66

7-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_getAttribute, 0, 0, 1)
7+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_getAttribute, 0, 1, IS_STRING, 1)
88
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
99
ZEND_END_ARG_INFO()
1010

11-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_getAttributeNo, 0, 0, 1)
11+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_getAttributeNo, 0, 1, IS_STRING, 1)
1212
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
1313
ZEND_END_ARG_INFO()
1414

15-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_getAttributeNs, 0, 0, 2)
15+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_getAttributeNs, 0, 2, IS_STRING, 1)
1616
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
1717
ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0)
1818
ZEND_END_ARG_INFO()
1919

20-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_getParserProperty, 0, 0, 1)
20+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_getParserProperty, 0, 1, _IS_BOOL, 0)
2121
ZEND_ARG_TYPE_INFO(0, property, IS_LONG, 0)
2222
ZEND_END_ARG_INFO()
2323

24-
#define arginfo_class_XMLReader_isValid arginfo_class_XMLReader_close
24+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_isValid, 0, 0, _IS_BOOL, 0)
25+
ZEND_END_ARG_INFO()
2526

26-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_lookupNamespace, 0, 0, 1)
27+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_lookupNamespace, 0, 1, IS_STRING, 1)
2728
ZEND_ARG_TYPE_INFO(0, prefix, IS_STRING, 0)
2829
ZEND_END_ARG_INFO()
2930

30-
#define arginfo_class_XMLReader_moveToAttribute arginfo_class_XMLReader_getAttribute
31+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_moveToAttribute, 0, 1, _IS_BOOL, 0)
32+
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
33+
ZEND_END_ARG_INFO()
3134

32-
#define arginfo_class_XMLReader_moveToAttributeNo arginfo_class_XMLReader_getAttributeNo
35+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_moveToAttributeNo, 0, 1, _IS_BOOL, 0)
36+
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
37+
ZEND_END_ARG_INFO()
3338

34-
#define arginfo_class_XMLReader_moveToAttributeNs arginfo_class_XMLReader_getAttributeNs
39+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_moveToAttributeNs, 0, 2, _IS_BOOL, 0)
40+
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
41+
ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0)
42+
ZEND_END_ARG_INFO()
3543

36-
#define arginfo_class_XMLReader_moveToElement arginfo_class_XMLReader_close
44+
#define arginfo_class_XMLReader_moveToElement arginfo_class_XMLReader_isValid
3745

38-
#define arginfo_class_XMLReader_moveToFirstAttribute arginfo_class_XMLReader_close
46+
#define arginfo_class_XMLReader_moveToFirstAttribute arginfo_class_XMLReader_isValid
3947

40-
#define arginfo_class_XMLReader_moveToNextAttribute arginfo_class_XMLReader_close
48+
#define arginfo_class_XMLReader_moveToNextAttribute arginfo_class_XMLReader_isValid
4149

42-
#define arginfo_class_XMLReader_read arginfo_class_XMLReader_close
50+
#define arginfo_class_XMLReader_read arginfo_class_XMLReader_isValid
4351

44-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_next, 0, 0, 0)
52+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_next, 0, 0, _IS_BOOL, 0)
4553
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null")
4654
ZEND_END_ARG_INFO()
4755

@@ -51,24 +59,25 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_open, 0, 0, 1)
5159
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
5260
ZEND_END_ARG_INFO()
5361

54-
#define arginfo_class_XMLReader_readInnerXml arginfo_class_XMLReader_close
62+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_readInnerXml, 0, 0, IS_STRING, 0)
63+
ZEND_END_ARG_INFO()
5564

56-
#define arginfo_class_XMLReader_readOuterXml arginfo_class_XMLReader_close
65+
#define arginfo_class_XMLReader_readOuterXml arginfo_class_XMLReader_readInnerXml
5766

58-
#define arginfo_class_XMLReader_readString arginfo_class_XMLReader_close
67+
#define arginfo_class_XMLReader_readString arginfo_class_XMLReader_readInnerXml
5968

60-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_setSchema, 0, 0, 1)
69+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_setSchema, 0, 1, _IS_BOOL, 0)
6170
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 1)
6271
ZEND_END_ARG_INFO()
6372

64-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_setParserProperty, 0, 0, 2)
73+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_setParserProperty, 0, 2, _IS_BOOL, 0)
6574
ZEND_ARG_TYPE_INFO(0, property, IS_LONG, 0)
6675
ZEND_ARG_TYPE_INFO(0, value, _IS_BOOL, 0)
6776
ZEND_END_ARG_INFO()
6877

6978
#define arginfo_class_XMLReader_setRelaxNGSchema arginfo_class_XMLReader_setSchema
7079

71-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_setRelaxNGSchemaSource, 0, 0, 1)
80+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XMLReader_setRelaxNGSchemaSource, 0, 1, _IS_BOOL, 0)
7281
ZEND_ARG_TYPE_INFO(0, source, IS_STRING, 1)
7382
ZEND_END_ARG_INFO()
7483

@@ -78,7 +87,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_XML, 0, 0, 1)
7887
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
7988
ZEND_END_ARG_INFO()
8089

81-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_expand, 0, 0, 0)
90+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_XMLReader_expand, 0, 0, DOMNode, MAY_BE_FALSE)
8291
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, baseNode, DOMNode, 1, "null")
8392
ZEND_END_ARG_INFO()
8493

0 commit comments

Comments
 (0)