Skip to content

Commit

Permalink
Make DirectoryIterator current() / key() return types tentative
Browse files Browse the repository at this point in the history
Fixes GH-8192.
  • Loading branch information
nikic committed Mar 12, 2022
1 parent 0b1bca6 commit d0a0518
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ PHP NEWS
- SPL:
. Fixed bug GH-8121 (SplFileObject - seek and key with csv file inconsistent).
(cmb)
. Fixed bug GH-8192 (Cannot override DirectoryIterator::current() without
return typehint in 8.1). (Nikita)

- Standard:
. Fixed bug GH-8048 (Force macOS to use statfs). (risner)
Expand Down
10 changes: 8 additions & 2 deletions ext/spl/spl_directory.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,16 @@ public function rewind(): void {}
/** @tentative-return-type */
public function valid(): bool {}

/** @return int */
/**
* @tentative-return-type
* @return int
*/
public function key(): mixed {} // TODO change return type to string

/** @return DirectoryIterator */
/**
* @tentative-return-type
* @return DirectoryIterator
*/
public function current(): mixed {} // TODO narrow return type

/** @tentative-return-type */
Expand Down
4 changes: 2 additions & 2 deletions ext/spl/spl_directory_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: eab71d8a7172dba2dac3c6fa97b2064c7a99191f */
* Stub hash: 3f2caf1c46760d8ef629ccb2e94ab0dba09f713b */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
Expand Down Expand Up @@ -102,7 +102,7 @@ ZEND_END_ARG_INFO()

#define arginfo_class_DirectoryIterator_valid arginfo_class_SplFileInfo_isWritable

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DirectoryIterator_key, 0, 0, IS_MIXED, 0)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DirectoryIterator_key, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_DirectoryIterator_current arginfo_class_DirectoryIterator_key
Expand Down

0 comments on commit d0a0518

Please sign in to comment.