1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/standard: Deprecate passing null to readdir(), rewinddir(), and closedir() (#19423)

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_null_to_readdir_rewinddir_and_closedir
This commit is contained in:
Gina Peter Banyard
2025-08-09 18:08:21 +01:00
committed by GitHub
parent ba21ab4ea0
commit dc0962c243
10 changed files with 86 additions and 3 deletions

View File

@@ -160,6 +160,8 @@ PHP_FUNCTION(dir)
static php_stream* php_dir_get_directory_stream_from_user_arg(php_stream *dir_stream)
{
if (dir_stream == NULL) {
php_error_docref(NULL, E_DEPRECATED,
"Passing null is deprecated, instead the last opened directory stream should be provided");
if (UNEXPECTED(DIRG(default_dir) == NULL)) {
zend_type_error("No resource supplied");
return NULL;

View File

@@ -44,6 +44,8 @@ rmdir($dir_path);
*** Testing closedir() : basic functionality ***
-- Call closedir() with no arguments: --
Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
NULL
-- Check Directory Handle: --
resource(%d) of type (Unknown)

View File

@@ -38,6 +38,8 @@ rmdir($dir_path);
*** Testing closedir() : basic functionality ***
-- Call closedir() with no arguments: --
Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
NULL
-- Check Directory Handle: --
resource(%d) of type (Unknown)

View File

@@ -8,5 +8,6 @@ try {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
--EXPECTF--
Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
No resource supplied

View File

@@ -65,6 +65,18 @@ string(9) "file3.tmp"
-- Call readdir() without $path argument --
resource(%d) of type (stream)
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
string(1) "."
string(2) ".."
string(9) "file1.tmp"

View File

@@ -59,6 +59,18 @@ string(9) "file3.tmp"
-- Call readdir() without $path argument --
resource(%d) of type (stream)
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
string(1) "."
string(2) ".."
string(9) "file1.tmp"

View File

@@ -61,7 +61,7 @@ closedir();
$dir_path = __DIR__ . "/私はガラスを食べられますreaddir_variation6";
rmdir($dir_path);
?>
--EXPECT--
--EXPECTF--
*** Testing readdir() : usage variations ***
-- Reading Directory Contents with Previous Handle --
@@ -72,8 +72,22 @@ string(59) "私はガラスを食べられますreaddir_variation62.tmp"
string(59) "私はガラスを食べられますreaddir_variation63.tmp"
-- Reading Directory Contents with Current Handle (no arguments supplied) --
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
string(1) "."
string(2) ".."
string(59) "私はガラスを食べられますreaddir_variation61.tmp"
string(59) "私はガラスを食べられますreaddir_variation62.tmp"
string(59) "私はガラスを食べられますreaddir_variation63.tmp"
Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

View File

@@ -55,7 +55,7 @@ closedir();
$dir_path = __DIR__ . "/readdir_variation6";
rmdir($dir_path);
?>
--EXPECT--
--EXPECTF--
*** Testing readdir() : usage variations ***
-- Reading Directory Contents with Previous Handle --
@@ -66,8 +66,22 @@ string(23) "readdir_variation62.tmp"
string(23) "readdir_variation63.tmp"
-- Reading Directory Contents with Current Handle (no arguments supplied) --
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
string(1) "."
string(2) ".."
string(23) "readdir_variation61.tmp"
string(23) "readdir_variation62.tmp"
string(23) "readdir_variation63.tmp"
Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d

View File

@@ -82,6 +82,14 @@ NULL
bool(true)
-- Read and rewind second directory (no argument supplied) --
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
array(3) {
[0]=>
string(1) "."
@@ -90,5 +98,9 @@ array(3) {
[2]=>
string(45) "私はガラスを食べられますfile2.tmp"
}
Deprecated: rewinddir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
NULL
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
bool(true)

View File

@@ -76,6 +76,14 @@ NULL
bool(true)
-- Read and rewind second directory (no argument supplied) --
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
array(3) {
[0]=>
string(1) "."
@@ -84,5 +92,9 @@ array(3) {
[2]=>
string(9) "file2.tmp"
}
Deprecated: rewinddir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
NULL
Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d
bool(true)