Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function process_token( $stackPtr ) {
protected function process_list_assignment( $stackPtr ) {
$list_open_close = Lists::getOpenClose( $this->phpcsFile, $stackPtr );
if ( false === $list_open_close ) {
// Short array, not short list.
// Live coding or short array, not short list.
return;
}

Expand Down
10 changes: 10 additions & 0 deletions WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -673,4 +673,14 @@ class WP_Atom_Server {
}
}

/*
* Safeguard that PHP 8.4+ asymmetric visibility properties don't lead to false positives.
* Including those defined using constructor property promotion.
*/
class Acronym_AsymmetricVisibilityProperties {
public private(set) string $bar = 'bar'; // Ok.

public function __construct(public protected(set) int $foo = 0) {} // Ok.
}

// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[]
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,11 @@ class Has_Mixed_Case_Property {
$lähtöaika = true; // OK.
$lÄhtÖaika = true; // Bad, but only handled by the sniff if Mbstring is available.
$lÄhtOaika = true; // Bad, handled via transliteration of non-ASCII chars if Mbstring is not available.

/*
* Safeguard that the sniff handles PHP 8.4+ asymmetric visibility properties correctly.
*/
class Acronym_AsymmetricVisibilityProperties {
public private(set) string $valid_name = 'bar'; // Ok.
public(set) string $invalidName = 'bar'; // Bad.
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function getErrorList() {
227 => 1,
238 => function_exists( 'mb_strtolower' ) ? 1 : 0,
239 => 1,
246 => 1,
);
}

Expand Down
1 change: 1 addition & 0 deletions WordPress/Tests/Security/NonceVerificationUnitTest.8.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
class IgnoreProperties {
public $_GET = array( 'key' => 'something' ); // OK.
public $_POST; // OK.
public private(set) string $_REQUEST; // Ok.
}
12 changes: 9 additions & 3 deletions WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ list(
get($year, $day) => &$not_a_wp_global[$year]
] = $array;

// Live coding/parse error.
// This has to be the last test in the file!
list( $tab, $tabs
/*
* Safeguard that PHP 8.4+ asymmetric visibility properties don't lead to false positives.
* Including those defined using constructor property promotion.
*/
class AsymmetricVisibilityProperties {
public private(set) string $pagenow = 'bar'; // Ok.

public function __construct(public protected(set) int $page = 0) {} // Ok.
}
8 changes: 8 additions & 0 deletions WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.8.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

/*
* Intentional parse error (missing closing parenthesis).
* This should be the only test in this file.
*/

list( $tab, $tabs
Loading