| @@ 384-388 (lines=5) @@ | ||
| 381 | case T_STRING: |
|
| 382 | if (strtolower($token['content']) === 'url') { |
|
| 383 | // Find the next content. |
|
| 384 | for ($x = ($stackPtr + 1); $x < $numTokens; $x++) { |
|
| 385 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) { |
|
| 386 | break; |
|
| 387 | } |
|
| 388 | } |
|
| 389 | ||
| 390 | // Needs to be in the format "url(" for it to be a URL. |
|
| 391 | if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) { |
|
| @@ 396-400 (lines=5) @@ | ||
| 393 | } |
|
| 394 | ||
| 395 | // Make sure the content isn't empty. |
|
| 396 | for ($y = ($x + 1); $y < $numTokens; $y++) { |
|
| 397 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$finalTokens[$y]['code']]) === false) { |
|
| 398 | break; |
|
| 399 | } |
|
| 400 | } |
|
| 401 | ||
| 402 | if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) { |
|
| 403 | continue; |
|
| @@ 919-923 (lines=5) @@ | ||
| 916 | // Find the last non-whitespace token that was added |
|
| 917 | // to the tokens array. |
|
| 918 | $numTokens = count($tokens); |
|
| 919 | for ($prev = ($numTokens - 1); $prev >= 0; $prev--) { |
|
| 920 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$prev]['code']]) === false) { |
|
| 921 | break; |
|
| 922 | } |
|
| 923 | } |
|
| 924 | ||
| 925 | if (isset($beforeTokens[$tokens[$prev]['code']]) === false) { |
|
| 926 | return null; |
|
| @@ 1043-1047 (lines=5) @@ | ||
| 1040 | ||
| 1041 | // Looking for functions that are actually closures. |
|
| 1042 | if ($tokens[$i]['code'] === T_FUNCTION && isset($tokens[$i]['scope_opener']) === true) { |
|
| 1043 | for ($x = ($i + 1); $x < $numTokens; $x++) { |
|
| 1044 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) { |
|
| 1045 | break; |
|
| 1046 | } |
|
| 1047 | } |
|
| 1048 | ||
| 1049 | if ($tokens[$x]['code'] === T_OPEN_PARENTHESIS) { |
|
| 1050 | $tokens[$i]['code'] = T_CLOSURE; |
|
| @@ 1127-1131 (lines=5) @@ | ||
| 1124 | } |
|
| 1125 | ||
| 1126 | // The string to the left of the colon is either a property or label. |
|
| 1127 | for ($label = ($i - 1); $label >= 0; $label--) { |
|
| 1128 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$label]['code']]) === false) { |
|
| 1129 | break; |
|
| 1130 | } |
|
| 1131 | } |
|
| 1132 | ||
| 1133 | if ($tokens[$label]['code'] !== T_STRING |
|
| 1134 | && $tokens[$label]['code'] !== T_CONSTANT_ENCAPSED_STRING |
|
| @@ 1055-1060 (lines=6) @@ | ||
| 1052 | ||
| 1053 | if ($tokens[$i]['code'] === T_FUNCTION) { |
|
| 1054 | // Context sensitive keywords support. |
|
| 1055 | for ($x = ($i + 1); $x < $numTokens; $x++) { |
|
| 1056 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) { |
|
| 1057 | // Non-whitespace content. |
|
| 1058 | break; |
|
| 1059 | } |
|
| 1060 | } |
|
| 1061 | ||
| 1062 | if ($x === $numTokens) { |
|
| 1063 | // We got to the end without finding any more |
|
| @@ 1161-1165 (lines=5) @@ | ||
| 1158 | Detect anonymous classes and assign them a different token. |
|
| 1159 | */ |
|
| 1160 | ||
| 1161 | for ($x = ($i + 1); $x < $numTokens; $x++) { |
|
| 1162 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) { |
|
| 1163 | break; |
|
| 1164 | } |
|
| 1165 | } |
|
| 1166 | ||
| 1167 | if ($tokens[$x]['code'] === T_OPEN_PARENTHESIS |
|
| 1168 | || $tokens[$x]['code'] === T_OPEN_CURLY_BRACKET |
|
| @@ 1196-1200 (lines=5) @@ | ||
| 1193 | } else if ($tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) { |
|
| 1194 | // Unless there is a variable or a bracket before this token, |
|
| 1195 | // it is the start of an array being defined using the short syntax. |
|
| 1196 | for ($x = ($i - 1); $x > 0; $x--) { |
|
| 1197 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) { |
|
| 1198 | break; |
|
| 1199 | } |
|
| 1200 | } |
|
| 1201 | ||
| 1202 | $allowed = array( |
|
| 1203 | T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, |
|
| @@ 1229-1233 (lines=5) @@ | ||
| 1226 | ||
| 1227 | continue; |
|
| 1228 | } else if ($tokens[$i]['code'] === T_STATIC) { |
|
| 1229 | for ($x = ($i - 1); $x > 0; $x--) { |
|
| 1230 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) { |
|
| 1231 | break; |
|
| 1232 | } |
|
| 1233 | } |
|
| 1234 | ||
| 1235 | if ($tokens[$x]['code'] === T_INSTANCEOF) { |
|
| 1236 | $tokens[$i]['code'] = T_STRING; |
|
| @@ 1259-1264 (lines=6) @@ | ||
| 1256 | || $tokens[$i]['code'] === T_FALSE |
|
| 1257 | || $tokens[$i]['code'] === T_NULL |
|
| 1258 | ) { |
|
| 1259 | for ($x = ($i + 1); $i < $numTokens; $x++) { |
|
| 1260 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) { |
|
| 1261 | // Non-whitespace content. |
|
| 1262 | break; |
|
| 1263 | } |
|
| 1264 | } |
|
| 1265 | ||
| 1266 | $context = array( |
|
| 1267 | T_OBJECT_OPERATOR => true, |
|
| @@ 1283-1288 (lines=6) @@ | ||
| 1280 | } |
|
| 1281 | } else if ($tokens[$i]['code'] === T_CONST) { |
|
| 1282 | // Context sensitive keywords support. |
|
| 1283 | for ($x = ($i + 1); $i < $numTokens; $x++) { |
|
| 1284 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) { |
|
| 1285 | // Non-whitespace content. |
|
| 1286 | break; |
|
| 1287 | } |
|
| 1288 | } |
|
| 1289 | ||
| 1290 | if ($tokens[$x]['code'] !== T_STRING) { |
|
| 1291 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
|
| @@ 1317-1322 (lines=6) @@ | ||
| 1314 | // and that brace has been ignored, it is actually |
|
| 1315 | // opening this case statement and the opener and closer are |
|
| 1316 | // probably set incorrectly. |
|
| 1317 | for ($x = ($scopeOpener + 1); $x < $numTokens; $x++) { |
|
| 1318 | if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) { |
|
| 1319 | // Non-whitespace content. |
|
| 1320 | break; |
|
| 1321 | } |
|
| 1322 | } |
|
| 1323 | ||
| 1324 | if ($tokens[$x]['code'] === T_CASE || $tokens[$x]['code'] === T_DEFAULT) { |
|
| 1325 | // Special case for multiple CASE statements that share the same |
|