Skip to content

Commit 97a8496

Browse files
committed
Declare tentative return types for ext/tidy
Closes GH-6999
1 parent 4ed66ff commit 97a8496

File tree

2 files changed

+67
-53
lines changed

2 files changed

+67
-53
lines changed

ext/tidy/tidy.stub.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,108 +57,108 @@ class tidy
5757
public function __construct(?string $filename = null, array|string|null $config = null, ?string $encoding = null, bool $useIncludePath = false) {}
5858

5959
/**
60-
* @return string|int|bool
60+
* @tentative-return-type
6161
* @alias tidy_getopt
6262
*/
63-
public function getOpt(string $option) {}
63+
public function getOpt(string $option): string|int|bool {}
6464

6565
/**
66-
* @return bool
66+
* @tentative-return-type
6767
* @alias tidy_clean_repair
6868
*/
69-
public function cleanRepair() {}
69+
public function cleanRepair(): bool {}
7070

71-
/** @return bool */
72-
public function parseFile(string $filename, array|string|null $config = null, ?string $encoding = null, bool $useIncludePath = false) {}
71+
/** @tentative-return-type */
72+
public function parseFile(string $filename, array|string|null $config = null, ?string $encoding = null, bool $useIncludePath = false): bool {}
7373

74-
/** @return bool */
75-
public function parseString(string $string, array|string|null $config = null, ?string $encoding = null) {}
74+
/** @tentative-return-type */
75+
public function parseString(string $string, array|string|null $config = null, ?string $encoding = null): bool {}
7676

7777
/**
78-
* @return string|false
78+
* @tentative-return-type
7979
* @alias tidy_repair_string
8080
*/
81-
public static function repairString(string $string, array|string|null $config = null, ?string $encoding = null) {}
81+
public static function repairString(string $string, array|string|null $config = null, ?string $encoding = null): string|false {}
8282

8383
/**
84-
* @return string|false
84+
* @tentative-return-type
8585
* @alias tidy_repair_file
8686
*/
87-
public static function repairFile(string $filename, array|string|null $config = null, ?string $encoding = null, bool $useIncludePath = false) {}
87+
public static function repairFile(string $filename, array|string|null $config = null, ?string $encoding = null, bool $useIncludePath = false): string|false {}
8888

8989
/**
90-
* @return bool
90+
* @tentative-return-type
9191
* @alias tidy_diagnose
9292
*/
93-
public function diagnose() {}
93+
public function diagnose(): bool {}
9494

9595
/**
96-
* @return string
96+
* @tentative-return-type
9797
* @alias tidy_get_release
9898
*/
99-
public function getRelease() {}
99+
public function getRelease(): string {}
100100

101101
/**
102-
* @return array
102+
* @tentative-return-type
103103
* @alias tidy_get_config
104104
*/
105-
public function getConfig() {}
105+
public function getConfig(): array {}
106106

107107
/**
108-
* @return int
108+
* @tentative-return-type
109109
* @alias tidy_get_status
110110
*/
111-
public function getStatus() {}
111+
public function getStatus(): int {}
112112

113113
/**
114-
* @return int
114+
* @tentative-return-type
115115
* @alias tidy_get_html_ver
116116
*/
117-
public function getHtmlVer() {}
117+
public function getHtmlVer(): int {}
118118

119119
#ifdef HAVE_TIDYOPTGETDOC
120120
/**
121-
* @return string|false
121+
* @tentative-return-type
122122
* @alias tidy_get_opt_doc
123123
*/
124-
public function getOptDoc(string $option) {}
124+
public function getOptDoc(string $option): string|false {}
125125
#endif
126126

127127
/**
128-
* @return bool
128+
* @tentative-return-type
129129
* @alias tidy_is_xhtml
130130
*/
131-
public function isXhtml() {}
131+
public function isXhtml(): bool {}
132132

133133
/**
134-
* @return bool
134+
* @tentative-return-type
135135
* @alias tidy_is_xml
136136
*/
137-
public function isXml() {}
137+
public function isXml(): bool {}
138138

139139
/**
140-
* @return tidyNode|null
140+
* @tentative-return-type
141141
* @alias tidy_get_root
142142
*/
143-
public function root() {}
143+
public function root(): ?tidyNode {}
144144

145145
/**
146-
* @return tidyNode|null
146+
* @tentative-return-type
147147
* @alias tidy_get_head
148148
*/
149-
public function head() {}
149+
public function head(): ?tidyNode {}
150150

151151
/**
152-
* @return tidyNode|null
152+
* @tentative-return-type
153153
* @alias tidy_get_html
154154
*/
155-
public function html() {}
155+
public function html(): ?tidyNode {}
156156

157157
/**
158-
* @return tidyNode|null
158+
* @tentative-return-type
159159
* @alias tidy_get_body
160160
*/
161-
public function body() {}
161+
public function body(): ?tidyNode {}
162162
}
163163

164164
final class tidyNode

ext/tidy/tidy_arginfo.h

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 75995fe0aad02540f1bde99495a188ae4ab7c0ac */
2+
* Stub hash: 4e5f6c0e7c6b8a6939a13276e3e68d2614a73d7e */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_tidy_parse_string, 0, 1, tidy, MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
@@ -95,42 +95,54 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy___construct, 0, 0, 0)
9595
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, useIncludePath, _IS_BOOL, 0, "false")
9696
ZEND_END_ARG_INFO()
9797

98-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_getOpt, 0, 0, 1)
98+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_tidy_getOpt, 0, 1, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_BOOL)
9999
ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0)
100100
ZEND_END_ARG_INFO()
101101

102-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_cleanRepair, 0, 0, 0)
102+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_tidy_cleanRepair, 0, 0, _IS_BOOL, 0)
103103
ZEND_END_ARG_INFO()
104104

105-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_parseFile, 0, 0, 1)
105+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_tidy_parseFile, 0, 1, _IS_BOOL, 0)
106106
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
107107
ZEND_ARG_TYPE_MASK(0, config, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null")
108108
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
109109
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, useIncludePath, _IS_BOOL, 0, "false")
110110
ZEND_END_ARG_INFO()
111111

112-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_parseString, 0, 0, 1)
112+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_tidy_parseString, 0, 1, _IS_BOOL, 0)
113113
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
114114
ZEND_ARG_TYPE_MASK(0, config, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null")
115115
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
116116
ZEND_END_ARG_INFO()
117117

118-
#define arginfo_class_tidy_repairString arginfo_class_tidy_parseString
118+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_tidy_repairString, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
119+
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
120+
ZEND_ARG_TYPE_MASK(0, config, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null")
121+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
122+
ZEND_END_ARG_INFO()
119123

120-
#define arginfo_class_tidy_repairFile arginfo_class_tidy_parseFile
124+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_tidy_repairFile, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
125+
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
126+
ZEND_ARG_TYPE_MASK(0, config, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null")
127+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
128+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, useIncludePath, _IS_BOOL, 0, "false")
129+
ZEND_END_ARG_INFO()
121130

122131
#define arginfo_class_tidy_diagnose arginfo_class_tidy_cleanRepair
123132

124-
#define arginfo_class_tidy_getRelease arginfo_class_tidy_cleanRepair
133+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_tidy_getRelease, 0, 0, IS_STRING, 0)
134+
ZEND_END_ARG_INFO()
125135

126-
#define arginfo_class_tidy_getConfig arginfo_class_tidy_cleanRepair
136+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_tidy_getConfig, 0, 0, IS_ARRAY, 0)
137+
ZEND_END_ARG_INFO()
127138

128-
#define arginfo_class_tidy_getStatus arginfo_class_tidy_cleanRepair
139+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_tidy_getStatus, 0, 0, IS_LONG, 0)
140+
ZEND_END_ARG_INFO()
129141

130-
#define arginfo_class_tidy_getHtmlVer arginfo_class_tidy_cleanRepair
142+
#define arginfo_class_tidy_getHtmlVer arginfo_class_tidy_getStatus
131143

132144
#if defined(HAVE_TIDYOPTGETDOC)
133-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_getOptDoc, 0, 0, 1)
145+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_tidy_getOptDoc, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
134146
ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0)
135147
ZEND_END_ARG_INFO()
136148
#endif
@@ -139,15 +151,17 @@ ZEND_END_ARG_INFO()
139151

140152
#define arginfo_class_tidy_isXml arginfo_class_tidy_cleanRepair
141153

142-
#define arginfo_class_tidy_root arginfo_class_tidy_cleanRepair
154+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_tidy_root, 0, 0, tidyNode, 1)
155+
ZEND_END_ARG_INFO()
143156

144-
#define arginfo_class_tidy_head arginfo_class_tidy_cleanRepair
157+
#define arginfo_class_tidy_head arginfo_class_tidy_root
145158

146-
#define arginfo_class_tidy_html arginfo_class_tidy_cleanRepair
159+
#define arginfo_class_tidy_html arginfo_class_tidy_root
147160

148-
#define arginfo_class_tidy_body arginfo_class_tidy_cleanRepair
161+
#define arginfo_class_tidy_body arginfo_class_tidy_root
149162

150-
#define arginfo_class_tidyNode___construct arginfo_class_tidy_cleanRepair
163+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidyNode___construct, 0, 0, 0)
164+
ZEND_END_ARG_INFO()
151165

152166
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_tidyNode_hasChildren, 0, 0, _IS_BOOL, 0)
153167
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)