Skip to content

Commit fb50666

Browse files
committed
NamingConventions/ValidVariableName: add tests using asymmetric visibility properties
This commit adds a few tests using asymmetric visibility properties (including in constructor property promotion) to the `WordPress.NamingConventions.ValidVariableName` tests. This is just to ensure that the sniff continues to apply its variable name rules when dealing with asymmetric visibility properties added in PHP 8.4. The sniff was already handling asymmetric visibility properties correctly, and no change to the sniff code is needed.
1 parent 9e94d3b commit fb50666

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,11 @@ class Has_Mixed_Case_Property {
237237
$lähtöaika = true; // OK.
238238
$lÄhtÖaika = true; // Bad, but only handled by the sniff if Mbstring is available.
239239
$lÄhtOaika = true; // Bad, handled via transliteration of non-ASCII chars if Mbstring is not available.
240+
241+
/*
242+
* Safeguard that the sniff handles PHP 8.4+ asymmetric visibility properties correctly.
243+
*/
244+
class Acronym_AsymmetricVisibilityProperties {
245+
public private(set) string $valid_name = 'bar'; // Ok.
246+
public(set) string $invalidName = 'bar'; // Bad.
247+
}

WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function getErrorList() {
9898
227 => 1,
9999
238 => function_exists( 'mb_strtolower' ) ? 1 : 0,
100100
239 => 1,
101+
246 => 1,
101102
);
102103
}
103104

0 commit comments

Comments
 (0)