Skip to content

Commit 747ddc4

Browse files
committed
standard: Validate sort_type argument in array_unique()
1 parent 6fe0fd0 commit 747ddc4

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
array_unique() throws ValueError on invalid sort_type
3+
--FILE--
4+
<?php
5+
try {
6+
array_unique([1, 2, 3], 999);
7+
} catch (ValueError $e) {
8+
echo $e->getMessage(), PHP_EOL;
9+
}
10+
11+
try {
12+
array_unique([1, 2, 3], -1);
13+
} catch (ValueError $e) {
14+
echo $e->getMessage(), PHP_EOL;
15+
}
16+
?>
17+
--EXPECT--
18+
array_unique(): Argument #2 ($flags) must be one of PHP_SORT_REGULAR, PHP_SORT_NUMERIC, PHP_SORT_STRING, or PHP_SORT_LOCALE_STRING
19+
array_unique(): Argument #2 ($flags) must be one of PHP_SORT_REGULAR, PHP_SORT_NUMERIC, PHP_SORT_STRING, or PHP_SORT_LOCALE_STRING

0 commit comments

Comments
 (0)