Skip to content

Commit 29920a0

Browse files
committed
AbstractArrayAssignmentRestrictions children: adjust for changes in received $val
The `$val` parameter received by the `callback()` method will no longer automatically have been stripped of quotes. This adjusts the `callback()` methods of the sniff which extend the WPCS `AbstractArrayAssignmentRestrictions` sniff to take this into account.
1 parent 1a8b51c commit 29920a0

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

WordPressVIPMinimum/Sniffs/Performance/NoPagingSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ public function getGroups() {
5252
public function callback( $key, $val, $line, $group ) {
5353
$key = strtolower( $key );
5454

55-
return ( $key === 'nopaging' && ( $val === 'true' || $val === 1 ) );
55+
return ( $key === 'nopaging' && ( $val === 'true' || $val === '1' ) );
5656
}
5757
}

WordPressVIPMinimum/Sniffs/Performance/OrderByRandSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace WordPressVIPMinimum\Sniffs\Performance;
1111

12+
use PHPCSUtils\Utils\TextStrings;
1213
use WordPressCS\WordPress\AbstractArrayAssignmentRestrictionsSniff;
1314

1415
/**
@@ -31,7 +32,7 @@ public function getGroups() {
3132
return [
3233
'orderby' => [
3334
'type' => 'error',
34-
'message' => 'Detected forbidden query_var "%s" of "%s". Use vip_get_random_posts() instead.',
35+
'message' => 'Detected forbidden query_var "%s" of %s. Use vip_get_random_posts() instead.',
3536
'keys' => [
3637
'orderby',
3738
],
@@ -50,6 +51,7 @@ public function getGroups() {
5051
* @return bool FALSE if no match, TRUE if matches.
5152
*/
5253
public function callback( $key, $val, $line, $group ) {
54+
$val = TextStrings::stripQuotes( $val );
5355
return strtolower( $val ) === 'rand';
5456
}
5557
}

WordPressVIPMinimum/Sniffs/Performance/RegexpCompareSniff.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace WordPressVIPMinimum\Sniffs\Performance;
99

10+
use PHPCSUtils\Utils\TextStrings;
1011
use WordPressCS\WordPress\AbstractArrayAssignmentRestrictionsSniff;
1112

1213
/**
@@ -45,6 +46,7 @@ public function getGroups() {
4546
* @return bool FALSE if no match, TRUE if matches.
4647
*/
4748
public function callback( $key, $val, $line, $group ) {
49+
$val = TextStrings::stripQuotes( $val );
4850
return ( strpos( $val, 'NOT REGEXP' ) === 0
4951
|| strpos( $val, 'REGEXP' ) === 0
5052
);

0 commit comments

Comments
 (0)