Skip to content

Commit 9e94d3b

Browse files
committed
NamingConventions/PrefixAllGlobals: 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.PrefixAllGlobals` tests. This is just to ensure that the part of the sniff code that ignores properties or method parameters (in the case of constructor property promotion) continues to handle PHP 8.4+ asymmetric visibility properties correctly. No change to the sniff code is needed.
1 parent 00e9af7 commit 9e94d3b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,4 +673,14 @@ class WP_Atom_Server {
673673
}
674674
}
675675

676+
/*
677+
* Safeguard that PHP 8.4+ asymmetric visibility properties don't lead to false positives.
678+
* Including those defined using constructor property promotion.
679+
*/
680+
class Acronym_AsymmetricVisibilityProperties {
681+
public private(set) string $bar = 'bar'; // Ok.
682+
683+
public function __construct(public protected(set) int $foo = 0) {} // Ok.
684+
}
685+
676686
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[]

0 commit comments

Comments
 (0)