Skip to content

Commit 18278eb

Browse files
committed
WIP / use do/while
1 parent ec41b77 commit 18278eb

File tree

2 files changed

+21
-26
lines changed

2 files changed

+21
-26
lines changed

.phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<exclude name="PHPCompatibility.Constants.NewConstants.t_coalesceFound"/>
6969
<exclude name="PHPCompatibility.Constants.NewConstants.t_coalesce_equalFound"/>
7070
<exclude name="PHPCompatibility.Constants.NewConstants.t_yield_fromFound"/>
71+
<exclude name="PHPCompatibility.Constants.NewConstants.t_readonlyFound"/>
7172
</rule>
7273

7374
<!-- Enforce PSR1 compatible namespaces. -->

WordPress/Sniffs/Security/EscapeOutputSniff.php

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -216,41 +216,35 @@ public function process_token( $stackPtr ) {
216216

217217
case \T_THROW:
218218
// Find the open parentheses, while stepping over the exception creation tokens.
219-
$ignore = Tokens::$emptyTokens;
220-
$ignore += Collections::namespacedNameTokens();
221-
$ignore += Collections::functionCallTokens();
222-
$ignore += Collections::objectOperators();
223-
$ignore[ T_READONLY ] = T_READONLY;
224-
225-
$next_relevant = $this->phpcsFile->findNext( $ignore, ( $stackPtr + 1 ), null, true );
226-
if ( false === $next_relevant ) {
227-
return;
228-
}
229-
230-
if ( \T_NEW === $this->tokens[ $next_relevant ]['code'] ) {
219+
$ignore = Tokens::$emptyTokens;
220+
$ignore += Collections::namespacedNameTokens();
221+
$ignore += Collections::functionCallTokens();
222+
$ignore += Collections::objectOperators();
223+
$ignore[ \T_READONLY ] = \T_READONLY;
224+
225+
$next_relevant = $stackPtr;
226+
do {
231227
$next_relevant = $this->phpcsFile->findNext( $ignore, ( $next_relevant + 1 ), null, true );
232228
if ( false === $next_relevant ) {
233229
return;
234230
}
235-
}
236231

237-
// Skip over attribute declarations when searching for the open parenthesis.
238-
while ( \T_ATTRIBUTE === $this->tokens[ $next_relevant ]['code'] ) {
239-
if ( isset( $this->tokens[ $next_relevant ]['attribute_closer'] ) === false ) {
240-
return;
232+
if ( \T_NEW === $this->tokens[ $next_relevant ]['code'] ) {
233+
continue;
241234
}
242235

243-
$next_relevant = $this->phpcsFile->findNext(
244-
$ignore,
245-
( $this->tokens[ $next_relevant ]['attribute_closer'] + 1 ),
246-
null,
247-
true
248-
);
236+
// Skip over attribute declarations when searching for the open parenthesis.
237+
if ( \T_ATTRIBUTE === $this->tokens[ $next_relevant ]['code'] ) {
238+
if ( isset( $this->tokens[ $next_relevant ]['attribute_closer'] ) === false ) {
239+
return;
240+
}
249241

250-
if ( false === $next_relevant ) {
251-
return;
242+
$next_relevant = $this->tokens[ $next_relevant ]['attribute_closer'];
243+
continue;
252244
}
253-
}
245+
246+
break;
247+
} while ( true );
254248

255249
if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $next_relevant ]['code']
256250
|| isset( $this->tokens[ $next_relevant ]['parenthesis_closer'] ) === false

0 commit comments

Comments
 (0)