diff --git a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc index e63122d3..011e250b 100644 --- a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc +++ b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc @@ -137,7 +137,7 @@ class Acronym_Example { function do_something( $param = 'default' ) {} } -$acronym_class = new class { +$acronym_class = new readonly class { const SOME_CONSTANT = 'value'; public $var = 'abc'; diff --git a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.inc b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.1.inc similarity index 96% rename from WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.inc rename to WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.1.inc index 6a06ba3c..4fa7a05e 100644 --- a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.inc +++ b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.1.inc @@ -223,6 +223,11 @@ function lähtöaika() {} // OK. function lÄhtÖaika() {} // Bad, but only handled by the sniff if Mbstring is available. function lÄhtOaika() {} // Bad, handled via transliteration of non-ASCII chars if Mbstring is not available. -// Live coding/parse error. -// This has to be the last test in the file. -function +/* + * Safeguard that PHP 8.3+ readonly anonymous classes are handled correctly. + */ +$anon_class = new readonly class() { + public function camelCase() {} // Bad. + protected function __something() {} // Bad. + private function snake_case() {} // Ok. +}; diff --git a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.2.inc b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.2.inc new file mode 100644 index 00000000..4f73e110 --- /dev/null +++ b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.2.inc @@ -0,0 +1,8 @@ + Key is the line number, value is the number of expected errors. */ - public function getErrorList() { - return array( - 3 => 1, - 9 => 1, - 13 => 1, - 15 => 1, - 79 => 2, - 80 => 2, - 81 => 2, - 82 => 2, - 83 => 2, - 84 => 2, - 85 => 2, - 86 => 2, - 87 => 2, - 88 => 2, - 89 => 2, - 106 => 2, - 116 => 1, - 117 => 1, - 157 => 2, - 183 => 1, - 184 => 1, - 185 => 1, - 199 => 1, - 208 => 2, - 210 => 1, - 223 => function_exists( 'mb_strtolower' ) ? 1 : 0, - 224 => 1, - ); + public function getErrorList( $testFile = '' ) { + switch ( $testFile ) { + case 'ValidFunctionNameUnitTest.1.inc': + return array( + 3 => 1, + 9 => 1, + 13 => 1, + 15 => 1, + 79 => 2, + 80 => 2, + 81 => 2, + 82 => 2, + 83 => 2, + 84 => 2, + 85 => 2, + 86 => 2, + 87 => 2, + 88 => 2, + 89 => 2, + 106 => 2, + 116 => 1, + 117 => 1, + 157 => 2, + 183 => 1, + 184 => 1, + 185 => 1, + 199 => 1, + 208 => 2, + 210 => 1, + 223 => function_exists( 'mb_strtolower' ) ? 1 : 0, + 224 => 1, + 230 => 1, + 231 => 1, + ); + + default: + return array(); + } } /**