Skip to content

Commit d0a0518

Browse files
committed
Make DirectoryIterator current() / key() return types tentative
Fixes GH-8192.
1 parent 0b1bca6 commit d0a0518

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ PHP NEWS
2323
- SPL:
2424
. Fixed bug GH-8121 (SplFileObject - seek and key with csv file inconsistent).
2525
(cmb)
26+
. Fixed bug GH-8192 (Cannot override DirectoryIterator::current() without
27+
return typehint in 8.1). (Nikita)
2628

2729
- Standard:
2830
. Fixed bug GH-8048 (Force macOS to use statfs). (risner)

ext/spl/spl_directory.stub.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,16 @@ public function rewind(): void {}
123123
/** @tentative-return-type */
124124
public function valid(): bool {}
125125

126-
/** @return int */
126+
/**
127+
* @tentative-return-type
128+
* @return int
129+
*/
127130
public function key(): mixed {} // TODO change return type to string
128131

129-
/** @return DirectoryIterator */
132+
/**
133+
* @tentative-return-type
134+
* @return DirectoryIterator
135+
*/
130136
public function current(): mixed {} // TODO narrow return type
131137

132138
/** @tentative-return-type */

ext/spl/spl_directory_arginfo.h

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

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
@@ -102,7 +102,7 @@ ZEND_END_ARG_INFO()
102102

103103
#define arginfo_class_DirectoryIterator_valid arginfo_class_SplFileInfo_isWritable
104104

105-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DirectoryIterator_key, 0, 0, IS_MIXED, 0)
105+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DirectoryIterator_key, 0, 0, IS_MIXED, 0)
106106
ZEND_END_ARG_INFO()
107107

108108
#define arginfo_class_DirectoryIterator_current arginfo_class_DirectoryIterator_key

0 commit comments

Comments
 (0)