@@ -19,118 +19,118 @@ |
||
| 19 | 19 | { |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Returns an array of tokens this test wants to listen for. |
|
| 24 | - * |
|
| 25 | - * @return array |
|
| 26 | - */ |
|
| 27 | - public function register() |
|
| 28 | - { |
|
| 29 | - return [ |
|
| 30 | - T_INCLUDE_ONCE, |
|
| 31 | - T_REQUIRE_ONCE, |
|
| 32 | - T_REQUIRE, |
|
| 33 | - T_INCLUDE, |
|
| 34 | - ]; |
|
| 35 | - |
|
| 36 | - }//end register() |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Processes this test, when one of its tokens is encountered. |
|
| 41 | - * |
|
| 42 | - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
|
| 43 | - * @param int $stackPtr The position of the current token in the |
|
| 44 | - * stack passed in $tokens. |
|
| 45 | - * |
|
| 46 | - * @return void |
|
| 47 | - */ |
|
| 48 | - public function process(File $phpcsFile, $stackPtr) |
|
| 49 | - { |
|
| 50 | - $tokens = $phpcsFile->getTokens(); |
|
| 51 | - |
|
| 52 | - $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); |
|
| 53 | - if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) { |
|
| 54 | - $error = '"%s" is a statement not a function; no parentheses are required'; |
|
| 55 | - $data = [$tokens[$stackPtr]['content']]; |
|
| 56 | - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'BracketsNotRequired', $data); |
|
| 57 | - if ($fix === true) { |
|
| 58 | - $phpcsFile->fixer->beginChangeset(); |
|
| 59 | - $phpcsFile->fixer->replaceToken($tokens[$nextToken]['parenthesis_closer'], ''); |
|
| 60 | - if ($tokens[($nextToken - 1)]['code'] !== T_WHITESPACE) { |
|
| 61 | - $phpcsFile->fixer->replaceToken($nextToken, ' '); |
|
| 62 | - } else { |
|
| 63 | - $phpcsFile->fixer->replaceToken($nextToken, ''); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - $phpcsFile->fixer->endChangeset(); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if (count($tokens[$stackPtr]['conditions']) !== 0) { |
|
| 71 | - $inCondition = true; |
|
| 72 | - } else { |
|
| 73 | - $inCondition = false; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // Check to see if this including statement is within the parenthesis |
|
| 77 | - // of a condition. If that's the case then we need to process it as being |
|
| 78 | - // within a condition, as they are checking the return value. |
|
| 79 | - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { |
|
| 80 | - foreach ($tokens[$stackPtr]['nested_parenthesis'] as $left => $right) { |
|
| 81 | - if (isset($tokens[$left]['parenthesis_owner']) === true) { |
|
| 82 | - $inCondition = true; |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // Check to see if they are assigning the return value of this |
|
| 88 | - // including call. If they are then they are probably checking it, so |
|
| 89 | - // it's conditional. |
|
| 90 | - $previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); |
|
| 91 | - if (isset(Tokens::$assignmentTokens[$tokens[$previous]['code']]) === true) { |
|
| 92 | - // The have assigned the return value to it, so its conditional. |
|
| 93 | - $inCondition = true; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $tokenCode = $tokens[$stackPtr]['code']; |
|
| 97 | - if ($inCondition === true) { |
|
| 98 | - // We are inside a conditional statement. We need an include_once. |
|
| 99 | - if ($tokenCode === T_REQUIRE_ONCE) { |
|
| 100 | - $error = 'File is being conditionally included; '; |
|
| 101 | - $error .= 'use "include_once" instead'; |
|
| 102 | - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseIncludeOnce'); |
|
| 103 | - if ($fix === true) { |
|
| 104 | - $phpcsFile->fixer->replaceToken($stackPtr, 'include_once'); |
|
| 105 | - } |
|
| 106 | - } else if ($tokenCode === T_REQUIRE) { |
|
| 107 | - $error = 'File is being conditionally included; '; |
|
| 108 | - $error .= 'use "include" instead'; |
|
| 109 | - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseInclude'); |
|
| 110 | - if ($fix === true) { |
|
| 111 | - $phpcsFile->fixer->replaceToken($stackPtr, 'include'); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } else { |
|
| 115 | - // We are unconditionally including, we need a require_once. |
|
| 116 | - if ($tokenCode === T_INCLUDE_ONCE) { |
|
| 117 | - $error = 'File is being unconditionally included; '; |
|
| 118 | - $error .= 'use "require_once" instead'; |
|
| 119 | - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseRequireOnce'); |
|
| 120 | - if ($fix === true) { |
|
| 121 | - $phpcsFile->fixer->replaceToken($stackPtr, 'require_once'); |
|
| 122 | - } |
|
| 123 | - } else if ($tokenCode === T_INCLUDE) { |
|
| 124 | - $error = 'File is being unconditionally included; '; |
|
| 125 | - $error .= 'use "require" instead'; |
|
| 126 | - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseRequire'); |
|
| 127 | - if ($fix === true) { |
|
| 128 | - $phpcsFile->fixer->replaceToken($stackPtr, 'require'); |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - }//end if |
|
| 132 | - |
|
| 133 | - }//end process() |
|
| 22 | + /** |
|
| 23 | + * Returns an array of tokens this test wants to listen for. |
|
| 24 | + * |
|
| 25 | + * @return array |
|
| 26 | + */ |
|
| 27 | + public function register() |
|
| 28 | + { |
|
| 29 | + return [ |
|
| 30 | + T_INCLUDE_ONCE, |
|
| 31 | + T_REQUIRE_ONCE, |
|
| 32 | + T_REQUIRE, |
|
| 33 | + T_INCLUDE, |
|
| 34 | + ]; |
|
| 35 | + |
|
| 36 | + }//end register() |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Processes this test, when one of its tokens is encountered. |
|
| 41 | + * |
|
| 42 | + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
|
| 43 | + * @param int $stackPtr The position of the current token in the |
|
| 44 | + * stack passed in $tokens. |
|
| 45 | + * |
|
| 46 | + * @return void |
|
| 47 | + */ |
|
| 48 | + public function process(File $phpcsFile, $stackPtr) |
|
| 49 | + { |
|
| 50 | + $tokens = $phpcsFile->getTokens(); |
|
| 51 | + |
|
| 52 | + $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); |
|
| 53 | + if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS) { |
|
| 54 | + $error = '"%s" is a statement not a function; no parentheses are required'; |
|
| 55 | + $data = [$tokens[$stackPtr]['content']]; |
|
| 56 | + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'BracketsNotRequired', $data); |
|
| 57 | + if ($fix === true) { |
|
| 58 | + $phpcsFile->fixer->beginChangeset(); |
|
| 59 | + $phpcsFile->fixer->replaceToken($tokens[$nextToken]['parenthesis_closer'], ''); |
|
| 60 | + if ($tokens[($nextToken - 1)]['code'] !== T_WHITESPACE) { |
|
| 61 | + $phpcsFile->fixer->replaceToken($nextToken, ' '); |
|
| 62 | + } else { |
|
| 63 | + $phpcsFile->fixer->replaceToken($nextToken, ''); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + $phpcsFile->fixer->endChangeset(); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if (count($tokens[$stackPtr]['conditions']) !== 0) { |
|
| 71 | + $inCondition = true; |
|
| 72 | + } else { |
|
| 73 | + $inCondition = false; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // Check to see if this including statement is within the parenthesis |
|
| 77 | + // of a condition. If that's the case then we need to process it as being |
|
| 78 | + // within a condition, as they are checking the return value. |
|
| 79 | + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { |
|
| 80 | + foreach ($tokens[$stackPtr]['nested_parenthesis'] as $left => $right) { |
|
| 81 | + if (isset($tokens[$left]['parenthesis_owner']) === true) { |
|
| 82 | + $inCondition = true; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // Check to see if they are assigning the return value of this |
|
| 88 | + // including call. If they are then they are probably checking it, so |
|
| 89 | + // it's conditional. |
|
| 90 | + $previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); |
|
| 91 | + if (isset(Tokens::$assignmentTokens[$tokens[$previous]['code']]) === true) { |
|
| 92 | + // The have assigned the return value to it, so its conditional. |
|
| 93 | + $inCondition = true; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $tokenCode = $tokens[$stackPtr]['code']; |
|
| 97 | + if ($inCondition === true) { |
|
| 98 | + // We are inside a conditional statement. We need an include_once. |
|
| 99 | + if ($tokenCode === T_REQUIRE_ONCE) { |
|
| 100 | + $error = 'File is being conditionally included; '; |
|
| 101 | + $error .= 'use "include_once" instead'; |
|
| 102 | + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseIncludeOnce'); |
|
| 103 | + if ($fix === true) { |
|
| 104 | + $phpcsFile->fixer->replaceToken($stackPtr, 'include_once'); |
|
| 105 | + } |
|
| 106 | + } else if ($tokenCode === T_REQUIRE) { |
|
| 107 | + $error = 'File is being conditionally included; '; |
|
| 108 | + $error .= 'use "include" instead'; |
|
| 109 | + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseInclude'); |
|
| 110 | + if ($fix === true) { |
|
| 111 | + $phpcsFile->fixer->replaceToken($stackPtr, 'include'); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } else { |
|
| 115 | + // We are unconditionally including, we need a require_once. |
|
| 116 | + if ($tokenCode === T_INCLUDE_ONCE) { |
|
| 117 | + $error = 'File is being unconditionally included; '; |
|
| 118 | + $error .= 'use "require_once" instead'; |
|
| 119 | + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseRequireOnce'); |
|
| 120 | + if ($fix === true) { |
|
| 121 | + $phpcsFile->fixer->replaceToken($stackPtr, 'require_once'); |
|
| 122 | + } |
|
| 123 | + } else if ($tokenCode === T_INCLUDE) { |
|
| 124 | + $error = 'File is being unconditionally included; '; |
|
| 125 | + $error .= 'use "require" instead'; |
|
| 126 | + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'UseRequire'); |
|
| 127 | + if ($fix === true) { |
|
| 128 | + $phpcsFile->fixer->replaceToken($stackPtr, 'require'); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + }//end if |
|
| 132 | + |
|
| 133 | + }//end process() |
|
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | }//end class |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | $tokens[$stackPtr]['content'], |
| 82 | 82 | ($braceLine - $classLine - 1), |
| 83 | 83 | ]; |
| 84 | - $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceWrongLine', $data); |
|
| 84 | + $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceWrongLine', $data); |
|
| 85 | 85 | if ($fix === true) { |
| 86 | 86 | $phpcsFile->fixer->beginChangeset(); |
| 87 | 87 | for ($i = ($curlyBrace - 1); $i > $lastContent; $i--) { |
@@ -16,135 +16,135 @@ |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Returns an array of tokens this test wants to listen for. |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function register() |
|
| 25 | - { |
|
| 26 | - return [ |
|
| 27 | - T_CLASS, |
|
| 28 | - T_INTERFACE, |
|
| 29 | - T_TRAIT, |
|
| 30 | - T_ENUM, |
|
| 31 | - ]; |
|
| 32 | - |
|
| 33 | - }//end register() |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Processes this test, when one of its tokens is encountered. |
|
| 38 | - * |
|
| 39 | - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
|
| 40 | - * @param integer $stackPtr The position of the current token in the |
|
| 41 | - * stack passed in $tokens. |
|
| 42 | - * |
|
| 43 | - * @return void |
|
| 44 | - */ |
|
| 45 | - public function process(File $phpcsFile, $stackPtr) |
|
| 46 | - { |
|
| 47 | - $tokens = $phpcsFile->getTokens(); |
|
| 48 | - $errorData = [strtolower($tokens[$stackPtr]['content'])]; |
|
| 49 | - |
|
| 50 | - if (isset($tokens[$stackPtr]['scope_opener']) === false) { |
|
| 51 | - $error = 'Possible parse error: %s missing opening or closing brace'; |
|
| 52 | - $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $errorData); |
|
| 53 | - return; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - $curlyBrace = $tokens[$stackPtr]['scope_opener']; |
|
| 57 | - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($curlyBrace - 1), $stackPtr, true); |
|
| 58 | - $classLine = $tokens[$lastContent]['line']; |
|
| 59 | - $braceLine = $tokens[$curlyBrace]['line']; |
|
| 60 | - if ($braceLine === $classLine) { |
|
| 61 | - $phpcsFile->recordMetric($stackPtr, 'Class opening brace placement', 'same line'); |
|
| 62 | - $error = 'Opening brace of a %s must be on the line after the definition'; |
|
| 63 | - $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceNewLine', $errorData); |
|
| 64 | - if ($fix === true) { |
|
| 65 | - $phpcsFile->fixer->beginChangeset(); |
|
| 66 | - if ($tokens[($curlyBrace - 1)]['code'] === T_WHITESPACE) { |
|
| 67 | - $phpcsFile->fixer->replaceToken(($curlyBrace - 1), ''); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - $phpcsFile->fixer->addNewlineBefore($curlyBrace); |
|
| 71 | - $phpcsFile->fixer->endChangeset(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - return; |
|
| 75 | - } else { |
|
| 76 | - $phpcsFile->recordMetric($stackPtr, 'Class opening brace placement', 'new line'); |
|
| 77 | - |
|
| 78 | - if ($braceLine > ($classLine + 1)) { |
|
| 79 | - $error = 'Opening brace of a %s must be on the line following the %s declaration; found %s line(s)'; |
|
| 80 | - $data = [ |
|
| 81 | - $tokens[$stackPtr]['content'], |
|
| 82 | - $tokens[$stackPtr]['content'], |
|
| 83 | - ($braceLine - $classLine - 1), |
|
| 84 | - ]; |
|
| 85 | - $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceWrongLine', $data); |
|
| 86 | - if ($fix === true) { |
|
| 87 | - $phpcsFile->fixer->beginChangeset(); |
|
| 88 | - for ($i = ($curlyBrace - 1); $i > $lastContent; $i--) { |
|
| 89 | - if ($tokens[$i]['line'] === ($tokens[$curlyBrace]['line'] + 1)) { |
|
| 90 | - break; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $phpcsFile->fixer->replaceToken($i, ''); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $phpcsFile->fixer->endChangeset(); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - return; |
|
| 100 | - }//end if |
|
| 101 | - }//end if |
|
| 102 | - |
|
| 103 | - if ($tokens[($curlyBrace + 1)]['content'] !== $phpcsFile->eolChar) { |
|
| 104 | - $error = 'Opening %s brace must be on a line by itself'; |
|
| 105 | - |
|
| 106 | - $nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($curlyBrace + 1), null, true); |
|
| 107 | - if ($tokens[$nextNonWhitespace]['code'] === T_PHPCS_IGNORE) { |
|
| 108 | - // Don't auto-fix if the next thing is a PHPCS ignore annotation. |
|
| 109 | - $phpcsFile->addError($error, $curlyBrace, 'OpenBraceNotAlone', $errorData); |
|
| 110 | - } else { |
|
| 111 | - $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceNotAlone', $errorData); |
|
| 112 | - if ($fix === true) { |
|
| 113 | - $phpcsFile->fixer->addNewline($curlyBrace); |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - if ($tokens[($curlyBrace - 1)]['code'] === T_WHITESPACE) { |
|
| 119 | - $prevContent = $tokens[($curlyBrace - 1)]['content']; |
|
| 120 | - if ($prevContent === $phpcsFile->eolChar) { |
|
| 121 | - $spaces = 0; |
|
| 122 | - } else { |
|
| 123 | - $spaces = $tokens[($curlyBrace - 1)]['length']; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true); |
|
| 127 | - $expected = ($tokens[$first]['column'] - 1); |
|
| 128 | - if ($spaces !== $expected) { |
|
| 129 | - $error = 'Expected %s spaces before opening brace; %s found'; |
|
| 130 | - $data = [ |
|
| 131 | - $expected, |
|
| 132 | - $spaces, |
|
| 133 | - ]; |
|
| 134 | - |
|
| 135 | - $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'SpaceBeforeBrace', $data); |
|
| 136 | - if ($fix === true) { |
|
| 137 | - $indent = str_repeat(' ', $expected); |
|
| 138 | - if ($spaces === 0) { |
|
| 139 | - $phpcsFile->fixer->addContentBefore($curlyBrace, $indent); |
|
| 140 | - } else { |
|
| 141 | - $phpcsFile->fixer->replaceToken(($curlyBrace - 1), $indent); |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - }//end if |
|
| 146 | - |
|
| 147 | - }//end process() |
|
| 19 | + /** |
|
| 20 | + * Returns an array of tokens this test wants to listen for. |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function register() |
|
| 25 | + { |
|
| 26 | + return [ |
|
| 27 | + T_CLASS, |
|
| 28 | + T_INTERFACE, |
|
| 29 | + T_TRAIT, |
|
| 30 | + T_ENUM, |
|
| 31 | + ]; |
|
| 32 | + |
|
| 33 | + }//end register() |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Processes this test, when one of its tokens is encountered. |
|
| 38 | + * |
|
| 39 | + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
|
| 40 | + * @param integer $stackPtr The position of the current token in the |
|
| 41 | + * stack passed in $tokens. |
|
| 42 | + * |
|
| 43 | + * @return void |
|
| 44 | + */ |
|
| 45 | + public function process(File $phpcsFile, $stackPtr) |
|
| 46 | + { |
|
| 47 | + $tokens = $phpcsFile->getTokens(); |
|
| 48 | + $errorData = [strtolower($tokens[$stackPtr]['content'])]; |
|
| 49 | + |
|
| 50 | + if (isset($tokens[$stackPtr]['scope_opener']) === false) { |
|
| 51 | + $error = 'Possible parse error: %s missing opening or closing brace'; |
|
| 52 | + $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $errorData); |
|
| 53 | + return; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + $curlyBrace = $tokens[$stackPtr]['scope_opener']; |
|
| 57 | + $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($curlyBrace - 1), $stackPtr, true); |
|
| 58 | + $classLine = $tokens[$lastContent]['line']; |
|
| 59 | + $braceLine = $tokens[$curlyBrace]['line']; |
|
| 60 | + if ($braceLine === $classLine) { |
|
| 61 | + $phpcsFile->recordMetric($stackPtr, 'Class opening brace placement', 'same line'); |
|
| 62 | + $error = 'Opening brace of a %s must be on the line after the definition'; |
|
| 63 | + $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceNewLine', $errorData); |
|
| 64 | + if ($fix === true) { |
|
| 65 | + $phpcsFile->fixer->beginChangeset(); |
|
| 66 | + if ($tokens[($curlyBrace - 1)]['code'] === T_WHITESPACE) { |
|
| 67 | + $phpcsFile->fixer->replaceToken(($curlyBrace - 1), ''); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + $phpcsFile->fixer->addNewlineBefore($curlyBrace); |
|
| 71 | + $phpcsFile->fixer->endChangeset(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + return; |
|
| 75 | + } else { |
|
| 76 | + $phpcsFile->recordMetric($stackPtr, 'Class opening brace placement', 'new line'); |
|
| 77 | + |
|
| 78 | + if ($braceLine > ($classLine + 1)) { |
|
| 79 | + $error = 'Opening brace of a %s must be on the line following the %s declaration; found %s line(s)'; |
|
| 80 | + $data = [ |
|
| 81 | + $tokens[$stackPtr]['content'], |
|
| 82 | + $tokens[$stackPtr]['content'], |
|
| 83 | + ($braceLine - $classLine - 1), |
|
| 84 | + ]; |
|
| 85 | + $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceWrongLine', $data); |
|
| 86 | + if ($fix === true) { |
|
| 87 | + $phpcsFile->fixer->beginChangeset(); |
|
| 88 | + for ($i = ($curlyBrace - 1); $i > $lastContent; $i--) { |
|
| 89 | + if ($tokens[$i]['line'] === ($tokens[$curlyBrace]['line'] + 1)) { |
|
| 90 | + break; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $phpcsFile->fixer->replaceToken($i, ''); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $phpcsFile->fixer->endChangeset(); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + return; |
|
| 100 | + }//end if |
|
| 101 | + }//end if |
|
| 102 | + |
|
| 103 | + if ($tokens[($curlyBrace + 1)]['content'] !== $phpcsFile->eolChar) { |
|
| 104 | + $error = 'Opening %s brace must be on a line by itself'; |
|
| 105 | + |
|
| 106 | + $nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($curlyBrace + 1), null, true); |
|
| 107 | + if ($tokens[$nextNonWhitespace]['code'] === T_PHPCS_IGNORE) { |
|
| 108 | + // Don't auto-fix if the next thing is a PHPCS ignore annotation. |
|
| 109 | + $phpcsFile->addError($error, $curlyBrace, 'OpenBraceNotAlone', $errorData); |
|
| 110 | + } else { |
|
| 111 | + $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'OpenBraceNotAlone', $errorData); |
|
| 112 | + if ($fix === true) { |
|
| 113 | + $phpcsFile->fixer->addNewline($curlyBrace); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + if ($tokens[($curlyBrace - 1)]['code'] === T_WHITESPACE) { |
|
| 119 | + $prevContent = $tokens[($curlyBrace - 1)]['content']; |
|
| 120 | + if ($prevContent === $phpcsFile->eolChar) { |
|
| 121 | + $spaces = 0; |
|
| 122 | + } else { |
|
| 123 | + $spaces = $tokens[($curlyBrace - 1)]['length']; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true); |
|
| 127 | + $expected = ($tokens[$first]['column'] - 1); |
|
| 128 | + if ($spaces !== $expected) { |
|
| 129 | + $error = 'Expected %s spaces before opening brace; %s found'; |
|
| 130 | + $data = [ |
|
| 131 | + $expected, |
|
| 132 | + $spaces, |
|
| 133 | + ]; |
|
| 134 | + |
|
| 135 | + $fix = $phpcsFile->addFixableError($error, $curlyBrace, 'SpaceBeforeBrace', $data); |
|
| 136 | + if ($fix === true) { |
|
| 137 | + $indent = str_repeat(' ', $expected); |
|
| 138 | + if ($spaces === 0) { |
|
| 139 | + $phpcsFile->fixer->addContentBefore($curlyBrace, $indent); |
|
| 140 | + } else { |
|
| 141 | + $phpcsFile->fixer->replaceToken(($curlyBrace - 1), $indent); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + }//end if |
|
| 146 | + |
|
| 147 | + }//end process() |
|
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | }//end class |
@@ -15,42 +15,42 @@ |
||
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Returns the lines where errors should occur. |
|
| 20 | - * |
|
| 21 | - * The key of the array should represent the line number and the value |
|
| 22 | - * should represent the number of errors that should occur on that line. |
|
| 23 | - * |
|
| 24 | - * @return array<int, int> |
|
| 25 | - */ |
|
| 26 | - public function getErrorList() |
|
| 27 | - { |
|
| 28 | - return [ |
|
| 29 | - 8 => 1, |
|
| 30 | - 10 => 1, |
|
| 31 | - 12 => 1, |
|
| 32 | - 14 => 1, |
|
| 33 | - 19 => 1, |
|
| 34 | - 28 => 1, |
|
| 35 | - 30 => 1, |
|
| 36 | - ]; |
|
| 37 | - |
|
| 38 | - }//end getErrorList() |
|
| 39 | - |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Returns the lines where warnings should occur. |
|
| 43 | - * |
|
| 44 | - * The key of the array should represent the line number and the value |
|
| 45 | - * should represent the number of warnings that should occur on that line. |
|
| 46 | - * |
|
| 47 | - * @return array<int, int> |
|
| 48 | - */ |
|
| 49 | - public function getWarningList() |
|
| 50 | - { |
|
| 51 | - return []; |
|
| 52 | - |
|
| 53 | - }//end getWarningList() |
|
| 18 | + /** |
|
| 19 | + * Returns the lines where errors should occur. |
|
| 20 | + * |
|
| 21 | + * The key of the array should represent the line number and the value |
|
| 22 | + * should represent the number of errors that should occur on that line. |
|
| 23 | + * |
|
| 24 | + * @return array<int, int> |
|
| 25 | + */ |
|
| 26 | + public function getErrorList() |
|
| 27 | + { |
|
| 28 | + return [ |
|
| 29 | + 8 => 1, |
|
| 30 | + 10 => 1, |
|
| 31 | + 12 => 1, |
|
| 32 | + 14 => 1, |
|
| 33 | + 19 => 1, |
|
| 34 | + 28 => 1, |
|
| 35 | + 30 => 1, |
|
| 36 | + ]; |
|
| 37 | + |
|
| 38 | + }//end getErrorList() |
|
| 39 | + |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Returns the lines where warnings should occur. |
|
| 43 | + * |
|
| 44 | + * The key of the array should represent the line number and the value |
|
| 45 | + * should represent the number of warnings that should occur on that line. |
|
| 46 | + * |
|
| 47 | + * @return array<int, int> |
|
| 48 | + */ |
|
| 49 | + public function getWarningList() |
|
| 50 | + { |
|
| 51 | + return []; |
|
| 52 | + |
|
| 53 | + }//end getWarningList() |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | }//end class |
@@ -15,37 +15,37 @@ |
||
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Returns the lines where errors should occur. |
|
| 20 | - * |
|
| 21 | - * The key of the array should represent the line number and the value |
|
| 22 | - * should represent the number of errors that should occur on that line. |
|
| 23 | - * |
|
| 24 | - * @return array<int, int> |
|
| 25 | - */ |
|
| 26 | - public function getErrorList() |
|
| 27 | - { |
|
| 28 | - return []; |
|
| 29 | - |
|
| 30 | - }//end getErrorList() |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Returns the lines where warnings should occur. |
|
| 35 | - * |
|
| 36 | - * The key of the array should represent the line number and the value |
|
| 37 | - * should represent the number of warnings that should occur on that line. |
|
| 38 | - * |
|
| 39 | - * @return array<int, int> |
|
| 40 | - */ |
|
| 41 | - public function getWarningList() |
|
| 42 | - { |
|
| 43 | - return [ |
|
| 44 | - 4 => 1, |
|
| 45 | - 16 => 1, |
|
| 46 | - ]; |
|
| 47 | - |
|
| 48 | - }//end getWarningList() |
|
| 18 | + /** |
|
| 19 | + * Returns the lines where errors should occur. |
|
| 20 | + * |
|
| 21 | + * The key of the array should represent the line number and the value |
|
| 22 | + * should represent the number of errors that should occur on that line. |
|
| 23 | + * |
|
| 24 | + * @return array<int, int> |
|
| 25 | + */ |
|
| 26 | + public function getErrorList() |
|
| 27 | + { |
|
| 28 | + return []; |
|
| 29 | + |
|
| 30 | + }//end getErrorList() |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Returns the lines where warnings should occur. |
|
| 35 | + * |
|
| 36 | + * The key of the array should represent the line number and the value |
|
| 37 | + * should represent the number of warnings that should occur on that line. |
|
| 38 | + * |
|
| 39 | + * @return array<int, int> |
|
| 40 | + */ |
|
| 41 | + public function getWarningList() |
|
| 42 | + { |
|
| 43 | + return [ |
|
| 44 | + 4 => 1, |
|
| 45 | + 16 => 1, |
|
| 46 | + ]; |
|
| 47 | + |
|
| 48 | + }//end getWarningList() |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | }//end class |
@@ -15,37 +15,37 @@ |
||
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Returns the lines where errors should occur. |
|
| 20 | - * |
|
| 21 | - * The key of the array should represent the line number and the value |
|
| 22 | - * should represent the number of errors that should occur on that line. |
|
| 23 | - * |
|
| 24 | - * @return array<int, int> |
|
| 25 | - */ |
|
| 26 | - public function getErrorList() |
|
| 27 | - { |
|
| 28 | - return []; |
|
| 29 | - |
|
| 30 | - }//end getErrorList() |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Returns the lines where warnings should occur. |
|
| 35 | - * |
|
| 36 | - * The key of the array should represent the line number and the value |
|
| 37 | - * should represent the number of warnings that should occur on that line. |
|
| 38 | - * |
|
| 39 | - * @return array<int, int> |
|
| 40 | - */ |
|
| 41 | - public function getWarningList() |
|
| 42 | - { |
|
| 43 | - return [ |
|
| 44 | - 4 => 1, |
|
| 45 | - 13 => 1, |
|
| 46 | - ]; |
|
| 47 | - |
|
| 48 | - }//end getWarningList() |
|
| 18 | + /** |
|
| 19 | + * Returns the lines where errors should occur. |
|
| 20 | + * |
|
| 21 | + * The key of the array should represent the line number and the value |
|
| 22 | + * should represent the number of errors that should occur on that line. |
|
| 23 | + * |
|
| 24 | + * @return array<int, int> |
|
| 25 | + */ |
|
| 26 | + public function getErrorList() |
|
| 27 | + { |
|
| 28 | + return []; |
|
| 29 | + |
|
| 30 | + }//end getErrorList() |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Returns the lines where warnings should occur. |
|
| 35 | + * |
|
| 36 | + * The key of the array should represent the line number and the value |
|
| 37 | + * should represent the number of warnings that should occur on that line. |
|
| 38 | + * |
|
| 39 | + * @return array<int, int> |
|
| 40 | + */ |
|
| 41 | + public function getWarningList() |
|
| 42 | + { |
|
| 43 | + return [ |
|
| 44 | + 4 => 1, |
|
| 45 | + 13 => 1, |
|
| 46 | + ]; |
|
| 47 | + |
|
| 48 | + }//end getWarningList() |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | }//end class |
@@ -15,37 +15,37 @@ |
||
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Returns the lines where errors should occur. |
|
| 20 | - * |
|
| 21 | - * The key of the array should represent the line number and the value |
|
| 22 | - * should represent the number of errors that should occur on that line. |
|
| 23 | - * |
|
| 24 | - * @return array<int, int> |
|
| 25 | - */ |
|
| 26 | - public function getErrorList() |
|
| 27 | - { |
|
| 28 | - return []; |
|
| 29 | - |
|
| 30 | - }//end getErrorList() |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Returns the lines where warnings should occur. |
|
| 35 | - * |
|
| 36 | - * The key of the array should represent the line number and the value |
|
| 37 | - * should represent the number of warnings that should occur on that line. |
|
| 38 | - * |
|
| 39 | - * @return array<int, int> |
|
| 40 | - */ |
|
| 41 | - public function getWarningList() |
|
| 42 | - { |
|
| 43 | - return [ |
|
| 44 | - 6 => 1, |
|
| 45 | - 10 => 1, |
|
| 46 | - ]; |
|
| 47 | - |
|
| 48 | - }//end getWarningList() |
|
| 18 | + /** |
|
| 19 | + * Returns the lines where errors should occur. |
|
| 20 | + * |
|
| 21 | + * The key of the array should represent the line number and the value |
|
| 22 | + * should represent the number of errors that should occur on that line. |
|
| 23 | + * |
|
| 24 | + * @return array<int, int> |
|
| 25 | + */ |
|
| 26 | + public function getErrorList() |
|
| 27 | + { |
|
| 28 | + return []; |
|
| 29 | + |
|
| 30 | + }//end getErrorList() |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Returns the lines where warnings should occur. |
|
| 35 | + * |
|
| 36 | + * The key of the array should represent the line number and the value |
|
| 37 | + * should represent the number of warnings that should occur on that line. |
|
| 38 | + * |
|
| 39 | + * @return array<int, int> |
|
| 40 | + */ |
|
| 41 | + public function getWarningList() |
|
| 42 | + { |
|
| 43 | + return [ |
|
| 44 | + 6 => 1, |
|
| 45 | + 10 => 1, |
|
| 46 | + ]; |
|
| 47 | + |
|
| 48 | + }//end getWarningList() |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | }//end class |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | } else if($a ??= $b) { |
| 61 | 61 | } elseif( $a = 'abc' && $b = 'def' ) { |
| 62 | 62 | } elseif( |
| 63 | - $a = 'abc' |
|
| 63 | + $a = 'abc' |
|
| 64 | 64 | && $a .= 'def' |
| 65 | 65 | ) {} |
| 66 | 66 | |
@@ -6,38 +6,38 @@ discard block |
||
| 6 | 6 | } elseif ($a !== 123) { |
| 7 | 7 | } elseif ($a != 123) {} |
| 8 | 8 | |
| 9 | -function abc( $a = 'default' ) {} |
|
| 10 | -if (in_array( $a, array( 1 => 'a', 2 => 'b' ) ) ) {} |
|
| 9 | +function abc($a = 'default') {} |
|
| 10 | +if (in_array($a, array(1 => 'a', 2 => 'b'))) {} |
|
| 11 | 11 | |
| 12 | -switch ( $a === $b ) {} |
|
| 13 | -switch ( true ) { |
|
| 12 | +switch ($a === $b) {} |
|
| 13 | +switch (true) { |
|
| 14 | 14 | case $sample == 'something': |
| 15 | 15 | break; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -for ( $i = 0; $i == 100; $i++ ) {} |
|
| 19 | -for ( $i = 0; $i >= 100; $i++ ) {} |
|
| 20 | -for ( $i = 0; ; $i++ ) {} |
|
| 18 | +for ($i = 0; $i == 100; $i++) {} |
|
| 19 | +for ($i = 0; $i >= 100; $i++) {} |
|
| 20 | +for ($i = 0; ; $i++) {} |
|
| 21 | 21 | for (;;) {} |
| 22 | 22 | |
| 23 | 23 | do { |
| 24 | -} while ( $sample == false ); |
|
| 24 | +}while ($sample == false); |
|
| 25 | 25 | |
| 26 | -while ( $sample === false ) {} |
|
| 26 | +while ($sample === false) {} |
|
| 27 | 27 | |
| 28 | 28 | // Silly, but not an assignment. |
| 29 | 29 | if (123 = $a) {} |
| 30 | 30 | if (strtolower($b) = $b) {} |
| 31 | -if (array( 1 => 'a', 2 => 'b' ) = $b) {} |
|
| 31 | +if (array(1 => 'a', 2 => 'b') = $b) {} |
|
| 32 | 32 | |
| 33 | 33 | if (SOME_CONSTANT = 123) { |
| 34 | -} else if(self::SOME_CONSTANT -= 10) {} |
|
| 34 | +} else if (self::SOME_CONSTANT -= 10) {} |
|
| 35 | 35 | |
| 36 | -if ( $a() = 123 ) { |
|
| 37 | -} else if ( $b->something() = 123 ) { |
|
| 38 | -} elseif ( $c::something() = 123 ) {} |
|
| 36 | +if ($a() = 123) { |
|
| 37 | +} else if ($b->something() = 123) { |
|
| 38 | +} elseif ($c::something() = 123) {} |
|
| 39 | 39 | |
| 40 | -switch ( true ) { |
|
| 40 | +switch (true) { |
|
| 41 | 41 | case 'something' = $sample: |
| 42 | 42 | break; |
| 43 | 43 | } |
@@ -45,21 +45,21 @@ discard block |
||
| 45 | 45 | // Assignments in condition. |
| 46 | 46 | if ($a = 123) { |
| 47 | 47 | } elseif ($a = 'abc') { |
| 48 | -} else if( $a += 10 ) { |
|
| 49 | -} else if($a -= 10) { |
|
| 50 | -} else if($a *= 10) { |
|
| 51 | -} else if($a **= 10) { |
|
| 52 | -} else if($a /= 10) { |
|
| 53 | -} else if($a .= strtolower($b)) { |
|
| 54 | -} else if($a %= SOME_CONSTANT) { |
|
| 55 | -} else if($a &= 2) { |
|
| 56 | -} else if($a |= 2) { |
|
| 57 | -} else if($a ^= 2) { |
|
| 58 | -} else if($a <<= 2) { |
|
| 59 | -} else if($a >>= 2) { |
|
| 60 | -} else if($a ??= $b) { |
|
| 61 | -} elseif( $a = 'abc' && $b = 'def' ) { |
|
| 62 | -} elseif( |
|
| 48 | +} else if ($a += 10) { |
|
| 49 | +} else if ($a -= 10) { |
|
| 50 | +} else if ($a *= 10) { |
|
| 51 | +} else if ($a **= 10) { |
|
| 52 | +} else if ($a /= 10) { |
|
| 53 | +} else if ($a .= strtolower($b)) { |
|
| 54 | +} else if ($a %= SOME_CONSTANT) { |
|
| 55 | +} else if ($a &= 2) { |
|
| 56 | +} else if ($a |= 2) { |
|
| 57 | +} else if ($a ^= 2) { |
|
| 58 | +} else if ($a <<= 2) { |
|
| 59 | +} else if ($a >>= 2) { |
|
| 60 | +} else if ($a ??= $b) { |
|
| 61 | +} elseif ($a = 'abc' && $b = 'def') { |
|
| 62 | +} elseif ( |
|
| 63 | 63 | $a = 'abc' |
| 64 | 64 | && $a .= 'def' |
| 65 | 65 | ) {} |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | } elseif (parent::$a *= 123) { |
| 71 | 71 | } elseif (static::$a = 123) { |
| 72 | 72 | } elseif (MyClass::$a .= 'abc') { |
| 73 | -} else if( $this->something += 10 ) {} |
|
| 73 | +} else if ($this->something += 10) {} |
|
| 74 | 74 | |
| 75 | -switch ( $a = $b ) {} |
|
| 76 | -switch ( true ) { |
|
| 75 | +switch ($a = $b) {} |
|
| 76 | +switch (true) { |
|
| 77 | 77 | case $sample = 'something': |
| 78 | 78 | break; |
| 79 | 79 | |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | -for ( $i = 0; $i = 100; $i++ ) {} |
|
| 85 | -for ( $i = 0; $i = 100 && $b = false; $i++ ) {} |
|
| 84 | +for ($i = 0; $i = 100; $i++) {} |
|
| 85 | +for ($i = 0; $i = 100 && $b = false; $i++) {} |
|
| 86 | 86 | |
| 87 | 87 | do { |
| 88 | -} while ( $sample = false ); |
|
| 88 | +}while ($sample = false); |
|
| 89 | 89 | |
| 90 | -while ( $sample = false ) {} |
|
| 90 | +while ($sample = false) {} |
|
| 91 | 91 | |
| 92 | 92 | if ($a = 123) : |
| 93 | 93 | endif; |
@@ -1,25 +1,25 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | for ($i = 0; $i < 20; $i++) { |
| 4 | - for ($j = 0; $j < 5; $i += 2) { |
|
| 5 | - for ($k = 0; $k > 3; $i++) { |
|
| 4 | + for ($j = 0; $j < 5; $i += 2) { |
|
| 5 | + for ($k = 0; $k > 3; $i++) { |
|
| 6 | 6 | |
| 7 | - } |
|
| 8 | - } |
|
| 7 | + } |
|
| 8 | + } |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | for ($i = 0; $i < 20; $i++) { |
| 12 | - for ($j = 0; $j < 5; $j += 2) { |
|
| 13 | - for ($k = 0; $k > 3; $k++) { |
|
| 12 | + for ($j = 0; $j < 5; $j += 2) { |
|
| 13 | + for ($k = 0; $k > 3; $k++) { |
|
| 14 | 14 | |
| 15 | - } |
|
| 16 | - } |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | for ($i = 0; $i < 20; $i++) { |
| 20 | - for ($j = 0; $j < 5; $j += 2) { |
|
| 21 | - for ($k = 0; $k > 3; $j++) { |
|
| 20 | + for ($j = 0; $j < 5; $j += 2) { |
|
| 21 | + for ($k = 0; $k > 3; $j++) { |
|
| 22 | 22 | |
| 23 | - } |
|
| 24 | - } |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -15,38 +15,38 @@ |
||
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Returns the lines where errors should occur. |
|
| 20 | - * |
|
| 21 | - * The key of the array should represent the line number and the value |
|
| 22 | - * should represent the number of errors that should occur on that line. |
|
| 23 | - * |
|
| 24 | - * @return array<int, int> |
|
| 25 | - */ |
|
| 26 | - public function getErrorList() |
|
| 27 | - { |
|
| 28 | - return []; |
|
| 29 | - |
|
| 30 | - }//end getErrorList() |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Returns the lines where warnings should occur. |
|
| 35 | - * |
|
| 36 | - * The key of the array should represent the line number and the value |
|
| 37 | - * should represent the number of warnings that should occur on that line. |
|
| 38 | - * |
|
| 39 | - * @return array<int, int> |
|
| 40 | - */ |
|
| 41 | - public function getWarningList() |
|
| 42 | - { |
|
| 43 | - return [ |
|
| 44 | - 3 => 2, |
|
| 45 | - 4 => 1, |
|
| 46 | - 20 => 1, |
|
| 47 | - ]; |
|
| 48 | - |
|
| 49 | - }//end getWarningList() |
|
| 18 | + /** |
|
| 19 | + * Returns the lines where errors should occur. |
|
| 20 | + * |
|
| 21 | + * The key of the array should represent the line number and the value |
|
| 22 | + * should represent the number of errors that should occur on that line. |
|
| 23 | + * |
|
| 24 | + * @return array<int, int> |
|
| 25 | + */ |
|
| 26 | + public function getErrorList() |
|
| 27 | + { |
|
| 28 | + return []; |
|
| 29 | + |
|
| 30 | + }//end getErrorList() |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Returns the lines where warnings should occur. |
|
| 35 | + * |
|
| 36 | + * The key of the array should represent the line number and the value |
|
| 37 | + * should represent the number of warnings that should occur on that line. |
|
| 38 | + * |
|
| 39 | + * @return array<int, int> |
|
| 40 | + */ |
|
| 41 | + public function getWarningList() |
|
| 42 | + { |
|
| 43 | + return [ |
|
| 44 | + 3 => 2, |
|
| 45 | + 4 => 1, |
|
| 46 | + 20 => 1, |
|
| 47 | + ]; |
|
| 48 | + |
|
| 49 | + }//end getWarningList() |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | }//end class |