Skip to content

Commit

Permalink
Typed constants in SPL extension (#12358)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgsowa authored Oct 7, 2023
1 parent 72cac39 commit f075710
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 330 deletions.
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ PHP 8.4 UPGRADE NOTES
9. Other Changes to Extensions
========================================

- Spl:
. The class constants are typed now.

========================================
10. New Global Constants
========================================
Expand Down
35 changes: 10 additions & 25 deletions ext/spl/spl_array.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@

class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Countable
{
/**
* @var int
* @cvalue SPL_ARRAY_STD_PROP_LIST
*/
const STD_PROP_LIST = UNKNOWN;
/**
* @var int
* @cvalue SPL_ARRAY_ARRAY_AS_PROPS
*/
const ARRAY_AS_PROPS = UNKNOWN;
/** @cvalue SPL_ARRAY_STD_PROP_LIST */
public const int STD_PROP_LIST = UNKNOWN;
/** @cvalue SPL_ARRAY_ARRAY_AS_PROPS */
public const int ARRAY_AS_PROPS = UNKNOWN;

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

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

class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Countable
{
/**
* @var int
* @cvalue SPL_ARRAY_STD_PROP_LIST
*/
public const STD_PROP_LIST = UNKNOWN;
/**
* @var int
* @cvalue SPL_ARRAY_ARRAY_AS_PROPS
*/
public const ARRAY_AS_PROPS = UNKNOWN;
/** @cvalue SPL_ARRAY_STD_PROP_LIST */
public const int STD_PROP_LIST = UNKNOWN;
/** @cvalue SPL_ARRAY_ARRAY_AS_PROPS */
public const int ARRAY_AS_PROPS = UNKNOWN;

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

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

class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
{
/**
* @var int
* @cvalue SPL_ARRAY_CHILD_ARRAYS_ONLY
*/
public const CHILD_ARRAYS_ONLY = UNKNOWN;
/** @cvalue SPL_ARRAY_CHILD_ARRAYS_ONLY */
public const int CHILD_ARRAYS_ONLY = UNKNOWN;

/** @tentative-return-type */
public function hasChildren(): bool {}
Expand Down
12 changes: 6 additions & 6 deletions ext/spl/spl_array_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 32 additions & 80 deletions ext/spl/spl_directory.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,66 +150,30 @@ public function __toString(): string {}

class FilesystemIterator extends DirectoryIterator
{
/**
* @var int
* @cvalue SPL_FILE_DIR_CURRENT_MODE_MASK
*/
public const CURRENT_MODE_MASK = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_CURRENT_AS_PATHNAME
*/
public const CURRENT_AS_PATHNAME = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_CURRENT_AS_FILEINFO
*/
public const CURRENT_AS_FILEINFO = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_CURRENT_AS_SELF
*/
public const CURRENT_AS_SELF = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_KEY_MODE_MASK
*/
public const KEY_MODE_MASK = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_KEY_AS_PATHNAME
*/
public const KEY_AS_PATHNAME = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_FOLLOW_SYMLINKS
*/
public const FOLLOW_SYMLINKS = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_KEY_AS_FILENAME
*/
public const KEY_AS_FILENAME = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_NEW_CURRENT_AND_KEY
*/
public const NEW_CURRENT_AND_KEY = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_OTHERS_MASK
*/
public const OTHER_MODE_MASK = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_SKIPDOTS
*/
public const SKIP_DOTS = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_DIR_UNIXPATHS
*/
public const UNIX_PATHS = UNKNOWN;
/** @cvalue SPL_FILE_DIR_CURRENT_MODE_MASK */
public const int CURRENT_MODE_MASK = UNKNOWN;
/** @cvalue SPL_FILE_DIR_CURRENT_AS_PATHNAME */
public const int CURRENT_AS_PATHNAME = UNKNOWN;
/** @cvalue SPL_FILE_DIR_CURRENT_AS_FILEINFO */
public const int CURRENT_AS_FILEINFO = UNKNOWN;
/** @cvalue SPL_FILE_DIR_CURRENT_AS_SELF */
public const int CURRENT_AS_SELF = UNKNOWN;
/** @cvalue SPL_FILE_DIR_KEY_MODE_MASK */
public const int KEY_MODE_MASK = UNKNOWN;
/** @cvalue SPL_FILE_DIR_KEY_AS_PATHNAME */
public const int KEY_AS_PATHNAME = UNKNOWN;
/** @cvalue SPL_FILE_DIR_FOLLOW_SYMLINKS */
public const int FOLLOW_SYMLINKS = UNKNOWN;
/** @cvalue SPL_FILE_DIR_KEY_AS_FILENAME */
public const int KEY_AS_FILENAME = UNKNOWN;
/** @cvalue SPL_FILE_NEW_CURRENT_AND_KEY */
public const int NEW_CURRENT_AND_KEY = UNKNOWN;
/** @cvalue SPL_FILE_DIR_OTHERS_MASK */
public const int OTHER_MODE_MASK = UNKNOWN;
/** @cvalue SPL_FILE_DIR_SKIPDOTS */
public const int SKIP_DOTS = UNKNOWN;
/** @cvalue SPL_FILE_DIR_UNIXPATHS */
public const int UNIX_PATHS = UNKNOWN;

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

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

class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
{
/**
* @var int
* @cvalue SPL_FILE_OBJECT_DROP_NEW_LINE
*/
public const DROP_NEW_LINE = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_OBJECT_READ_AHEAD
*/
public const READ_AHEAD = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_OBJECT_SKIP_EMPTY
*/
public const SKIP_EMPTY = UNKNOWN;
/**
* @var int
* @cvalue SPL_FILE_OBJECT_READ_CSV
*/
public const READ_CSV = UNKNOWN;
/** @cvalue SPL_FILE_OBJECT_DROP_NEW_LINE */
public const int DROP_NEW_LINE = UNKNOWN;
/** @cvalue SPL_FILE_OBJECT_READ_AHEAD */
public const int READ_AHEAD = UNKNOWN;
/** @cvalue SPL_FILE_OBJECT_SKIP_EMPTY */
public const int SKIP_EMPTY = UNKNOWN;
/** @cvalue SPL_FILE_OBJECT_READ_CSV */
public const int READ_CSV = UNKNOWN;

/** @param resource|null $context */
public function __construct(string $filename, string $mode = "r", bool $useIncludePath = false, $context = null) {}
Expand Down
34 changes: 17 additions & 17 deletions ext/spl/spl_directory_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f075710

Please sign in to comment.