Skip to content

Commit f075710

Browse files
authored
Typed constants in SPL extension (php#12358)
1 parent 72cac39 commit f075710

13 files changed

+180
-330
lines changed

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ PHP 8.4 UPGRADE NOTES
106106
9. Other Changes to Extensions
107107
========================================
108108

109+
- Spl:
110+
. The class constants are typed now.
111+
109112
========================================
110113
10. New Global Constants
111114
========================================

ext/spl/spl_array.stub.php

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44

55
class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Countable
66
{
7-
/**
8-
* @var int
9-
* @cvalue SPL_ARRAY_STD_PROP_LIST
10-
*/
11-
const STD_PROP_LIST = UNKNOWN;
12-
/**
13-
* @var int
14-
* @cvalue SPL_ARRAY_ARRAY_AS_PROPS
15-
*/
16-
const ARRAY_AS_PROPS = UNKNOWN;
7+
/** @cvalue SPL_ARRAY_STD_PROP_LIST */
8+
public const int STD_PROP_LIST = UNKNOWN;
9+
/** @cvalue SPL_ARRAY_ARRAY_AS_PROPS */
10+
public const int ARRAY_AS_PROPS = UNKNOWN;
1711

1812
public function __construct(array|object $array = [], int $flags = 0, string $iteratorClass = ArrayIterator::class) {}
1913

@@ -92,16 +86,10 @@ public function __debugInfo(): array {}
9286

9387
class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Countable
9488
{
95-
/**
96-
* @var int
97-
* @cvalue SPL_ARRAY_STD_PROP_LIST
98-
*/
99-
public const STD_PROP_LIST = UNKNOWN;
100-
/**
101-
* @var int
102-
* @cvalue SPL_ARRAY_ARRAY_AS_PROPS
103-
*/
104-
public const ARRAY_AS_PROPS = UNKNOWN;
89+
/** @cvalue SPL_ARRAY_STD_PROP_LIST */
90+
public const int STD_PROP_LIST = UNKNOWN;
91+
/** @cvalue SPL_ARRAY_ARRAY_AS_PROPS */
92+
public const int ARRAY_AS_PROPS = UNKNOWN;
10593

10694
public function __construct(array|object $array = [], int $flags = 0) {}
10795

@@ -246,11 +234,8 @@ public function __debugInfo(): array {}
246234

247235
class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
248236
{
249-
/**
250-
* @var int
251-
* @cvalue SPL_ARRAY_CHILD_ARRAYS_ONLY
252-
*/
253-
public const CHILD_ARRAYS_ONLY = UNKNOWN;
237+
/** @cvalue SPL_ARRAY_CHILD_ARRAYS_ONLY */
238+
public const int CHILD_ARRAYS_ONLY = UNKNOWN;
254239

255240
/** @tentative-return-type */
256241
public function hasChildren(): bool {}

ext/spl/spl_array_arginfo.h

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/spl/spl_directory.stub.php

Lines changed: 32 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -150,66 +150,30 @@ public function __toString(): string {}
150150

151151
class FilesystemIterator extends DirectoryIterator
152152
{
153-
/**
154-
* @var int
155-
* @cvalue SPL_FILE_DIR_CURRENT_MODE_MASK
156-
*/
157-
public const CURRENT_MODE_MASK = UNKNOWN;
158-
/**
159-
* @var int
160-
* @cvalue SPL_FILE_DIR_CURRENT_AS_PATHNAME
161-
*/
162-
public const CURRENT_AS_PATHNAME = UNKNOWN;
163-
/**
164-
* @var int
165-
* @cvalue SPL_FILE_DIR_CURRENT_AS_FILEINFO
166-
*/
167-
public const CURRENT_AS_FILEINFO = UNKNOWN;
168-
/**
169-
* @var int
170-
* @cvalue SPL_FILE_DIR_CURRENT_AS_SELF
171-
*/
172-
public const CURRENT_AS_SELF = UNKNOWN;
173-
/**
174-
* @var int
175-
* @cvalue SPL_FILE_DIR_KEY_MODE_MASK
176-
*/
177-
public const KEY_MODE_MASK = UNKNOWN;
178-
/**
179-
* @var int
180-
* @cvalue SPL_FILE_DIR_KEY_AS_PATHNAME
181-
*/
182-
public const KEY_AS_PATHNAME = UNKNOWN;
183-
/**
184-
* @var int
185-
* @cvalue SPL_FILE_DIR_FOLLOW_SYMLINKS
186-
*/
187-
public const FOLLOW_SYMLINKS = UNKNOWN;
188-
/**
189-
* @var int
190-
* @cvalue SPL_FILE_DIR_KEY_AS_FILENAME
191-
*/
192-
public const KEY_AS_FILENAME = UNKNOWN;
193-
/**
194-
* @var int
195-
* @cvalue SPL_FILE_NEW_CURRENT_AND_KEY
196-
*/
197-
public const NEW_CURRENT_AND_KEY = UNKNOWN;
198-
/**
199-
* @var int
200-
* @cvalue SPL_FILE_DIR_OTHERS_MASK
201-
*/
202-
public const OTHER_MODE_MASK = UNKNOWN;
203-
/**
204-
* @var int
205-
* @cvalue SPL_FILE_DIR_SKIPDOTS
206-
*/
207-
public const SKIP_DOTS = UNKNOWN;
208-
/**
209-
* @var int
210-
* @cvalue SPL_FILE_DIR_UNIXPATHS
211-
*/
212-
public const UNIX_PATHS = UNKNOWN;
153+
/** @cvalue SPL_FILE_DIR_CURRENT_MODE_MASK */
154+
public const int CURRENT_MODE_MASK = UNKNOWN;
155+
/** @cvalue SPL_FILE_DIR_CURRENT_AS_PATHNAME */
156+
public const int CURRENT_AS_PATHNAME = UNKNOWN;
157+
/** @cvalue SPL_FILE_DIR_CURRENT_AS_FILEINFO */
158+
public const int CURRENT_AS_FILEINFO = UNKNOWN;
159+
/** @cvalue SPL_FILE_DIR_CURRENT_AS_SELF */
160+
public const int CURRENT_AS_SELF = UNKNOWN;
161+
/** @cvalue SPL_FILE_DIR_KEY_MODE_MASK */
162+
public const int KEY_MODE_MASK = UNKNOWN;
163+
/** @cvalue SPL_FILE_DIR_KEY_AS_PATHNAME */
164+
public const int KEY_AS_PATHNAME = UNKNOWN;
165+
/** @cvalue SPL_FILE_DIR_FOLLOW_SYMLINKS */
166+
public const int FOLLOW_SYMLINKS = UNKNOWN;
167+
/** @cvalue SPL_FILE_DIR_KEY_AS_FILENAME */
168+
public const int KEY_AS_FILENAME = UNKNOWN;
169+
/** @cvalue SPL_FILE_NEW_CURRENT_AND_KEY */
170+
public const int NEW_CURRENT_AND_KEY = UNKNOWN;
171+
/** @cvalue SPL_FILE_DIR_OTHERS_MASK */
172+
public const int OTHER_MODE_MASK = UNKNOWN;
173+
/** @cvalue SPL_FILE_DIR_SKIPDOTS */
174+
public const int SKIP_DOTS = UNKNOWN;
175+
/** @cvalue SPL_FILE_DIR_UNIXPATHS */
176+
public const int UNIX_PATHS = UNKNOWN;
213177

214178
public function __construct(string $directory, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS) {}
215179

@@ -258,26 +222,14 @@ public function count(): int {}
258222

259223
class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
260224
{
261-
/**
262-
* @var int
263-
* @cvalue SPL_FILE_OBJECT_DROP_NEW_LINE
264-
*/
265-
public const DROP_NEW_LINE = UNKNOWN;
266-
/**
267-
* @var int
268-
* @cvalue SPL_FILE_OBJECT_READ_AHEAD
269-
*/
270-
public const READ_AHEAD = UNKNOWN;
271-
/**
272-
* @var int
273-
* @cvalue SPL_FILE_OBJECT_SKIP_EMPTY
274-
*/
275-
public const SKIP_EMPTY = UNKNOWN;
276-
/**
277-
* @var int
278-
* @cvalue SPL_FILE_OBJECT_READ_CSV
279-
*/
280-
public const READ_CSV = UNKNOWN;
225+
/** @cvalue SPL_FILE_OBJECT_DROP_NEW_LINE */
226+
public const int DROP_NEW_LINE = UNKNOWN;
227+
/** @cvalue SPL_FILE_OBJECT_READ_AHEAD */
228+
public const int READ_AHEAD = UNKNOWN;
229+
/** @cvalue SPL_FILE_OBJECT_SKIP_EMPTY */
230+
public const int SKIP_EMPTY = UNKNOWN;
231+
/** @cvalue SPL_FILE_OBJECT_READ_CSV */
232+
public const int READ_CSV = UNKNOWN;
281233

282234
/** @param resource|null $context */
283235
public function __construct(string $filename, string $mode = "r", bool $useIncludePath = false, $context = null) {}

ext/spl/spl_directory_arginfo.h

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)