Skip to content

Commit

Permalink
forbidEnumInFunctionArguments: deny also natcasesort (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal authored Dec 22, 2023
1 parent 0512340 commit 3c286ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Rule/ForbidEnumInFunctionArgumentsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ForbidEnumInFunctionArgumentsRule implements Rule
'asort' => [0, self::REASON_UNPREDICTABLE_RESULT],
'arsort' => [0, self::REASON_UNPREDICTABLE_RESULT],
'natsort' => [0, self::REASON_IMPLICIT_TO_STRING],
'natcasesort' => [0, self::REASON_IMPLICIT_TO_STRING],
'array_count_values' => [0, self::REASON_SKIPS_ENUMS],
'array_fill_keys' => [0, self::REASON_IMPLICIT_TO_STRING],
'array_flip' => [0, self::REASON_SKIPS_ENUMS],
Expand Down
1 change: 1 addition & 0 deletions tests/Rule/data/ForbidEnumInFunctionArgumentsRule/code.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function testAllFunctions()
asort($enums1); // error: Argument 1 in asort() cannot contain enum as the function causes unexpected results
arsort($enums1); // error: Argument 1 in arsort() cannot contain enum as the function causes unexpected results
natsort($enums1); // error: Argument 1 in natsort() cannot contain enum as the function causes implicit __toString conversion which is not supported for enums
natcasesort($enums1); // error: Argument 1 in natcasesort() cannot contain enum as the function causes implicit __toString conversion which is not supported for enums
array_count_values($enums1); // error: Argument 1 in array_count_values() cannot contain enum as the function will skip any enums and produce warning
array_fill_keys($enums1, 1); // error: Argument 1 in array_fill_keys() cannot contain enum as the function causes implicit __toString conversion which is not supported for enums
array_flip($enums1); // error: Argument 1 in array_flip() cannot contain enum as the function will skip any enums and produce warning
Expand Down

0 comments on commit 3c286ce

Please sign in to comment.