Skip to content

Commit 8d8812b

Browse files
authored
Allow for short array syntax (#454)
Allow for short array syntax
2 parents bf8558a + 38ec339 commit 8d8812b

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

.phpcs.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
<!-- Disallow long array syntax -->
3535
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
3636

37+
<!-- Allow short array syntax -->
38+
<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found">
39+
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/>
40+
</rule>
41+
3742
<!-- Check code for cross-version PHP compatibility. -->
3843
<config name="testVersion" value="5.6-"/>
3944
<rule ref="PHPCompatibility">

WordPressVIPMinimum/Sniffs/Functions/DynamicCallsSniff.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ private function collect_variables() {
106106
return;
107107
}
108108

109-
$current_var_name = $this->tokens[
110-
$this->stackPtr
111-
]['content'];
109+
$current_var_name = $this->tokens[ $this->stackPtr ]['content'];
112110

113111
/*
114112
* Find assignments ( $foo = "bar"; )
@@ -202,9 +200,7 @@ private function find_dynamic_calls() {
202200
*/
203201

204202
if ( ! isset(
205-
$this->variables_arr[
206-
$this->tokens[ $this->stackPtr ]['content']
207-
]
203+
$this->variables_arr[ $this->tokens[ $this->stackPtr ]['content'] ]
208204
) ) {
209205
return;
210206
}
@@ -220,16 +216,12 @@ private function find_dynamic_calls() {
220216
$i++;
221217
} while (
222218
'T_WHITESPACE' ===
223-
$this->tokens[
224-
$this->stackPtr + $i
225-
]['type']
219+
$this->tokens[ $this->stackPtr + $i ]['type']
226220
);
227221

228222
if (
229223
'T_OPEN_PARENTHESIS' !==
230-
$this->tokens[
231-
$this->stackPtr + $i
232-
]['type']
224+
$this->tokens[ $this->stackPtr + $i ]['type']
233225
) {
234226
return;
235227
}
@@ -242,9 +234,7 @@ private function find_dynamic_calls() {
242234
*/
243235

244236
if ( ! in_array(
245-
$this->variables_arr[
246-
$this->tokens[ $this->stackPtr ]['content']
247-
],
237+
$this->variables_arr[ $this->tokens[ $this->stackPtr ]['content'] ],
248238
$this->blacklisted_functions,
249239
true
250240
) ) {

0 commit comments

Comments
 (0)