array_change_key_case() Validates Its Case Argument

array_change_key_case() accepts a second argument, either CASE_LOWER or CASE_UPPER. Until PHP 8.6, any other value was silently treated as CASE_LOWER. In PHP 8.6, an invalid value throws a ValueError.

PHP code

<?php

var_dump(array_change_key_case(['A' => 1], 99));

?>

Before

array(1) {
  [A]=>
  int(1)
}

After

array_change_key_case(): Argument #2 ($case) must be either CASE_LOWER or CASE_UPPER

PHP version change

This behavior changed in 8.6

See Also

Error Messages