Skip to content

Commit a1f0108

Browse files
committed
WP/GlobalVariablesOverride: add tests using asymmetric visibility properties
This commit adds a few tests using asymmetric visibility properties (including in constructor property promotion) to the `WordPress.WP.GlobalVariablesOverride` 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 f5ebe18 commit a1f0108

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,13 @@ list(
310310
array( $tab, $tabs ) => $not_a_wp_global,
311311
get($year, $day) => &$not_a_wp_global[$year]
312312
] = $array;
313+
314+
/*
315+
* Safeguard that PHP 8.4+ asymmetric visibility properties don't lead to false positives.
316+
* Including those defined using constructor property promotion.
317+
*/
318+
class AsymmetricVisibilityProperties {
319+
public private(set) string $pagenow = 'bar'; // Ok.
320+
321+
public function __construct(public protected(set) int $page = 0) {} // Ok.
322+
}

0 commit comments

Comments
 (0)