@@ -24,8 +24,7 @@ discard block |
||
| 24 | 24 | * @author Wim Godden <[email protected]> |
| 25 | 25 | * @copyright 2014 Cu.be Solutions bvba |
| 26 | 26 | */ |
| 27 | -abstract class Sniff implements PHPCS_Sniff |
|
| 28 | -{ |
|
| 27 | +abstract class Sniff implements PHPCS_Sniff { |
|
| 29 | 28 | |
| 30 | 29 | const REGEX_COMPLEX_VARS = '`(?:(\{)?(?<!\\\\)\$)?(\{)?(?<!\\\\)\$(\{)?(?P<varname>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(?:->\$?(?P>varname)|\[[^\]]+\]|::\$?(?P>varname)|\([^\)]*\))*(?(3)\}|)(?(2)\}|)(?(1)\}|)`'; |
| 31 | 30 | |
@@ -105,8 +104,7 @@ discard block |
||
| 105 | 104 | * |
| 106 | 105 | * @throws \PHP_CodeSniffer_Exception If testVersion is invalid. |
| 107 | 106 | */ |
| 108 | - private function getTestVersion() |
|
| 109 | - { |
|
| 107 | + private function getTestVersion() { |
|
| 110 | 108 | static $arrTestVersions = array(); |
| 111 | 109 | |
| 112 | 110 | $default = array(null, null); |
@@ -173,8 +171,7 @@ discard block |
||
| 173 | 171 | * is equal to or higher than the highest supported PHP version |
| 174 | 172 | * in testVersion. False otherwise. |
| 175 | 173 | */ |
| 176 | - public function supportsAbove($phpVersion) |
|
| 177 | - { |
|
| 174 | + public function supportsAbove($phpVersion) { |
|
| 178 | 175 | $testVersion = $this->getTestVersion(); |
| 179 | 176 | $testVersion = $testVersion[1]; |
| 180 | 177 | |
@@ -200,8 +197,7 @@ discard block |
||
| 200 | 197 | * supported PHP version in testVersion. |
| 201 | 198 | * False otherwise or if no testVersion is provided. |
| 202 | 199 | */ |
| 203 | - public function supportsBelow($phpVersion) |
|
| 204 | - { |
|
| 200 | + public function supportsBelow($phpVersion) { |
|
| 205 | 201 | $testVersion = $this->getTestVersion(); |
| 206 | 202 | $testVersion = $testVersion[0]; |
| 207 | 203 | |
@@ -231,8 +227,7 @@ discard block |
||
| 231 | 227 | * |
| 232 | 228 | * @return void |
| 233 | 229 | */ |
| 234 | - public function addMessage(File $phpcsFile, $message, $stackPtr, $isError, $code = 'Found', $data = array()) |
|
| 235 | - { |
|
| 230 | + public function addMessage(File $phpcsFile, $message, $stackPtr, $isError, $code = 'Found', $data = array()) { |
|
| 236 | 231 | if ($isError === true) { |
| 237 | 232 | $phpcsFile->addError($message, $stackPtr, $code, $data); |
| 238 | 233 | } else { |
@@ -250,8 +245,7 @@ discard block |
||
| 250 | 245 | * |
| 251 | 246 | * @return string |
| 252 | 247 | */ |
| 253 | - public function stringToErrorCode($baseString) |
|
| 254 | - { |
|
| 248 | + public function stringToErrorCode($baseString) { |
|
| 255 | 249 | return preg_replace('`[^a-z0-9_]`i', '_', strtolower($baseString)); |
| 256 | 250 | } |
| 257 | 251 | |
@@ -265,8 +259,7 @@ discard block |
||
| 265 | 259 | * |
| 266 | 260 | * @return string String without quotes around it. |
| 267 | 261 | */ |
| 268 | - public function stripQuotes($string) |
|
| 269 | - { |
|
| 262 | + public function stripQuotes($string) { |
|
| 270 | 263 | return preg_replace('`^([\'"])(.*)\1$`Ds', '$2', $string); |
| 271 | 264 | } |
| 272 | 265 | |
@@ -280,8 +273,7 @@ discard block |
||
| 280 | 273 | * |
| 281 | 274 | * @return string String without variables in it. |
| 282 | 275 | */ |
| 283 | - public function stripVariables($string) |
|
| 284 | - { |
|
| 276 | + public function stripVariables($string) { |
|
| 285 | 277 | if (strpos($string, '$') === false) { |
| 286 | 278 | return $string; |
| 287 | 279 | } |
@@ -297,8 +289,7 @@ discard block |
||
| 297 | 289 | * |
| 298 | 290 | * @return array Same array, but with all lowercase top level keys. |
| 299 | 291 | */ |
| 300 | - public function arrayKeysToLowercase($array) |
|
| 301 | - { |
|
| 292 | + public function arrayKeysToLowercase($array) { |
|
| 302 | 293 | return array_change_key_case($array, \CASE_LOWER); |
| 303 | 294 | } |
| 304 | 295 | |
@@ -320,8 +311,7 @@ discard block |
||
| 320 | 311 | * |
| 321 | 312 | * @return bool |
| 322 | 313 | */ |
| 323 | - public function doesFunctionCallHaveParameters(File $phpcsFile, $stackPtr) |
|
| 324 | - { |
|
| 314 | + public function doesFunctionCallHaveParameters(File $phpcsFile, $stackPtr) { |
|
| 325 | 315 | $tokens = $phpcsFile->getTokens(); |
| 326 | 316 | |
| 327 | 317 | // Check for the existence of the token. |
@@ -390,8 +380,7 @@ discard block |
||
| 390 | 380 | * |
| 391 | 381 | * @return int |
| 392 | 382 | */ |
| 393 | - public function getFunctionCallParameterCount(File $phpcsFile, $stackPtr) |
|
| 394 | - { |
|
| 383 | + public function getFunctionCallParameterCount(File $phpcsFile, $stackPtr) { |
|
| 395 | 384 | if ($this->doesFunctionCallHaveParameters($phpcsFile, $stackPtr) === false) { |
| 396 | 385 | return 0; |
| 397 | 386 | } |
@@ -418,8 +407,7 @@ discard block |
||
| 418 | 407 | * |
| 419 | 408 | * @return array |
| 420 | 409 | */ |
| 421 | - public function getFunctionCallParameters(File $phpcsFile, $stackPtr) |
|
| 422 | - { |
|
| 410 | + public function getFunctionCallParameters(File $phpcsFile, $stackPtr) { |
|
| 423 | 411 | if ($this->doesFunctionCallHaveParameters($phpcsFile, $stackPtr) === false) { |
| 424 | 412 | return array(); |
| 425 | 413 | } |
@@ -525,8 +513,7 @@ discard block |
||
| 525 | 513 | * |
| 526 | 514 | * @return array|false |
| 527 | 515 | */ |
| 528 | - public function getFunctionCallParameter(File $phpcsFile, $stackPtr, $paramOffset) |
|
| 529 | - { |
|
| 516 | + public function getFunctionCallParameter(File $phpcsFile, $stackPtr, $paramOffset) { |
|
| 530 | 517 | $parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr); |
| 531 | 518 | |
| 532 | 519 | if (isset($parameters[$paramOffset]) === false) { |
@@ -555,8 +542,7 @@ discard block |
||
| 555 | 542 | * If the $scopeTypes are set: True if *one* of the conditions is a |
| 556 | 543 | * valid scope, false otherwise. |
| 557 | 544 | */ |
| 558 | - public function tokenHasScope(File $phpcsFile, $stackPtr, $validScopes = null) |
|
| 559 | - { |
|
| 545 | + public function tokenHasScope(File $phpcsFile, $stackPtr, $validScopes = null) { |
|
| 560 | 546 | $tokens = $phpcsFile->getTokens(); |
| 561 | 547 | |
| 562 | 548 | // Check for the existence of the token. |
@@ -589,8 +575,7 @@ discard block |
||
| 589 | 575 | * |
| 590 | 576 | * @return bool True if within class scope, false otherwise. |
| 591 | 577 | */ |
| 592 | - public function inClassScope(File $phpcsFile, $stackPtr, $strict = true) |
|
| 593 | - { |
|
| 578 | + public function inClassScope(File $phpcsFile, $stackPtr, $strict = true) { |
|
| 594 | 579 | $validScopes = array(\T_CLASS); |
| 595 | 580 | if (\defined('T_ANON_CLASS') === true) { |
| 596 | 581 | $validScopes[] = \T_ANON_CLASS; |
@@ -615,8 +600,7 @@ discard block |
||
| 615 | 600 | * |
| 616 | 601 | * @return string |
| 617 | 602 | */ |
| 618 | - public function getFQClassNameFromNewToken(File $phpcsFile, $stackPtr) |
|
| 619 | - { |
|
| 603 | + public function getFQClassNameFromNewToken(File $phpcsFile, $stackPtr) { |
|
| 620 | 604 | $tokens = $phpcsFile->getTokens(); |
| 621 | 605 | |
| 622 | 606 | // Check for the existence of the token. |
@@ -669,8 +653,7 @@ discard block |
||
| 669 | 653 | * |
| 670 | 654 | * @return string |
| 671 | 655 | */ |
| 672 | - public function getFQExtendedClassName(File $phpcsFile, $stackPtr) |
|
| 673 | - { |
|
| 656 | + public function getFQExtendedClassName(File $phpcsFile, $stackPtr) { |
|
| 674 | 657 | $tokens = $phpcsFile->getTokens(); |
| 675 | 658 | |
| 676 | 659 | // Check for the existence of the token. |
@@ -705,8 +688,7 @@ discard block |
||
| 705 | 688 | * |
| 706 | 689 | * @return string |
| 707 | 690 | */ |
| 708 | - public function getFQClassNameFromDoubleColonToken(File $phpcsFile, $stackPtr) |
|
| 709 | - { |
|
| 691 | + public function getFQClassNameFromDoubleColonToken(File $phpcsFile, $stackPtr) { |
|
| 710 | 692 | $tokens = $phpcsFile->getTokens(); |
| 711 | 693 | |
| 712 | 694 | // Check for the existence of the token. |
@@ -770,8 +752,7 @@ discard block |
||
| 770 | 752 | * |
| 771 | 753 | * @return string |
| 772 | 754 | */ |
| 773 | - public function getFQName(File $phpcsFile, $stackPtr, $name) |
|
| 774 | - { |
|
| 755 | + public function getFQName(File $phpcsFile, $stackPtr, $name) { |
|
| 775 | 756 | if (strpos($name, '\\') === 0) { |
| 776 | 757 | // Already fully qualified. |
| 777 | 758 | return $name; |
@@ -800,8 +781,7 @@ discard block |
||
| 800 | 781 | * |
| 801 | 782 | * @return bool True if namespaced, false if global. |
| 802 | 783 | */ |
| 803 | - public function isNamespaced($FQName) |
|
| 804 | - { |
|
| 784 | + public function isNamespaced($FQName) { |
|
| 805 | 785 | if (strpos($FQName, '\\') !== 0) { |
| 806 | 786 | throw new PHPCS_Exception('$FQName must be a fully qualified name'); |
| 807 | 787 | } |
@@ -818,8 +798,7 @@ discard block |
||
| 818 | 798 | * |
| 819 | 799 | * @return string Namespace name or empty string if it couldn't be determined or no namespace applies. |
| 820 | 800 | */ |
| 821 | - public function determineNamespace(File $phpcsFile, $stackPtr) |
|
| 822 | - { |
|
| 801 | + public function determineNamespace(File $phpcsFile, $stackPtr) { |
|
| 823 | 802 | $tokens = $phpcsFile->getTokens(); |
| 824 | 803 | |
| 825 | 804 | // Check for the existence of the token. |
@@ -882,8 +861,7 @@ discard block |
||
| 882 | 861 | * @return string|false Namespace name or false if not a namespace declaration. |
| 883 | 862 | * Namespace name can be an empty string for global namespace declaration. |
| 884 | 863 | */ |
| 885 | - public function getDeclaredNamespaceName(File $phpcsFile, $stackPtr) |
|
| 886 | - { |
|
| 864 | + public function getDeclaredNamespaceName(File $phpcsFile, $stackPtr) { |
|
| 887 | 865 | $tokens = $phpcsFile->getTokens(); |
| 888 | 866 | |
| 889 | 867 | // Check for the existence of the token. |
@@ -939,8 +917,7 @@ discard block |
||
| 939 | 917 | * no return type was found or the passed token was |
| 940 | 918 | * not of the correct type. |
| 941 | 919 | */ |
| 942 | - public function getReturnTypeHintToken(File $phpcsFile, $stackPtr) |
|
| 943 | - { |
|
| 920 | + public function getReturnTypeHintToken(File $phpcsFile, $stackPtr) { |
|
| 944 | 921 | $tokens = $phpcsFile->getTokens(); |
| 945 | 922 | |
| 946 | 923 | if (\defined('T_RETURN_TYPE') && $tokens[$stackPtr]['code'] === \T_RETURN_TYPE) { |
@@ -1018,8 +995,7 @@ discard block |
||
| 1018 | 995 | * |
| 1019 | 996 | * @return string|false The name of the return type token. |
| 1020 | 997 | */ |
| 1021 | - public function getReturnTypeHintName(File $phpcsFile, $stackPtr) |
|
| 1022 | - { |
|
| 998 | + public function getReturnTypeHintName(File $phpcsFile, $stackPtr) { |
|
| 1023 | 999 | $tokens = $phpcsFile->getTokens(); |
| 1024 | 1000 | |
| 1025 | 1001 | // In older PHPCS versions, the nullable indicator will turn a return type colon into a T_INLINE_ELSE. |
@@ -1069,8 +1045,7 @@ discard block |
||
| 1069 | 1045 | * |
| 1070 | 1046 | * @return bool |
| 1071 | 1047 | */ |
| 1072 | - public function isClassProperty(File $phpcsFile, $stackPtr) |
|
| 1073 | - { |
|
| 1048 | + public function isClassProperty(File $phpcsFile, $stackPtr) { |
|
| 1074 | 1049 | $tokens = $phpcsFile->getTokens(); |
| 1075 | 1050 | |
| 1076 | 1051 | if (isset($tokens[$stackPtr]) === false || $tokens[$stackPtr]['code'] !== \T_VARIABLE) { |
@@ -1114,8 +1089,7 @@ discard block |
||
| 1114 | 1089 | * |
| 1115 | 1090 | * @return bool |
| 1116 | 1091 | */ |
| 1117 | - public function isClassConstant(File $phpcsFile, $stackPtr) |
|
| 1118 | - { |
|
| 1092 | + public function isClassConstant(File $phpcsFile, $stackPtr) { |
|
| 1119 | 1093 | $tokens = $phpcsFile->getTokens(); |
| 1120 | 1094 | |
| 1121 | 1095 | if (isset($tokens[$stackPtr]) === false || $tokens[$stackPtr]['code'] !== \T_CONST) { |
@@ -1152,8 +1126,7 @@ discard block |
||
| 1152 | 1126 | * |
| 1153 | 1127 | * @return int|bool StackPtr to the scope if valid, false otherwise. |
| 1154 | 1128 | */ |
| 1155 | - protected function validDirectScope(File $phpcsFile, $stackPtr, $validScopes) |
|
| 1156 | - { |
|
| 1129 | + protected function validDirectScope(File $phpcsFile, $stackPtr, $validScopes) { |
|
| 1157 | 1130 | $tokens = $phpcsFile->getTokens(); |
| 1158 | 1131 | |
| 1159 | 1132 | if (empty($tokens[$stackPtr]['conditions']) === true) { |
@@ -1194,8 +1167,7 @@ discard block |
||
| 1194 | 1167 | * - no type hints were found |
| 1195 | 1168 | * - or the passed token was not of the correct type. |
| 1196 | 1169 | */ |
| 1197 | - public function getTypeHintsFromFunctionDeclaration(File $phpcsFile, $stackPtr) |
|
| 1198 | - { |
|
| 1170 | + public function getTypeHintsFromFunctionDeclaration(File $phpcsFile, $stackPtr) { |
|
| 1199 | 1171 | $tokens = $phpcsFile->getTokens(); |
| 1200 | 1172 | |
| 1201 | 1173 | if ($tokens[$stackPtr]['code'] !== \T_FUNCTION && $tokens[$stackPtr]['code'] !== \T_CLOSURE) { |
@@ -1238,8 +1210,7 @@ discard block |
||
| 1238 | 1210 | * @return string|false The algorithm name without quotes if this was a relevant hash |
| 1239 | 1211 | * function call or false if it was not. |
| 1240 | 1212 | */ |
| 1241 | - public function getHashAlgorithmParameter(File $phpcsFile, $stackPtr) |
|
| 1242 | - { |
|
| 1213 | + public function getHashAlgorithmParameter(File $phpcsFile, $stackPtr) { |
|
| 1243 | 1214 | $tokens = $phpcsFile->getTokens(); |
| 1244 | 1215 | |
| 1245 | 1216 | // Check for the existence of the token. |
@@ -1281,8 +1252,7 @@ discard block |
||
| 1281 | 1252 | * |
| 1282 | 1253 | * @return bool |
| 1283 | 1254 | */ |
| 1284 | - public function isUseOfGlobalConstant(File $phpcsFile, $stackPtr) |
|
| 1285 | - { |
|
| 1255 | + public function isUseOfGlobalConstant(File $phpcsFile, $stackPtr) { |
|
| 1286 | 1256 | static $isLowPHPCS, $isLowPHP; |
| 1287 | 1257 | |
| 1288 | 1258 | $tokens = $phpcsFile->getTokens(); |
@@ -1419,8 +1389,7 @@ discard block |
||
| 1419 | 1389 | * False if not or if it could not be reliably determined |
| 1420 | 1390 | * (variable or calculations and such). |
| 1421 | 1391 | */ |
| 1422 | - public function isPositiveNumber(File $phpcsFile, $start, $end, $allowFloats = false) |
|
| 1423 | - { |
|
| 1392 | + public function isPositiveNumber(File $phpcsFile, $start, $end, $allowFloats = false) { |
|
| 1424 | 1393 | $number = $this->isNumber($phpcsFile, $start, $end, $allowFloats); |
| 1425 | 1394 | |
| 1426 | 1395 | if ($number === false) { |
@@ -1451,8 +1420,7 @@ discard block |
||
| 1451 | 1420 | * False if not or if it could not be reliably determined |
| 1452 | 1421 | * (variable or calculations and such). |
| 1453 | 1422 | */ |
| 1454 | - public function isNegativeNumber(File $phpcsFile, $start, $end, $allowFloats = false) |
|
| 1455 | - { |
|
| 1423 | + public function isNegativeNumber(File $phpcsFile, $start, $end, $allowFloats = false) { |
|
| 1456 | 1424 | $number = $this->isNumber($phpcsFile, $start, $end, $allowFloats); |
| 1457 | 1425 | |
| 1458 | 1426 | if ($number === false) { |
@@ -1488,8 +1456,7 @@ discard block |
||
| 1488 | 1456 | * number or if it could not be reliably determined |
| 1489 | 1457 | * (variable or calculations and such). |
| 1490 | 1458 | */ |
| 1491 | - protected function isNumber(File $phpcsFile, $start, $end, $allowFloats = false) |
|
| 1492 | - { |
|
| 1459 | + protected function isNumber(File $phpcsFile, $start, $end, $allowFloats = false) { |
|
| 1493 | 1460 | $stringTokens = Tokens::$heredocTokens + Tokens::$stringTokens; |
| 1494 | 1461 | |
| 1495 | 1462 | $validTokens = array(); |
@@ -1656,8 +1623,7 @@ discard block |
||
| 1656 | 1623 | * |
| 1657 | 1624 | * @return bool |
| 1658 | 1625 | */ |
| 1659 | - protected function isNumericCalculation(File $phpcsFile, $start, $end) |
|
| 1660 | - { |
|
| 1626 | + protected function isNumericCalculation(File $phpcsFile, $start, $end) { |
|
| 1661 | 1627 | $arithmeticTokens = Tokens::$arithmeticTokens; |
| 1662 | 1628 | |
| 1663 | 1629 | // phpcs:disable PHPCompatibility.Constants.NewConstants.t_powFound |
@@ -1741,8 +1707,7 @@ discard block |
||
| 1741 | 1707 | * |
| 1742 | 1708 | * @return bool True if short ternary, or false otherwise. |
| 1743 | 1709 | */ |
| 1744 | - public function isShortTernary(File $phpcsFile, $stackPtr) |
|
| 1745 | - { |
|
| 1710 | + public function isShortTernary(File $phpcsFile, $stackPtr) { |
|
| 1746 | 1711 | $tokens = $phpcsFile->getTokens(); |
| 1747 | 1712 | if (isset($tokens[$stackPtr]) === false |
| 1748 | 1713 | || $tokens[$stackPtr]['code'] !== \T_INLINE_THEN |
@@ -1775,8 +1740,7 @@ discard block |
||
| 1775 | 1740 | * |
| 1776 | 1741 | * @return bool |
| 1777 | 1742 | */ |
| 1778 | - public function isShortList(File $phpcsFile, $stackPtr) |
|
| 1779 | - { |
|
| 1743 | + public function isShortList(File $phpcsFile, $stackPtr) { |
|
| 1780 | 1744 | $tokens = $phpcsFile->getTokens(); |
| 1781 | 1745 | |
| 1782 | 1746 | // Check for the existence of the token. |
@@ -1922,8 +1886,7 @@ discard block |
||
| 1922 | 1886 | * |
| 1923 | 1887 | * @return bool |
| 1924 | 1888 | */ |
| 1925 | - public function isVariable(File $phpcsFile, $start, $end, $targetNestingLevel) |
|
| 1926 | - { |
|
| 1889 | + public function isVariable(File $phpcsFile, $start, $end, $targetNestingLevel) { |
|
| 1927 | 1890 | static $tokenBlackList, $bracketTokens; |
| 1928 | 1891 | |
| 1929 | 1892 | // Create the token arrays only once. |
@@ -2016,8 +1979,7 @@ discard block |
||
| 2016 | 1979 | * @return bool True if the token passed is a unary operator. |
| 2017 | 1980 | * False otherwise or if the token is not a T_PLUS/T_MINUS token. |
| 2018 | 1981 | */ |
| 2019 | - public static function isUnaryPlusMinus(File $phpcsFile, $stackPtr) |
|
| 2020 | - { |
|
| 1982 | + public static function isUnaryPlusMinus(File $phpcsFile, $stackPtr) { |
|
| 2021 | 1983 | $tokens = $phpcsFile->getTokens(); |
| 2022 | 1984 | |
| 2023 | 1985 | if (isset($tokens[$stackPtr]) === false |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | * @package PHPCompatibility |
| 19 | 19 | * @author Juliette Reinders Folmer <[email protected]> |
| 20 | 20 | */ |
| 21 | -abstract class AbstractComplexVersionSniff extends Sniff implements ComplexVersionInterface |
|
| 22 | -{ |
|
| 21 | +abstract class AbstractComplexVersionSniff extends Sniff implements ComplexVersionInterface { |
|
| 23 | 22 | |
| 24 | 23 | |
| 25 | 24 | /** |
@@ -33,8 +32,7 @@ discard block |
||
| 33 | 32 | * |
| 34 | 33 | * @return void |
| 35 | 34 | */ |
| 36 | - public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo) |
|
| 37 | - { |
|
| 35 | + public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo) { |
|
| 38 | 36 | $itemArray = $this->getItemArray($itemInfo); |
| 39 | 37 | $errorInfo = $this->getErrorInfo($itemArray, $itemInfo); |
| 40 | 38 | |
@@ -59,8 +57,7 @@ discard block |
||
| 59 | 57 | * |
| 60 | 58 | * @return array |
| 61 | 59 | */ |
| 62 | - protected function getNonVersionArrayKeys() |
|
| 63 | - { |
|
| 60 | + protected function getNonVersionArrayKeys() { |
|
| 64 | 61 | return array(); |
| 65 | 62 | } |
| 66 | 63 | |
@@ -73,8 +70,7 @@ discard block |
||
| 73 | 70 | * |
| 74 | 71 | * @return array Array with only the version information. |
| 75 | 72 | */ |
| 76 | - protected function getVersionArray(array $itemArray) |
|
| 77 | - { |
|
| 73 | + protected function getVersionArray(array $itemArray) { |
|
| 78 | 74 | return array_diff_key($itemArray, array_flip($this->getNonVersionArrayKeys())); |
| 79 | 75 | } |
| 80 | 76 | |
@@ -87,8 +83,7 @@ discard block |
||
| 87 | 83 | * |
| 88 | 84 | * @return string |
| 89 | 85 | */ |
| 90 | - protected function getItemName(array $itemInfo, array $errorInfo) |
|
| 91 | - { |
|
| 86 | + protected function getItemName(array $itemInfo, array $errorInfo) { |
|
| 92 | 87 | return $itemInfo['name']; |
| 93 | 88 | } |
| 94 | 89 | |
@@ -110,8 +105,7 @@ discard block |
||
| 110 | 105 | * |
| 111 | 106 | * @return string |
| 112 | 107 | */ |
| 113 | - protected function filterErrorMsg($error, array $itemInfo, array $errorInfo) |
|
| 114 | - { |
|
| 108 | + protected function filterErrorMsg($error, array $itemInfo, array $errorInfo) { |
|
| 115 | 109 | return $error; |
| 116 | 110 | } |
| 117 | 111 | |
@@ -125,8 +119,7 @@ discard block |
||
| 125 | 119 | * |
| 126 | 120 | * @return array |
| 127 | 121 | */ |
| 128 | - protected function filterErrorData(array $data, array $itemInfo, array $errorInfo) |
|
| 129 | - { |
|
| 122 | + protected function filterErrorData(array $data, array $itemInfo, array $errorInfo) { |
|
| 130 | 123 | return $data; |
| 131 | 124 | } |
| 132 | 125 | } |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | * @package PHPCompatibility |
| 19 | 19 | * @author Juliette Reinders Folmer <[email protected]> |
| 20 | 20 | */ |
| 21 | -abstract class AbstractNewFeatureSniff extends AbstractComplexVersionSniff |
|
| 22 | -{ |
|
| 21 | +abstract class AbstractNewFeatureSniff extends AbstractComplexVersionSniff { |
|
| 23 | 22 | |
| 24 | 23 | |
| 25 | 24 | /** |
@@ -29,8 +28,7 @@ discard block |
||
| 29 | 28 | * |
| 30 | 29 | * @return bool |
| 31 | 30 | */ |
| 32 | - protected function shouldThrowError(array $errorInfo) |
|
| 33 | - { |
|
| 31 | + protected function shouldThrowError(array $errorInfo) { |
|
| 34 | 32 | return ($errorInfo['not_in_version'] !== ''); |
| 35 | 33 | } |
| 36 | 34 | |
@@ -43,8 +41,7 @@ discard block |
||
| 43 | 41 | * |
| 44 | 42 | * @return array |
| 45 | 43 | */ |
| 46 | - public function getErrorInfo(array $itemArray, array $itemInfo) |
|
| 47 | - { |
|
| 44 | + public function getErrorInfo(array $itemArray, array $itemInfo) { |
|
| 48 | 45 | $errorInfo = array( |
| 49 | 46 | 'not_in_version' => '', |
| 50 | 47 | 'error' => true, |
@@ -71,8 +68,7 @@ discard block |
||
| 71 | 68 | * |
| 72 | 69 | * @return string |
| 73 | 70 | */ |
| 74 | - protected function getErrorMsgTemplate() |
|
| 75 | - { |
|
| 71 | + protected function getErrorMsgTemplate() { |
|
| 76 | 72 | return '%s is not present in PHP version %s or earlier'; |
| 77 | 73 | } |
| 78 | 74 | |
@@ -89,8 +85,7 @@ discard block |
||
| 89 | 85 | * |
| 90 | 86 | * @return void |
| 91 | 87 | */ |
| 92 | - public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo) |
|
| 93 | - { |
|
| 88 | + public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo) { |
|
| 94 | 89 | $itemName = $this->getItemName($itemInfo, $errorInfo); |
| 95 | 90 | $error = $this->getErrorMsgTemplate(); |
| 96 | 91 | |
@@ -22,8 +22,7 @@ |
||
| 22 | 22 | * @package PHPCompatibility |
| 23 | 23 | * @author Juliette Reinders Folmer <[email protected]> |
| 24 | 24 | */ |
| 25 | -interface ComplexVersionInterface |
|
| 26 | -{ |
|
| 25 | +interface ComplexVersionInterface { |
|
| 27 | 26 | |
| 28 | 27 | |
| 29 | 28 | /** |
@@ -30,8 +30,7 @@ discard block |
||
| 30 | 30 | * @package PHPCompatibility |
| 31 | 31 | * @author Juliette Reinders Folmer <[email protected]> |
| 32 | 32 | */ |
| 33 | -class NewConstantScalarExpressionsSniff extends Sniff |
|
| 34 | -{ |
|
| 33 | +class NewConstantScalarExpressionsSniff extends Sniff { |
|
| 35 | 34 | |
| 36 | 35 | /** |
| 37 | 36 | * Error message. |
@@ -91,8 +90,7 @@ discard block |
||
| 91 | 90 | * |
| 92 | 91 | * @return array |
| 93 | 92 | */ |
| 94 | - public function register() |
|
| 95 | - { |
|
| 93 | + public function register() { |
|
| 96 | 94 | // Set the properties up only once. |
| 97 | 95 | $this->setProperties(); |
| 98 | 96 | |
@@ -111,8 +109,7 @@ discard block |
||
| 111 | 109 | * |
| 112 | 110 | * @return void |
| 113 | 111 | */ |
| 114 | - public function setProperties() |
|
| 115 | - { |
|
| 112 | + public function setProperties() { |
|
| 116 | 113 | $this->safeOperands += Tokens::$heredocTokens; |
| 117 | 114 | $this->safeOperands += Tokens::$emptyTokens; |
| 118 | 115 | } |
@@ -123,8 +120,7 @@ discard block |
||
| 123 | 120 | * |
| 124 | 121 | * @return bool |
| 125 | 122 | */ |
| 126 | - protected function bowOutEarly() |
|
| 127 | - { |
|
| 123 | + protected function bowOutEarly() { |
|
| 128 | 124 | return ($this->supportsBelow('5.5') !== true); |
| 129 | 125 | } |
| 130 | 126 | |
@@ -138,8 +134,7 @@ discard block |
||
| 138 | 134 | * |
| 139 | 135 | * @return void|int Null or integer stack pointer to skip forward. |
| 140 | 136 | */ |
| 141 | - public function process(File $phpcsFile, $stackPtr) |
|
| 142 | - { |
|
| 137 | + public function process(File $phpcsFile, $stackPtr) { |
|
| 143 | 138 | if ($this->bowOutEarly() === true) { |
| 144 | 139 | return; |
| 145 | 140 | } |
@@ -304,8 +299,7 @@ discard block |
||
| 304 | 299 | * |
| 305 | 300 | * @return bool |
| 306 | 301 | */ |
| 307 | - protected function isValidAssignment(File $phpcsFile, $stackPtr, $end) |
|
| 308 | - { |
|
| 302 | + protected function isValidAssignment(File $phpcsFile, $stackPtr, $end) { |
|
| 309 | 303 | $tokens = $phpcsFile->getTokens(); |
| 310 | 304 | $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true); |
| 311 | 305 | if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) { |
@@ -331,8 +325,7 @@ discard block |
||
| 331 | 325 | * |
| 332 | 326 | * @return bool |
| 333 | 327 | */ |
| 334 | - protected function isStaticValue(File $phpcsFile, $tokens, $start, $end, $nestedArrays = 0) |
|
| 335 | - { |
|
| 328 | + protected function isStaticValue(File $phpcsFile, $tokens, $start, $end, $nestedArrays = 0) { |
|
| 336 | 329 | $nextNonSimple = $phpcsFile->findNext($this->safeOperands, $start, ($end + 1), true); |
| 337 | 330 | if ($nextNonSimple === false) { |
| 338 | 331 | return true; |
@@ -471,8 +464,7 @@ discard block |
||
| 471 | 464 | * |
| 472 | 465 | * @return void |
| 473 | 466 | */ |
| 474 | - protected function throwError(File $phpcsFile, $stackPtr, $type, $content = '') |
|
| 475 | - { |
|
| 467 | + protected function throwError(File $phpcsFile, $stackPtr, $type, $content = '') { |
|
| 476 | 468 | $error = static::ERROR_PHRASE; |
| 477 | 469 | $phrase = ''; |
| 478 | 470 | $errorCode = 'Found'; |
@@ -505,8 +497,7 @@ discard block |
||
| 505 | 497 | * |
| 506 | 498 | * @return bool|int True if this is the real end. Int stackPtr to skip to if not. |
| 507 | 499 | */ |
| 508 | - private function isRealEndOfDeclaration($tokens, $endPtr, $targetLevel) |
|
| 509 | - { |
|
| 500 | + private function isRealEndOfDeclaration($tokens, $endPtr, $targetLevel) { |
|
| 510 | 501 | // Ignore anything within short array definition brackets for now. |
| 511 | 502 | if ($tokens[$endPtr]['code'] === \T_OPEN_SHORT_ARRAY |
| 512 | 503 | && (isset($tokens[$endPtr]['bracket_opener']) |
@@ -25,16 +25,14 @@ discard block |
||
| 25 | 25 | * @package PHPCompatibility |
| 26 | 26 | * @author Juliette Reinders Folmer <[email protected]> |
| 27 | 27 | */ |
| 28 | -class NewConstantArraysUsingConstSniff extends Sniff |
|
| 29 | -{ |
|
| 28 | +class NewConstantArraysUsingConstSniff extends Sniff { |
|
| 30 | 29 | |
| 31 | 30 | /** |
| 32 | 31 | * Returns an array of tokens this test wants to listen for. |
| 33 | 32 | * |
| 34 | 33 | * @return array |
| 35 | 34 | */ |
| 36 | - public function register() |
|
| 37 | - { |
|
| 35 | + public function register() { |
|
| 38 | 36 | return array(\T_CONST); |
| 39 | 37 | } |
| 40 | 38 | |
@@ -47,8 +45,7 @@ discard block |
||
| 47 | 45 | * |
| 48 | 46 | * @return void |
| 49 | 47 | */ |
| 50 | - public function process(File $phpcsFile, $stackPtr) |
|
| 51 | - { |
|
| 48 | + public function process(File $phpcsFile, $stackPtr) { |
|
| 52 | 49 | if ($this->supportsBelow('5.5') !== true) { |
| 53 | 50 | return; |
| 54 | 51 | } |
@@ -25,16 +25,14 @@ discard block |
||
| 25 | 25 | * @package PHPCompatibility |
| 26 | 26 | * @author Wim Godden <[email protected]> |
| 27 | 27 | */ |
| 28 | -class NewConstantArraysUsingDefineSniff extends Sniff |
|
| 29 | -{ |
|
| 28 | +class NewConstantArraysUsingDefineSniff extends Sniff { |
|
| 30 | 29 | |
| 31 | 30 | /** |
| 32 | 31 | * Returns an array of tokens this test wants to listen for. |
| 33 | 32 | * |
| 34 | 33 | * @return array |
| 35 | 34 | */ |
| 36 | - public function register() |
|
| 37 | - { |
|
| 35 | + public function register() { |
|
| 38 | 36 | return array(\T_STRING); |
| 39 | 37 | } |
| 40 | 38 | |
@@ -47,8 +45,7 @@ discard block |
||
| 47 | 45 | * |
| 48 | 46 | * @return void |
| 49 | 47 | */ |
| 50 | - public function process(File $phpcsFile, $stackPtr) |
|
| 51 | - { |
|
| 48 | + public function process(File $phpcsFile, $stackPtr) { |
|
| 52 | 49 | if ($this->supportsBelow('5.6') !== true) { |
| 53 | 50 | return; |
| 54 | 51 | } |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | * @package PHPCompatibility |
| 33 | 33 | * @author Juliette Reinders Folmer <[email protected]> |
| 34 | 34 | */ |
| 35 | -class NewHeredocSniff extends NewConstantScalarExpressionsSniff |
|
| 36 | -{ |
|
| 35 | +class NewHeredocSniff extends NewConstantScalarExpressionsSniff { |
|
| 37 | 36 | |
| 38 | 37 | /** |
| 39 | 38 | * Error message. |
@@ -60,8 +59,7 @@ discard block |
||
| 60 | 59 | * |
| 61 | 60 | * @return bool |
| 62 | 61 | */ |
| 63 | - protected function bowOutEarly() |
|
| 64 | - { |
|
| 62 | + protected function bowOutEarly() { |
|
| 65 | 63 | return ($this->supportsBelow('5.2') !== true); |
| 66 | 64 | } |
| 67 | 65 | |
@@ -76,8 +74,7 @@ discard block |
||
| 76 | 74 | * |
| 77 | 75 | * @return bool True if no heredoc (or assignment) is found, false otherwise. |
| 78 | 76 | */ |
| 79 | - protected function isValidAssignment(File $phpcsFile, $stackPtr, $end) |
|
| 80 | - { |
|
| 77 | + protected function isValidAssignment(File $phpcsFile, $stackPtr, $end) { |
|
| 81 | 78 | $tokens = $phpcsFile->getTokens(); |
| 82 | 79 | $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), $end, true); |
| 83 | 80 | if ($next === false || $tokens[$next]['code'] !== \T_EQUAL) { |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @since 9.2.0 |
| 27 | 27 | */ |
| 28 | -class RemovedOrphanedParentSniff extends Sniff |
|
| 29 | -{ |
|
| 28 | +class RemovedOrphanedParentSniff extends Sniff { |
|
| 30 | 29 | |
| 31 | 30 | /** |
| 32 | 31 | * Class scopes to check the class declaration. |
@@ -47,8 +46,7 @@ discard block |
||
| 47 | 46 | * |
| 48 | 47 | * @return array |
| 49 | 48 | */ |
| 50 | - public function register() |
|
| 51 | - { |
|
| 49 | + public function register() { |
|
| 52 | 50 | return array(\T_PARENT); |
| 53 | 51 | } |
| 54 | 52 | |
@@ -63,8 +61,7 @@ discard block |
||
| 63 | 61 | * |
| 64 | 62 | * @return void |
| 65 | 63 | */ |
| 66 | - public function process(File $phpcsFile, $stackPtr) |
|
| 67 | - { |
|
| 64 | + public function process(File $phpcsFile, $stackPtr) { |
|
| 68 | 65 | if ($this->supportsAbove('7.4') === false) { |
| 69 | 66 | return; |
| 70 | 67 | } |