Skip to content

Commit 80e5ad5

Browse files
committed
Various ext/spl stub fixes
Closes GH-7215
1 parent 8cec7db commit 80e5ad5

File tree

7 files changed

+49
-53
lines changed

7 files changed

+49
-53
lines changed

build/gen_stub.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ public static function fromNode(Node $node): SimpleType {
118118
return new SimpleType($node->toString(), true);
119119
}
120120

121+
if ($node->toLowerString() === 'self') {
122+
throw new Exception('The exact class name must be used instead of "self"');
123+
}
124+
121125
assert($node->isFullyQualified());
122126
return new SimpleType($node->toString(), false);
123127
}
@@ -142,9 +146,10 @@ public static function fromPhpDoc(string $type): SimpleType
142146
case "object":
143147
case "resource":
144148
case "mixed":
145-
case "self":
146149
case "static":
147150
return new SimpleType(strtolower($type), true);
151+
case "self":
152+
throw new Exception('The exact class name must be used instead of "self"');
148153
}
149154

150155
if (strpos($type, "[]") !== false) {
@@ -1162,6 +1167,10 @@ function parseFunctionLike(
11621167
}
11631168
}
11641169

1170+
if ($param->default instanceof Expr\ClassConstFetch && $param->default->class->toLowerString() === "self") {
1171+
throw new Exception('The exact class name must be used instead of "self"');
1172+
}
1173+
11651174
$foundVariadic = $param->variadic;
11661175

11671176
$args[] = new ArgInfo(

ext/spl/spl_array.stub.php

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,17 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Count
66
{
77
public function __construct(array|object $array = [], int $flags = 0, string $iteratorClass = ArrayIterator::class) {}
88

9-
/**
10-
* @param string|int $key
11-
* @return bool
12-
*/
13-
public function offsetExists($key) {}
9+
/** @return bool */
10+
public function offsetExists(mixed $key) {}
1411

15-
/**
16-
* @param string|int $key
17-
* @return mixed
18-
*/
19-
public function offsetGet($key) {}
12+
/** @return mixed */
13+
public function offsetGet(mixed $key) {}
2014

21-
/**
22-
* @param string|int $key
23-
* @return void
24-
*/
25-
public function offsetSet($key, mixed $value) {}
15+
/** @return void */
16+
public function offsetSet(mixed $key, mixed $value) {}
2617

27-
/**
28-
* @param string|int $key
29-
* @return void
30-
*/
31-
public function offsetUnset($key) {}
18+
/** @return void */
19+
public function offsetUnset(mixed $key) {}
3220

3321
/** @return void */
3422
public function append(mixed $value) {}
@@ -96,32 +84,28 @@ class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Coun
9684
public function __construct(array|object $array = [], int $flags = 0) {}
9785

9886
/**
99-
* @param string|int $key
10087
* @return bool
10188
* @implementation-alias ArrayObject::offsetExists
10289
*/
103-
public function offsetExists($key) {}
90+
public function offsetExists(mixed $key) {}
10491

10592
/**
106-
* @param string|int $key
10793
* @return mixed
10894
* @implementation-alias ArrayObject::offsetGet
10995
*/
110-
public function offsetGet($key) {}
96+
public function offsetGet(mixed $key) {}
11197

11298
/**
113-
* @param string|int $key
11499
* @return void
115100
* @implementation-alias ArrayObject::offsetSet
116101
*/
117-
public function offsetSet($key, mixed $value) {}
102+
public function offsetSet(mixed $key, mixed $value) {}
118103

119104
/**
120-
* @param string|int $key
121105
* @return void
122106
* @implementation-alias ArrayObject::offsetUnset
123107
*/
124-
public function offsetUnset($key) {}
108+
public function offsetUnset(mixed $key) {}
125109

126110
/**
127111
* @return void

ext/spl/spl_array_arginfo.h

Lines changed: 3 additions & 3 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: a4bc5ec5a95aae6bfa53988316cfa396f4f9fb92 */
2+
* Stub hash: 89f431b33667e7ee6538a2a50ed7aabcf0449d36 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_MASK(0, array, MAY_BE_ARRAY|MAY_BE_OBJECT, "[]")
@@ -8,13 +8,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject___construct, 0, 0, 0)
88
ZEND_END_ARG_INFO()
99

1010
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_offsetExists, 0, 0, 1)
11-
ZEND_ARG_INFO(0, key)
11+
ZEND_ARG_TYPE_INFO(0, key, IS_MIXED, 0)
1212
ZEND_END_ARG_INFO()
1313

1414
#define arginfo_class_ArrayObject_offsetGet arginfo_class_ArrayObject_offsetExists
1515

1616
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_offsetSet, 0, 0, 2)
17-
ZEND_ARG_INFO(0, key)
17+
ZEND_ARG_TYPE_INFO(0, key, IS_MIXED, 0)
1818
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
1919
ZEND_END_ARG_INFO()
2020

ext/spl/spl_directory.stub.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function rewind() {}
148148
/** @return string */
149149
public function key() {}
150150

151-
/** @return string|SplFileInfo|self */
151+
/** @return string|SplFileInfo|FilesystemIterator */
152152
public function current() {}
153153

154154
/** @return int */
@@ -211,7 +211,7 @@ public function fgetcsv(string $separator = ",", string $enclosure = "\"", strin
211211
/** @return int|false */
212212
public function fputcsv(array $fields, string $separator = ",", string $enclosure = "\"", string $escape = "\\") {}
213213

214-
/** @return bool|null */
214+
/** @return void */
215215
public function setCsvControl(string $separator = ",", string $enclosure = "\"", string $escape = "\\") {}
216216

217217
/** @return array */
@@ -238,7 +238,7 @@ public function fgetc() {}
238238
/** @return int */
239239
public function fpassthru() {}
240240

241-
/** @return array|int|false|null */
241+
/** @return array|int|null */
242242
public function fscanf(string $format, mixed &...$vars) {}
243243

244244
/** @return int|false */
@@ -274,7 +274,7 @@ public function getMaxLineLen() {}
274274
/** @return bool */
275275
public function hasChildren() {}
276276

277-
/** @return null */
277+
/** @return RecursiveIterator|null */
278278
public function getChildren() {}
279279

280280
/** @return void */

ext/spl/spl_directory_arginfo.h

Lines changed: 1 addition & 1 deletion
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: 285af54cf7b3f3ef3f0d673b248c5afbd4cc440e */
2+
* Stub hash: d9110bb238c9edb5c013bd482649ed96e24ff7b6 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)

ext/spl/spl_iterators.stub.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ interface RecursiveIterator extends Iterator
4747
/** @return bool */
4848
public function hasChildren();
4949

50-
/** @return RecursiveIterator */
50+
/** @return RecursiveIterator|null */
5151
public function getChildren();
5252
}
5353

5454
class RecursiveIteratorIterator implements OuterIterator
5555
{
56-
public function __construct(Traversable $iterator, int $mode = self::LEAVES_ONLY, int $flags = 0) {}
56+
public function __construct(Traversable $iterator, int $mode = RecursiveIteratorIterator::LEAVES_ONLY, int $flags = 0) {}
5757

5858
/** @return void */
5959
public function rewind() {}
@@ -200,7 +200,7 @@ public function getPosition() {}
200200

201201
class CachingIterator extends IteratorIterator implements ArrayAccess, Countable
202202
{
203-
public function __construct(Iterator $iterator, int $flags = self::CALL_TOSTRING) {}
203+
public function __construct(Iterator $iterator, int $flags = CachingIterator::CALL_TOSTRING) {}
204204

205205
/** @return void */
206206
public function rewind() {}
@@ -255,7 +255,7 @@ public function count() {}
255255

256256
class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
257257
{
258-
public function __construct(Iterator $iterator, int $flags = self::CALL_TOSTRING) {}
258+
public function __construct(Iterator $iterator, int $flags = RecursiveCachingIterator::CALL_TOSTRING) {}
259259

260260
/** @return bool */
261261
public function hasChildren() {}
@@ -320,7 +320,7 @@ public function next() {}
320320

321321
class RegexIterator extends FilterIterator
322322
{
323-
public function __construct(Iterator $iterator, string $pattern, int $mode = self::MATCH, int $flags = 0, int $pregFlags = 0) {}
323+
public function __construct(Iterator $iterator, string $pattern, int $mode = RegexIterator::MATCH, int $flags = 0, int $pregFlags = 0) {}
324324

325325
/** @return bool */
326326
public function accept() {}
@@ -349,7 +349,7 @@ public function setPregFlags(int $pregFlags) {}
349349

350350
class RecursiveRegexIterator extends RegexIterator implements RecursiveIterator
351351
{
352-
public function __construct(RecursiveIterator $iterator, string $pattern, int $mode = self::MATCH, int $flags = 0, int $pregFlags = 0) {}
352+
public function __construct(RecursiveIterator $iterator, string $pattern, int $mode = RecursiveRegexIterator::MATCH, int $flags = 0, int $pregFlags = 0) {}
353353

354354
/** @return bool */
355355
public function accept() {}
@@ -369,9 +369,9 @@ class RecursiveTreeIterator extends RecursiveIteratorIterator
369369
/** @param RecursiveIterator|IteratorAggregate $iterator */
370370
public function __construct(
371371
$iterator,
372-
int $flags = self::BYPASS_KEY,
372+
int $flags = RecursiveTreeIterator::BYPASS_KEY,
373373
int $cachingIteratorFlags = CachingIterator::CATCH_GET_CHILD,
374-
int $mode = self::SELF_FIRST
374+
int $mode = RecursiveTreeIterator::SELF_FIRST
375375
) {}
376376

377377
/** @return mixed */

ext/spl/spl_iterators_arginfo.h

Lines changed: 11 additions & 8 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: ae7df94646bf08874d7b9804833d0081c40e0348 */
2+
* Stub hash: da35c3e48b3a09f5f013fdd760ddab6bdfb37967 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_EmptyIterator_current, 0, 0, 0)
55
ZEND_END_ARG_INFO()
@@ -34,7 +34,7 @@ ZEND_END_ARG_INFO()
3434

3535
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RecursiveIteratorIterator___construct, 0, 0, 1)
3636
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
37-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "self::LEAVES_ONLY")
37+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "RecursiveIteratorIterator::LEAVES_ONLY")
3838
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
3939
ZEND_END_ARG_INFO()
4040

@@ -139,7 +139,7 @@ ZEND_END_ARG_INFO()
139139

140140
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_CachingIterator___construct, 0, 0, 1)
141141
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
142-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "self::CALL_TOSTRING")
142+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "CachingIterator::CALL_TOSTRING")
143143
ZEND_END_ARG_INFO()
144144

145145
#define arginfo_class_CachingIterator_rewind arginfo_class_EmptyIterator_current
@@ -176,7 +176,10 @@ ZEND_END_ARG_INFO()
176176

177177
#define arginfo_class_CachingIterator_count arginfo_class_EmptyIterator_current
178178

179-
#define arginfo_class_RecursiveCachingIterator___construct arginfo_class_CachingIterator___construct
179+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RecursiveCachingIterator___construct, 0, 0, 1)
180+
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
181+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "RecursiveCachingIterator::CALL_TOSTRING")
182+
ZEND_END_ARG_INFO()
180183

181184
#define arginfo_class_RecursiveCachingIterator_hasChildren arginfo_class_EmptyIterator_current
182185

@@ -217,7 +220,7 @@ ZEND_END_ARG_INFO()
217220
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RegexIterator___construct, 0, 0, 2)
218221
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
219222
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
220-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "self::MATCH")
223+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "RegexIterator::MATCH")
221224
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
222225
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pregFlags, IS_LONG, 0, "0")
223226
ZEND_END_ARG_INFO()
@@ -245,7 +248,7 @@ ZEND_END_ARG_INFO()
245248
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RecursiveRegexIterator___construct, 0, 0, 2)
246249
ZEND_ARG_OBJ_INFO(0, iterator, RecursiveIterator, 0)
247250
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
248-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "self::MATCH")
251+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "RecursiveRegexIterator::MATCH")
249252
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
250253
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pregFlags, IS_LONG, 0, "0")
251254
ZEND_END_ARG_INFO()
@@ -258,9 +261,9 @@ ZEND_END_ARG_INFO()
258261

259262
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RecursiveTreeIterator___construct, 0, 0, 1)
260263
ZEND_ARG_INFO(0, iterator)
261-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "self::BYPASS_KEY")
264+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "RecursiveTreeIterator::BYPASS_KEY")
262265
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cachingIteratorFlags, IS_LONG, 0, "CachingIterator::CATCH_GET_CHILD")
263-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "self::SELF_FIRST")
266+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "RecursiveTreeIterator::SELF_FIRST")
264267
ZEND_END_ARG_INFO()
265268

266269
#define arginfo_class_RecursiveTreeIterator_key arginfo_class_EmptyIterator_current

0 commit comments

Comments
 (0)