| @@ 385-389 (lines=5) @@ | ||
| 382 | case T_STRING: |
|
| 383 | if (strtolower($token['content']) === 'url') { |
|
| 384 | // Find the next content. |
|
| 385 | for ($x = ($stackPtr + 1); $x < $numTokens; $x++) { |
|
| 386 | if (isset(Util\Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) { |
|
| 387 | break; |
|
| 388 | } |
|
| 389 | } |
|
| 390 | ||
| 391 | // Needs to be in the format "url(" for it to be a URL. |
|
| 392 | if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) { |
|
| @@ 397-401 (lines=5) @@ | ||
| 394 | } |
|
| 395 | ||
| 396 | // Make sure the content isn't empty. |
|
| 397 | for ($y = ($x + 1); $y < $numTokens; $y++) { |
|
| 398 | if (isset(Util\Tokens::$emptyTokens[$finalTokens[$y]['code']]) === false) { |
|
| 399 | break; |
|
| 400 | } |
|
| 401 | } |
|
| 402 | ||
| 403 | if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) { |
|
| 404 | continue; |
|
| @@ 916-920 (lines=5) @@ | ||
| 913 | // Find the last non-whitespace token that was added |
|
| 914 | // to the tokens array. |
|
| 915 | $numTokens = count($tokens); |
|
| 916 | for ($prev = ($numTokens - 1); $prev >= 0; $prev--) { |
|
| 917 | if (isset(Util\Tokens::$emptyTokens[$tokens[$prev]['code']]) === false) { |
|
| 918 | break; |
|
| 919 | } |
|
| 920 | } |
|
| 921 | ||
| 922 | if (isset($beforeTokens[$tokens[$prev]['code']]) === false) { |
|
| 923 | return null; |
|
| @@ 1037-1041 (lines=5) @@ | ||
| 1034 | ||
| 1035 | // Looking for functions that are actually closures. |
|
| 1036 | if ($this->tokens[$i]['code'] === T_FUNCTION && isset($this->tokens[$i]['scope_opener']) === true) { |
|
| 1037 | for ($x = ($i + 1); $x < $numTokens; $x++) { |
|
| 1038 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { |
|
| 1039 | break; |
|
| 1040 | } |
|
| 1041 | } |
|
| 1042 | ||
| 1043 | if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) { |
|
| 1044 | $this->tokens[$i]['code'] = T_CLOSURE; |
|
| @@ 1121-1125 (lines=5) @@ | ||
| 1118 | } |
|
| 1119 | ||
| 1120 | // The string to the left of the colon is either a property or label. |
|
| 1121 | for ($label = ($i - 1); $label >= 0; $label--) { |
|
| 1122 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$label]['code']]) === false) { |
|
| 1123 | break; |
|
| 1124 | } |
|
| 1125 | } |
|
| 1126 | ||
| 1127 | if ($this->tokens[$label]['code'] !== T_STRING |
|
| 1128 | && $this->tokens[$label]['code'] !== T_CONSTANT_ENCAPSED_STRING |
|
| @@ 1159-1164 (lines=6) @@ | ||
| 1156 | ||
| 1157 | if ($this->tokens[$i]['code'] === T_FUNCTION) { |
|
| 1158 | // Context sensitive keywords support. |
|
| 1159 | for ($x = ($i + 1); $x < $numTokens; $x++) { |
|
| 1160 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { |
|
| 1161 | // Non-whitespace content. |
|
| 1162 | break; |
|
| 1163 | } |
|
| 1164 | } |
|
| 1165 | ||
| 1166 | if ($x === $numTokens) { |
|
| 1167 | // We got to the end without finding any more |
|
| @@ 1265-1269 (lines=5) @@ | ||
| 1262 | Detect anonymous classes and assign them a different token. |
|
| 1263 | */ |
|
| 1264 | ||
| 1265 | for ($x = ($i + 1); $x < $numTokens; $x++) { |
|
| 1266 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { |
|
| 1267 | break; |
|
| 1268 | } |
|
| 1269 | } |
|
| 1270 | ||
| 1271 | if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS |
|
| 1272 | || $this->tokens[$x]['code'] === T_OPEN_CURLY_BRACKET |
|
| @@ 1300-1304 (lines=5) @@ | ||
| 1297 | } else if ($this->tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) { |
|
| 1298 | // Unless there is a variable or a bracket before this token, |
|
| 1299 | // it is the start of an array being defined using the short syntax. |
|
| 1300 | for ($x = ($i - 1); $x > 0; $x--) { |
|
| 1301 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { |
|
| 1302 | break; |
|
| 1303 | } |
|
| 1304 | } |
|
| 1305 | ||
| 1306 | $allowed = array( |
|
| 1307 | T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, |
|
| @@ 1333-1337 (lines=5) @@ | ||
| 1330 | ||
| 1331 | continue; |
|
| 1332 | } else if ($this->tokens[$i]['code'] === T_STATIC) { |
|
| 1333 | for ($x = ($i - 1); $x > 0; $x--) { |
|
| 1334 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { |
|
| 1335 | break; |
|
| 1336 | } |
|
| 1337 | } |
|
| 1338 | ||
| 1339 | if ($this->tokens[$x]['code'] === T_INSTANCEOF) { |
|
| 1340 | $this->tokens[$i]['code'] = T_STRING; |
|
| @@ 1363-1368 (lines=6) @@ | ||
| 1360 | || $this->tokens[$i]['code'] === T_FALSE |
|
| 1361 | || $this->tokens[$i]['code'] === T_NULL |
|
| 1362 | ) { |
|
| 1363 | for ($x = ($i + 1); $i < $numTokens; $x++) { |
|
| 1364 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { |
|
| 1365 | // Non-whitespace content. |
|
| 1366 | break; |
|
| 1367 | } |
|
| 1368 | } |
|
| 1369 | ||
| 1370 | $context = array( |
|
| 1371 | T_OBJECT_OPERATOR => true, |
|
| @@ 1387-1392 (lines=6) @@ | ||
| 1384 | } |
|
| 1385 | } else if ($this->tokens[$i]['code'] === T_CONST) { |
|
| 1386 | // Context sensitive keywords support. |
|
| 1387 | for ($x = ($i + 1); $i < $numTokens; $x++) { |
|
| 1388 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { |
|
| 1389 | // Non-whitespace content. |
|
| 1390 | break; |
|
| 1391 | } |
|
| 1392 | } |
|
| 1393 | ||
| 1394 | if ($this->tokens[$x]['code'] !== T_STRING) { |
|
| 1395 | if (PHP_CodeSniffer_VERBOSITY > 1) { |
|
| @@ 1406-1411 (lines=6) @@ | ||
| 1403 | } |
|
| 1404 | } else if ($this->tokens[$i]['code'] === T_PAAMAYIM_NEKUDOTAYIM) { |
|
| 1405 | // Context sensitive keywords support. |
|
| 1406 | for ($x = ($i + 1); $i < $numTokens; $x++) { |
|
| 1407 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { |
|
| 1408 | // Non-whitespace content. |
|
| 1409 | break; |
|
| 1410 | } |
|
| 1411 | } |
|
| 1412 | ||
| 1413 | if (in_array($this->tokens[$x]['code'], array(T_STRING, T_VARIABLE, T_DOLLAR), true) === false) { |
|
| 1414 | if (PHP_CodeSniffer_VERBOSITY > 1) { |
|
| @@ 1440-1445 (lines=6) @@ | ||
| 1437 | // and that brace has been ignored, it is actually |
|
| 1438 | // opening this case statement and the opener and closer are |
|
| 1439 | // probably set incorrectly. |
|
| 1440 | for ($x = ($scopeOpener + 1); $x < $numTokens; $x++) { |
|
| 1441 | if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { |
|
| 1442 | // Non-whitespace content. |
|
| 1443 | break; |
|
| 1444 | } |
|
| 1445 | } |
|
| 1446 | ||
| 1447 | if ($this->tokens[$x]['code'] === T_CASE || $this->tokens[$x]['code'] === T_DEFAULT) { |
|
| 1448 | // Special case for multiple CASE statements that share the same |
|