Skip to content

Commit 0a32996

Browse files
committed
Merge branch 'master' into 4.x
2 parents e9cf86f + 288a2a9 commit 0a32996

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/Files/File.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,10 @@ public function getMemberProperties($stackPtr)
19071907
throw new RuntimeException('$stackPtr must be of type T_VARIABLE');
19081908
}
19091909

1910+
if (empty($this->tokens[$stackPtr]['conditions']) === true) {
1911+
throw new RuntimeException('$stackPtr is not a class member var');
1912+
}
1913+
19101914
$conditions = $this->tokens[$stackPtr]['conditions'];
19111915
$conditions = array_keys($conditions);
19121916
$ptr = array_pop($conditions);

src/Tokenizers/PHP.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,16 +1531,18 @@ protected function tokenize($string)
15311531
$newToken['type'] = 'T_ATTRIBUTE';
15321532
$newToken['content'] = '#[';
15331533
$finalTokens[$newStackPtr] = $newToken;
1534+
$newStackPtr++;
15341535

1535-
$tokens[$bracketCloser] = [];
1536-
$tokens[$bracketCloser][0] = T_ATTRIBUTE_END;
1537-
$tokens[$bracketCloser][1] = ']';
1536+
if ($bracketCloser !== null) {
1537+
$tokens[$bracketCloser] = [];
1538+
$tokens[$bracketCloser][0] = T_ATTRIBUTE_END;
1539+
$tokens[$bracketCloser][1] = ']';
15381540

1539-
if (PHP_CODESNIFFER_VERBOSITY > 1) {
1540-
StatusWriter::write("* token $bracketCloser changed from T_CLOSE_SQUARE_BRACKET to T_ATTRIBUTE_END", 2);
1541+
if (PHP_CODESNIFFER_VERBOSITY > 1) {
1542+
StatusWriter::write("* token $bracketCloser changed from T_CLOSE_SQUARE_BRACKET to T_ATTRIBUTE_END", 2);
1543+
}
15411544
}
15421545

1543-
$newStackPtr++;
15441546
continue;
15451547
}//end if
15461548

@@ -2187,7 +2189,7 @@ protected function tokenize($string)
21872189
}
21882190

21892191
if ($prevNonEmpty === null
2190-
&& isset(Tokens::EMPTY_TOKENS[$tokenType]) === false
2192+
&& @isset(Tokens::EMPTY_TOKENS[$tokenType]) === false
21912193
) {
21922194
// Found the previous non-empty token.
21932195
if ($tokenType === ':' || $tokenType === ',' || $tokenType === T_ATTRIBUTE_END) {
@@ -2206,8 +2208,8 @@ protected function tokenize($string)
22062208

22072209
if ($tokenType === T_FUNCTION
22082210
|| $tokenType === T_FN
2209-
|| isset(Tokens::METHOD_MODIFIERS[$tokenType]) === true
2210-
|| isset(Tokens::SCOPE_MODIFIERS[$tokenType]) === true
2211+
|| @isset(Tokens::METHOD_MODIFIERS[$tokenType]) === true
2212+
|| @isset(Tokens::SCOPE_MODIFIERS[$tokenType]) === true
22112213
|| $tokenType === T_VAR
22122214
|| $tokenType === T_READONLY
22132215
) {
@@ -2230,7 +2232,7 @@ protected function tokenize($string)
22302232
break;
22312233
}
22322234

2233-
if (isset(Tokens::EMPTY_TOKENS[$tokenType]) === false) {
2235+
if (@isset(Tokens::EMPTY_TOKENS[$tokenType]) === false) {
22342236
$lastSeenNonEmpty = $tokenType;
22352237
}
22362238
}//end for

0 commit comments

Comments
 (0)