Skip to content

Commit 437a0e1

Browse files
Throw ValueError when a wrong flag value is provided to the second argument of scandir()
1 parent fae07f0 commit 437a0e1

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ PHP 8.6 UPGRADE NOTES
134134
- Standard:
135135
. pathinfo() now raises a ValueError when an invalid $flag argument
136136
value is passed.
137+
. scandir() now raises a ValueError when an invalid $sorting_order
138+
argument value is passed.
137139

138140
- Zip:
139141
. ZipArchive::extractTo now raises a TypeError for the

ext/standard/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ PHP_FUNCTION(scandir)
591591
} else if (flags == PHP_SCANDIR_SORT_DESCENDING) {
592592
n = php_stream_scandir(dirn, &namelist, context, (void *) php_stream_dirent_alphasortr);
593593
} else {
594-
zend_argument_value_error(2, "must be one of the SCANDIR_SORT_ASCENDING, SCANDIR_SORT_DESCENDING and SCANDIR_SORT_NONE constants");
594+
zend_argument_value_error(2, "must be one of the SCANDIR_SORT_ASCENDING, SCANDIR_SORT_DESCENDING, or SCANDIR_SORT_NONE constants");
595595
RETURN_THROWS();
596596
}
597597

ext/standard/tests/dir/scandir_invalid_flag.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ try {
99
}
1010
?>
1111
--EXPECT--
12-
scandir(): Argument #2 ($sorting_order) must be one of the SCANDIR_SORT_ASCENDING, SCANDIR_SORT_DESCENDING and SCANDIR_SORT_NONE constants
12+
scandir(): Argument #2 ($sorting_order) must be one of the SCANDIR_SORT_ASCENDING, SCANDIR_SORT_DESCENDING, or SCANDIR_SORT_NONE constants

0 commit comments

Comments
 (0)