@@ -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 | - 4 => 1, |
|
| 30 | - 8 => 1, |
|
| 31 | - 28 => 1, |
|
| 32 | - ]; |
|
| 33 | - |
|
| 34 | - }//end getErrorList() |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Returns the lines where warnings should occur. |
|
| 39 | - * |
|
| 40 | - * The key of the array should represent the line number and the value |
|
| 41 | - * should represent the number of warnings that should occur on that line. |
|
| 42 | - * |
|
| 43 | - * @return array<int, int> |
|
| 44 | - */ |
|
| 45 | - public function getWarningList() |
|
| 46 | - { |
|
| 47 | - return []; |
|
| 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 | + 4 => 1, |
|
| 30 | + 8 => 1, |
|
| 31 | + 28 => 1, |
|
| 32 | + ]; |
|
| 33 | + |
|
| 34 | + }//end getErrorList() |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Returns the lines where warnings should occur. |
|
| 39 | + * |
|
| 40 | + * The key of the array should represent the line number and the value |
|
| 41 | + * should represent the number of warnings that should occur on that line. |
|
| 42 | + * |
|
| 43 | + * @return array<int, int> |
|
| 44 | + */ |
|
| 45 | + public function getWarningList() |
|
| 46 | + { |
|
| 47 | + return []; |
|
| 48 | + |
|
| 49 | + }//end getWarningList() |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | }//end class |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | }//end class |
| 58 | 58 | |
| 59 | -class ClassOne implements ClassFour ,ClassFive, ClassSix |
|
| 59 | +class ClassOne implements ClassFour, ClassFive, ClassSix |
|
| 60 | 60 | { |
| 61 | 61 | }//end class |
| 62 | 62 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | } // phpcs:enable Standard.Category.Sniff |
| 84 | 84 | |
| 85 | -class File implements \Zend_Auth_Storage_Interface,\Zend_Auth_Storage, \Zend_Foo |
|
| 85 | +class File implements \Zend_Auth_Storage_Interface, \Zend_Auth_Storage, \Zend_Foo |
|
| 86 | 86 | { |
| 87 | 87 | } |
| 88 | 88 | |
@@ -107,4 +107,4 @@ discard block |
||
| 107 | 107 | class IncorrectCodeBeforeClosingBrace |
| 108 | 108 | { |
| 109 | 109 | |
| 110 | -echo phpinfo();} |
|
| 110 | +echo phpinfo(); } |
|
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | class IncorrectBracePlacementWithImplements implements correctClassDeclaration {} |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - class IncorrectIndentedClass |
|
| 28 | - { |
|
| 27 | + class IncorrectIndentedClass |
|
| 28 | + { |
|
| 29 | 29 | |
| 30 | - }//end class |
|
| 30 | + }//end class |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | // Incorrect code placement for opening/closing brace. |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | echo phpinfo(); } |
| 49 | 49 | |
| 50 | - class IncorrectIndentedClass |
|
| 50 | + class IncorrectIndentedClass |
|
| 51 | 51 | { |
| 52 | 52 | |
| 53 | 53 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | class MyClass2 |
| 98 | 98 | { |
| 99 | - var $x; |
|
| 99 | + var $x; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function SelfMemberReferenceUnitTestExample() |
| 15 | 15 | { |
| 16 | - $testResults =& $this->testResults; |
|
| 16 | + $testResults = & $this->testResults; |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | // Correct call to self. |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | MyClass::test($value); |
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | - $array = array(1,2,3); |
|
| 60 | + $array = array(1, 2, 3); |
|
| 61 | 61 | array_walk($array, $callback); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -5,54 +5,54 @@ discard block |
||
| 5 | 5 | { |
| 6 | 6 | |
| 7 | 7 | |
| 8 | - private $testCount = 0; |
|
| 8 | + private $testCount = 0; |
|
| 9 | 9 | |
| 10 | 10 | |
| 11 | - private $testResults = array(); |
|
| 11 | + private $testResults = array(); |
|
| 12 | 12 | |
| 13 | 13 | |
| 14 | - public function SelfMemberReferenceUnitTestExample() |
|
| 15 | - { |
|
| 16 | - $testResults =& $this->testResults; |
|
| 14 | + public function SelfMemberReferenceUnitTestExample() |
|
| 15 | + { |
|
| 16 | + $testResults =& $this->testResults; |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | - // Correct call to self. |
|
| 20 | - $testResults[] = self::selfMemberReferenceUnitTestFunction(); |
|
| 21 | - $testResults[] = parent::selfMemberReferenceUnitTestFunction(); |
|
| 19 | + // Correct call to self. |
|
| 20 | + $testResults[] = self::selfMemberReferenceUnitTestFunction(); |
|
| 21 | + $testResults[] = parent::selfMemberReferenceUnitTestFunction(); |
|
| 22 | 22 | |
| 23 | - // Incorrect case. |
|
| 24 | - $testResults[] = Self::selfMemberReferenceUnitTestFunction(); |
|
| 25 | - $testResults[] = SELF::selfMemberReferenceUnitTestFunction(); |
|
| 26 | - $testResults[] = SelfMemberReferenceUnitTestExample::selfMemberReferenceUnitTestFunction(); |
|
| 23 | + // Incorrect case. |
|
| 24 | + $testResults[] = Self::selfMemberReferenceUnitTestFunction(); |
|
| 25 | + $testResults[] = SELF::selfMemberReferenceUnitTestFunction(); |
|
| 26 | + $testResults[] = SelfMemberReferenceUnitTestExample::selfMemberReferenceUnitTestFunction(); |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - // Incorrect spacing. |
|
| 30 | - $testResults[] = self ::selfMemberReferenceUnitTestFunction(); |
|
| 31 | - $testResults[] = self:: selfMemberReferenceUnitTestFunction(); |
|
| 32 | - $testResults[] = self :: selfMemberReferenceUnitTestFunction(); |
|
| 29 | + // Incorrect spacing. |
|
| 30 | + $testResults[] = self ::selfMemberReferenceUnitTestFunction(); |
|
| 31 | + $testResults[] = self:: selfMemberReferenceUnitTestFunction(); |
|
| 32 | + $testResults[] = self :: selfMemberReferenceUnitTestFunction(); |
|
| 33 | 33 | |
| 34 | - // Remove ALL the newlines |
|
| 35 | - $testResults[] = self |
|
| 34 | + // Remove ALL the newlines |
|
| 35 | + $testResults[] = self |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | |
| 40 | - :: |
|
| 40 | + :: |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - selfMemberReferenceUnitTestFunction(); |
|
| 45 | + selfMemberReferenceUnitTestFunction(); |
|
| 46 | 46 | |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - function selfMemberReferenceUnitTestFunction() |
|
| 51 | - { |
|
| 52 | - $this->testCount = $this->testCount + 1; |
|
| 53 | - return $this->testCount; |
|
| 50 | + function selfMemberReferenceUnitTestFunction() |
|
| 51 | + { |
|
| 52 | + $this->testCount = $this->testCount + 1; |
|
| 53 | + return $this->testCount; |
|
| 54 | 54 | |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | } |
@@ -60,115 +60,115 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | class MyClass { |
| 62 | 62 | |
| 63 | - public static function test($value) { |
|
| 64 | - echo "$value\n"; |
|
| 65 | - } |
|
| 63 | + public static function test($value) { |
|
| 64 | + echo "$value\n"; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - public static function walk() { |
|
| 68 | - $callback = function($value, $key) { |
|
| 69 | - // This is valid because you can't use self:: in a closure. |
|
| 70 | - MyClass::test($value); |
|
| 71 | - }; |
|
| 67 | + public static function walk() { |
|
| 68 | + $callback = function($value, $key) { |
|
| 69 | + // This is valid because you can't use self:: in a closure. |
|
| 70 | + MyClass::test($value); |
|
| 71 | + }; |
|
| 72 | 72 | |
| 73 | - $array = array(1,2,3); |
|
| 74 | - array_walk($array, $callback); |
|
| 75 | - } |
|
| 73 | + $array = array(1,2,3); |
|
| 74 | + array_walk($array, $callback); |
|
| 75 | + } |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | MyClass::walk(); |
| 79 | 79 | |
| 80 | 80 | class Controller |
| 81 | 81 | { |
| 82 | - public function Action() |
|
| 83 | - { |
|
| 84 | - Doctrine\Common\Util\Debug::dump(); |
|
| 85 | - } |
|
| 82 | + public function Action() |
|
| 83 | + { |
|
| 84 | + Doctrine\Common\Util\Debug::dump(); |
|
| 85 | + } |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | class Foo |
| 89 | 89 | { |
| 90 | - public static function bar() |
|
| 91 | - { |
|
| 92 | - \Foo::baz(); |
|
| 93 | - } |
|
| 90 | + public static function bar() |
|
| 91 | + { |
|
| 92 | + \Foo::baz(); |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | namespace TYPO3\CMS\Reports; |
| 97 | 97 | |
| 98 | 98 | class Status { |
| 99 | - const NOTICE = -2; |
|
| 100 | - const INFO = -1; |
|
| 101 | - const OK = 0; |
|
| 102 | - const WARNING = 1; |
|
| 103 | - const ERROR = 2; |
|
| 99 | + const NOTICE = -2; |
|
| 100 | + const INFO = -1; |
|
| 101 | + const OK = 0; |
|
| 102 | + const WARNING = 1; |
|
| 103 | + const ERROR = 2; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | namespace TYPO3\CMS\Reports\Report\Status; |
| 107 | 107 | |
| 108 | 108 | class Status implements \TYPO3\CMS\Reports\ReportInterface { |
| 109 | - public function getHighestSeverity(array $statusCollection) { |
|
| 110 | - $highestSeverity = \TYPO3\CMS\Reports\Status::NOTICE; |
|
| 111 | - } |
|
| 109 | + public function getHighestSeverity(array $statusCollection) { |
|
| 110 | + $highestSeverity = \TYPO3\CMS\Reports\Status::NOTICE; |
|
| 111 | + } |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | namespace Foo; |
| 115 | 115 | |
| 116 | 116 | class Bar { |
| 117 | 117 | |
| 118 | - function myFunction() |
|
| 119 | - { |
|
| 120 | - \Foo\Whatever::something(); |
|
| 121 | - \Foo\Bar::something(); |
|
| 122 | - } |
|
| 118 | + function myFunction() |
|
| 119 | + { |
|
| 120 | + \Foo\Whatever::something(); |
|
| 121 | + \Foo\Bar::something(); |
|
| 122 | + } |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | namespace Foo\Bar; |
| 126 | 126 | |
| 127 | 127 | class Baz { |
| 128 | 128 | |
| 129 | - function myFunction() |
|
| 130 | - { |
|
| 131 | - \Foo\Bar\Whatever::something(); |
|
| 132 | - \Foo\Bar\Baz::something(); |
|
| 133 | - } |
|
| 129 | + function myFunction() |
|
| 130 | + { |
|
| 131 | + \Foo\Bar\Whatever::something(); |
|
| 132 | + \Foo\Bar\Baz::something(); |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | class Nested_Anon_Class { |
| 137 | - public function getAnonymousClass() { |
|
| 138 | - // Spacing/comments should not cause false negatives for the NotUsed error. |
|
| 139 | - Nested_Anon_Class :: $prop; |
|
| 140 | - Nested_Anon_Class |
|
| 141 | - /* some comment */ |
|
| 142 | - |
|
| 143 | - :: |
|
| 144 | - |
|
| 145 | - // phpcs:ignore Standard.Category.SniffName -- for reasons. |
|
| 146 | - Bar(); |
|
| 147 | - |
|
| 148 | - // Anonymous class is a different scope. |
|
| 149 | - return new class() { |
|
| 150 | - public function nested_function() { |
|
| 151 | - Nested_Anon_Class::$prop; |
|
| 152 | - Nested_Anon_Class::BAR; |
|
| 153 | - } |
|
| 154 | - }; |
|
| 155 | - } |
|
| 137 | + public function getAnonymousClass() { |
|
| 138 | + // Spacing/comments should not cause false negatives for the NotUsed error. |
|
| 139 | + Nested_Anon_Class :: $prop; |
|
| 140 | + Nested_Anon_Class |
|
| 141 | + /* some comment */ |
|
| 142 | + |
|
| 143 | + :: |
|
| 144 | + |
|
| 145 | + // phpcs:ignore Standard.Category.SniffName -- for reasons. |
|
| 146 | + Bar(); |
|
| 147 | + |
|
| 148 | + // Anonymous class is a different scope. |
|
| 149 | + return new class() { |
|
| 150 | + public function nested_function() { |
|
| 151 | + Nested_Anon_Class::$prop; |
|
| 152 | + Nested_Anon_Class::BAR; |
|
| 153 | + } |
|
| 154 | + }; |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Test dealing with scoped namespaces. |
| 159 | 159 | namespace Foo\Baz { |
| 160 | - class BarFoo { |
|
| 161 | - public function foo() { |
|
| 162 | - echo Foo\Baz\BarFoo::$prop; |
|
| 163 | - } |
|
| 164 | - } |
|
| 160 | + class BarFoo { |
|
| 161 | + public function foo() { |
|
| 162 | + echo Foo\Baz\BarFoo::$prop; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // Prevent false negative when namespace has whitespace/comments. |
| 168 | 168 | namespace Foo /*comment*/ \ Bah { |
| 169 | - class BarFoo { |
|
| 170 | - public function foo() { |
|
| 171 | - echo Foo \ /*comment*/ Bah\BarFoo::$prop; |
|
| 172 | - } |
|
| 173 | - } |
|
| 169 | + class BarFoo { |
|
| 170 | + public function foo() { |
|
| 171 | + echo Foo \ /*comment*/ Bah\BarFoo::$prop; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | * |
| 26 | 26 | * @return array<int, int> |
| 27 | 27 | */ |
| 28 | - public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc') |
|
| 28 | + public function getErrorList($testFile = 'ComparisonOperatorUsageUnitTest.inc') |
|
| 29 | 29 | { |
| 30 | 30 | switch ($testFile) { |
| 31 | 31 | case 'ComparisonOperatorUsageUnitTest.inc': |
@@ -15,87 +15,87 @@ |
||
| 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 | - * @param string $testFile The name of the file being tested. |
|
| 25 | - * |
|
| 26 | - * @return array<int, int> |
|
| 27 | - */ |
|
| 28 | - public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc') |
|
| 29 | - { |
|
| 30 | - switch ($testFile) { |
|
| 31 | - case 'ComparisonOperatorUsageUnitTest.inc': |
|
| 32 | - return [ |
|
| 33 | - 6 => 1, |
|
| 34 | - 7 => 1, |
|
| 35 | - 10 => 1, |
|
| 36 | - 11 => 1, |
|
| 37 | - 18 => 1, |
|
| 38 | - 19 => 1, |
|
| 39 | - 22 => 1, |
|
| 40 | - 23 => 1, |
|
| 41 | - 29 => 2, |
|
| 42 | - 32 => 2, |
|
| 43 | - 38 => 4, |
|
| 44 | - 47 => 2, |
|
| 45 | - 69 => 1, |
|
| 46 | - 72 => 1, |
|
| 47 | - 75 => 1, |
|
| 48 | - 78 => 1, |
|
| 49 | - 80 => 1, |
|
| 50 | - 82 => 1, |
|
| 51 | - 83 => 1, |
|
| 52 | - 89 => 1, |
|
| 53 | - 92 => 1, |
|
| 54 | - 100 => 1, |
|
| 55 | - 106 => 1, |
|
| 56 | - 112 => 1, |
|
| 57 | - 123 => 1, |
|
| 58 | - 127 => 1, |
|
| 59 | - 131 => 1, |
|
| 60 | - 135 => 1, |
|
| 61 | - ]; |
|
| 62 | - break; |
|
| 63 | - case 'ComparisonOperatorUsageUnitTest.js': |
|
| 64 | - return [ |
|
| 65 | - 5 => 1, |
|
| 66 | - 6 => 1, |
|
| 67 | - 17 => 1, |
|
| 68 | - 18 => 1, |
|
| 69 | - 28 => 2, |
|
| 70 | - 40 => 1, |
|
| 71 | - 47 => 1, |
|
| 72 | - 52 => 1, |
|
| 73 | - 63 => 1, |
|
| 74 | - 67 => 1, |
|
| 75 | - 71 => 1, |
|
| 76 | - ]; |
|
| 77 | - break; |
|
| 78 | - default: |
|
| 79 | - return []; |
|
| 80 | - break; |
|
| 81 | - }//end switch |
|
| 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 | + * @param string $testFile The name of the file being tested. |
|
| 25 | + * |
|
| 26 | + * @return array<int, int> |
|
| 27 | + */ |
|
| 28 | + public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc') |
|
| 29 | + { |
|
| 30 | + switch ($testFile) { |
|
| 31 | + case 'ComparisonOperatorUsageUnitTest.inc': |
|
| 32 | + return [ |
|
| 33 | + 6 => 1, |
|
| 34 | + 7 => 1, |
|
| 35 | + 10 => 1, |
|
| 36 | + 11 => 1, |
|
| 37 | + 18 => 1, |
|
| 38 | + 19 => 1, |
|
| 39 | + 22 => 1, |
|
| 40 | + 23 => 1, |
|
| 41 | + 29 => 2, |
|
| 42 | + 32 => 2, |
|
| 43 | + 38 => 4, |
|
| 44 | + 47 => 2, |
|
| 45 | + 69 => 1, |
|
| 46 | + 72 => 1, |
|
| 47 | + 75 => 1, |
|
| 48 | + 78 => 1, |
|
| 49 | + 80 => 1, |
|
| 50 | + 82 => 1, |
|
| 51 | + 83 => 1, |
|
| 52 | + 89 => 1, |
|
| 53 | + 92 => 1, |
|
| 54 | + 100 => 1, |
|
| 55 | + 106 => 1, |
|
| 56 | + 112 => 1, |
|
| 57 | + 123 => 1, |
|
| 58 | + 127 => 1, |
|
| 59 | + 131 => 1, |
|
| 60 | + 135 => 1, |
|
| 61 | + ]; |
|
| 62 | + break; |
|
| 63 | + case 'ComparisonOperatorUsageUnitTest.js': |
|
| 64 | + return [ |
|
| 65 | + 5 => 1, |
|
| 66 | + 6 => 1, |
|
| 67 | + 17 => 1, |
|
| 68 | + 18 => 1, |
|
| 69 | + 28 => 2, |
|
| 70 | + 40 => 1, |
|
| 71 | + 47 => 1, |
|
| 72 | + 52 => 1, |
|
| 73 | + 63 => 1, |
|
| 74 | + 67 => 1, |
|
| 75 | + 71 => 1, |
|
| 76 | + ]; |
|
| 77 | + break; |
|
| 78 | + default: |
|
| 79 | + return []; |
|
| 80 | + break; |
|
| 81 | + }//end switch |
|
| 82 | 82 | |
| 83 | - }//end getErrorList() |
|
| 83 | + }//end getErrorList() |
|
| 84 | 84 | |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Returns the lines where warnings should occur. |
|
| 88 | - * |
|
| 89 | - * The key of the array should represent the line number and the value |
|
| 90 | - * should represent the number of warnings that should occur on that line. |
|
| 91 | - * |
|
| 92 | - * @return array<int, int> |
|
| 93 | - */ |
|
| 94 | - public function getWarningList() |
|
| 95 | - { |
|
| 96 | - return []; |
|
| 86 | + /** |
|
| 87 | + * Returns the lines where warnings should occur. |
|
| 88 | + * |
|
| 89 | + * The key of the array should represent the line number and the value |
|
| 90 | + * should represent the number of warnings that should occur on that line. |
|
| 91 | + * |
|
| 92 | + * @return array<int, int> |
|
| 93 | + */ |
|
| 94 | + public function getWarningList() |
|
| 95 | + { |
|
| 96 | + return []; |
|
| 97 | 97 | |
| 98 | - }//end getWarningList() |
|
| 98 | + }//end getWarningList() |
|
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | }//end class |
@@ -28,56 +28,56 @@ |
||
| 28 | 28 | public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc') |
| 29 | 29 | { |
| 30 | 30 | switch ($testFile) { |
| 31 | - case 'ComparisonOperatorUsageUnitTest.inc': |
|
| 32 | - return [ |
|
| 33 | - 6 => 1, |
|
| 34 | - 7 => 1, |
|
| 35 | - 10 => 1, |
|
| 36 | - 11 => 1, |
|
| 37 | - 18 => 1, |
|
| 38 | - 19 => 1, |
|
| 39 | - 22 => 1, |
|
| 40 | - 23 => 1, |
|
| 41 | - 29 => 2, |
|
| 42 | - 32 => 2, |
|
| 43 | - 38 => 4, |
|
| 44 | - 47 => 2, |
|
| 45 | - 69 => 1, |
|
| 46 | - 72 => 1, |
|
| 47 | - 75 => 1, |
|
| 48 | - 78 => 1, |
|
| 49 | - 80 => 1, |
|
| 50 | - 82 => 1, |
|
| 51 | - 83 => 1, |
|
| 52 | - 89 => 1, |
|
| 53 | - 92 => 1, |
|
| 54 | - 100 => 1, |
|
| 55 | - 106 => 1, |
|
| 56 | - 112 => 1, |
|
| 57 | - 123 => 1, |
|
| 58 | - 127 => 1, |
|
| 59 | - 131 => 1, |
|
| 60 | - 135 => 1, |
|
| 61 | - ]; |
|
| 62 | - break; |
|
| 63 | - case 'ComparisonOperatorUsageUnitTest.js': |
|
| 64 | - return [ |
|
| 65 | - 5 => 1, |
|
| 66 | - 6 => 1, |
|
| 67 | - 17 => 1, |
|
| 68 | - 18 => 1, |
|
| 69 | - 28 => 2, |
|
| 70 | - 40 => 1, |
|
| 71 | - 47 => 1, |
|
| 72 | - 52 => 1, |
|
| 73 | - 63 => 1, |
|
| 74 | - 67 => 1, |
|
| 75 | - 71 => 1, |
|
| 76 | - ]; |
|
| 77 | - break; |
|
| 78 | - default: |
|
| 79 | - return []; |
|
| 80 | - break; |
|
| 31 | + case 'ComparisonOperatorUsageUnitTest.inc': |
|
| 32 | + return [ |
|
| 33 | + 6 => 1, |
|
| 34 | + 7 => 1, |
|
| 35 | + 10 => 1, |
|
| 36 | + 11 => 1, |
|
| 37 | + 18 => 1, |
|
| 38 | + 19 => 1, |
|
| 39 | + 22 => 1, |
|
| 40 | + 23 => 1, |
|
| 41 | + 29 => 2, |
|
| 42 | + 32 => 2, |
|
| 43 | + 38 => 4, |
|
| 44 | + 47 => 2, |
|
| 45 | + 69 => 1, |
|
| 46 | + 72 => 1, |
|
| 47 | + 75 => 1, |
|
| 48 | + 78 => 1, |
|
| 49 | + 80 => 1, |
|
| 50 | + 82 => 1, |
|
| 51 | + 83 => 1, |
|
| 52 | + 89 => 1, |
|
| 53 | + 92 => 1, |
|
| 54 | + 100 => 1, |
|
| 55 | + 106 => 1, |
|
| 56 | + 112 => 1, |
|
| 57 | + 123 => 1, |
|
| 58 | + 127 => 1, |
|
| 59 | + 131 => 1, |
|
| 60 | + 135 => 1, |
|
| 61 | + ]; |
|
| 62 | + break; |
|
| 63 | + case 'ComparisonOperatorUsageUnitTest.js': |
|
| 64 | + return [ |
|
| 65 | + 5 => 1, |
|
| 66 | + 6 => 1, |
|
| 67 | + 17 => 1, |
|
| 68 | + 18 => 1, |
|
| 69 | + 28 => 2, |
|
| 70 | + 40 => 1, |
|
| 71 | + 47 => 1, |
|
| 72 | + 52 => 1, |
|
| 73 | + 63 => 1, |
|
| 74 | + 67 => 1, |
|
| 75 | + 71 => 1, |
|
| 76 | + ]; |
|
| 77 | + break; |
|
| 78 | + default: |
|
| 79 | + return []; |
|
| 80 | + break; |
|
| 81 | 81 | }//end switch |
| 82 | 82 | |
| 83 | 83 | }//end getErrorList() |
@@ -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 | - 5 => 1, |
|
| 30 | - 11 => 1, |
|
| 31 | - 17 => 2, |
|
| 32 | - ]; |
|
| 33 | - |
|
| 34 | - }//end getErrorList() |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Returns the lines where warnings should occur. |
|
| 39 | - * |
|
| 40 | - * The key of the array should represent the line number and the value |
|
| 41 | - * should represent the number of warnings that should occur on that line. |
|
| 42 | - * |
|
| 43 | - * @return array<int, int> |
|
| 44 | - */ |
|
| 45 | - public function getWarningList() |
|
| 46 | - { |
|
| 47 | - return []; |
|
| 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 | + 5 => 1, |
|
| 30 | + 11 => 1, |
|
| 31 | + 17 => 2, |
|
| 32 | + ]; |
|
| 33 | + |
|
| 34 | + }//end getErrorList() |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Returns the lines where warnings should occur. |
|
| 39 | + * |
|
| 40 | + * The key of the array should represent the line number and the value |
|
| 41 | + * should represent the number of warnings that should occur on that line. |
|
| 42 | + * |
|
| 43 | + * @return array<int, int> |
|
| 44 | + */ |
|
| 45 | + public function getWarningList() |
|
| 46 | + { |
|
| 47 | + return []; |
|
| 48 | + |
|
| 49 | + }//end getWarningList() |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | }//end class |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | // Without brackets around inline IF condition. |
| 54 | 54 | $var1 === TRUE |
| 55 | - ? $var2 = 0 |
|
| 56 | - : $var2 = 1; |
|
| 55 | + ? $var2 = 0 |
|
| 56 | + : $var2 = 1; |
|
| 57 | 57 | |
| 58 | 58 | $var1 === TRUE ? $var2 = 0 : $var2 = 1; |
| 59 | 59 | ?> |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | $var1 === TRUE ? $var2 = 0 : $var2 = 1; |
| 62 | 62 | |
| 63 | 63 | if ($var2 === TRUE) { |
| 64 | - $var1 === TRUE ? $var2 = 0 : $var2 = 1; |
|
| 64 | + $var1 === TRUE ? $var2 = 0 : $var2 = 1; |
|
| 65 | 65 | } |
| 66 | 66 | $var1 === TRUE ? $var2 = 0 : $var2 = 1; |
| 67 | 67 | |
| 68 | 68 | $var1 |
| 69 | - ? $var2 = 0 |
|
| 70 | - : $var2 = 1; |
|
| 69 | + ? $var2 = 0 |
|
| 70 | + : $var2 = 1; |
|
| 71 | 71 | |
| 72 | 72 | $var1 ? $var2 = 0 : $var2 = 1; |
| 73 | 73 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $var1 ? $var2 = 0 : $var2 = 1; |
| 76 | 76 | |
| 77 | 77 | if ($var2 === TRUE) { |
| 78 | - $var1 ? $var2 = 0 : $var2 = 1; |
|
| 78 | + $var1 ? $var2 = 0 : $var2 = 1; |
|
| 79 | 79 | } |
| 80 | 80 | $var1 ? $var2 = 0 : $var2 = 1; |
| 81 | 81 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | if ($value) { |
| 11 | -} else if (!$value) { |
|
| 11 | +} else if ( ! $value) { |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | if (is_array($array) === TRUE) { |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | if (is_array($array)) { |
| 23 | -} else if (!myFunction($value)) { |
|
| 23 | +} else if ( ! myFunction($value)) { |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | if ($value === TRUE || $other === FALSE) { |
@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | if ($value == TRUE || $other == FALSE) { |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -if ($value || !$other) { |
|
| 32 | +if ($value || ! $other) { |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | if ($one === TRUE || $two === TRUE || $three === FALSE || $four === TRUE) { |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -if ($one || $two || !$three || $four) { |
|
| 38 | +if ($one || $two || ! $three || $four) { |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | if ($var instanceof PHP_CodeSniffer) { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $var1 ? $var2 = 0 : $var2 = 1; |
| 81 | 81 | |
| 82 | 82 | if ($value) { |
| 83 | -} elseif (!$value) { |
|
| 83 | +} elseif ( ! $value) { |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | if (false === ($parent instanceof Foo) && ($parent instanceof Bar) === false) { |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | do { |
| 99 | 99 | |
| 100 | -} while ($var1); |
|
| 100 | +}while ($var1); |
|
| 101 | 101 | |
| 102 | 102 | do { |
| 103 | 103 | |
| 104 | -} while ($var1 === TRUE); |
|
| 104 | +}while ($var1 === TRUE); |
|
| 105 | 105 | |
| 106 | 106 | for ($var1 = 10; $var1; $var1--) { |
| 107 | 107 | } |
@@ -17,38 +17,38 @@ |
||
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Processes the tokens outside the scope. |
|
| 22 | - * |
|
| 23 | - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being processed. |
|
| 24 | - * @param int $stackPtr The position where this token was |
|
| 25 | - * found. |
|
| 26 | - * |
|
| 27 | - * @return void |
|
| 28 | - */ |
|
| 29 | - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) |
|
| 30 | - { |
|
| 31 | - $functionName = $phpcsFile->getDeclarationName($stackPtr); |
|
| 32 | - if ($functionName === null) { |
|
| 33 | - return; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - $errorData = [$functionName]; |
|
| 37 | - |
|
| 38 | - // Does this function claim to be magical? |
|
| 39 | - if (preg_match('|^__[^_]|', $functionName) !== 0) { |
|
| 40 | - $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; |
|
| 41 | - $phpcsFile->addError($error, $stackPtr, 'DoubleUnderscore', $errorData); |
|
| 42 | - |
|
| 43 | - $functionName = ltrim($functionName, '_'); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if (Common::isCamelCaps($functionName, false, true, false) === false) { |
|
| 47 | - $error = 'Function name "%s" is not in camel caps format'; |
|
| 48 | - $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - }//end processTokenOutsideScope() |
|
| 20 | + /** |
|
| 21 | + * Processes the tokens outside the scope. |
|
| 22 | + * |
|
| 23 | + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being processed. |
|
| 24 | + * @param int $stackPtr The position where this token was |
|
| 25 | + * found. |
|
| 26 | + * |
|
| 27 | + * @return void |
|
| 28 | + */ |
|
| 29 | + protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) |
|
| 30 | + { |
|
| 31 | + $functionName = $phpcsFile->getDeclarationName($stackPtr); |
|
| 32 | + if ($functionName === null) { |
|
| 33 | + return; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + $errorData = [$functionName]; |
|
| 37 | + |
|
| 38 | + // Does this function claim to be magical? |
|
| 39 | + if (preg_match('|^__[^_]|', $functionName) !== 0) { |
|
| 40 | + $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore'; |
|
| 41 | + $phpcsFile->addError($error, $stackPtr, 'DoubleUnderscore', $errorData); |
|
| 42 | + |
|
| 43 | + $functionName = ltrim($functionName, '_'); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if (Common::isCamelCaps($functionName, false, true, false) === false) { |
|
| 47 | + $error = 'Function name "%s" is not in camel caps format'; |
|
| 48 | + $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + }//end processTokenOutsideScope() |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | }//end class |
@@ -17,43 +17,43 @@ |
||
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Returns an array of tokens this test wants to listen for. |
|
| 22 | - * |
|
| 23 | - * @return array |
|
| 24 | - */ |
|
| 25 | - public function register() |
|
| 26 | - { |
|
| 27 | - return Tokens::$booleanOperators; |
|
| 28 | - |
|
| 29 | - }//end register() |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Processes this test, when one of its tokens is encountered. |
|
| 34 | - * |
|
| 35 | - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
|
| 36 | - * @param int $stackPtr The position of the current token |
|
| 37 | - * in the stack passed in $tokens. |
|
| 38 | - * |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - public function process(File $phpcsFile, $stackPtr) |
|
| 42 | - { |
|
| 43 | - $tokens = $phpcsFile->getTokens(); |
|
| 44 | - if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { |
|
| 45 | - foreach ($tokens[$stackPtr]['nested_parenthesis'] as $open => $close) { |
|
| 46 | - if (isset($tokens[$open]['parenthesis_owner']) === true) { |
|
| 47 | - // Any owner means we are not just a simple statement. |
|
| 48 | - return; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - $error = 'Boolean operators are not allowed outside of control structure conditions'; |
|
| 54 | - $phpcsFile->addError($error, $stackPtr, 'Found'); |
|
| 55 | - |
|
| 56 | - }//end process() |
|
| 20 | + /** |
|
| 21 | + * Returns an array of tokens this test wants to listen for. |
|
| 22 | + * |
|
| 23 | + * @return array |
|
| 24 | + */ |
|
| 25 | + public function register() |
|
| 26 | + { |
|
| 27 | + return Tokens::$booleanOperators; |
|
| 28 | + |
|
| 29 | + }//end register() |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Processes this test, when one of its tokens is encountered. |
|
| 34 | + * |
|
| 35 | + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
|
| 36 | + * @param int $stackPtr The position of the current token |
|
| 37 | + * in the stack passed in $tokens. |
|
| 38 | + * |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + public function process(File $phpcsFile, $stackPtr) |
|
| 42 | + { |
|
| 43 | + $tokens = $phpcsFile->getTokens(); |
|
| 44 | + if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { |
|
| 45 | + foreach ($tokens[$stackPtr]['nested_parenthesis'] as $open => $close) { |
|
| 46 | + if (isset($tokens[$open]['parenthesis_owner']) === true) { |
|
| 47 | + // Any owner means we are not just a simple statement. |
|
| 48 | + return; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + $error = 'Boolean operators are not allowed outside of control structure conditions'; |
|
| 54 | + $phpcsFile->addError($error, $stackPtr, 'Found'); |
|
| 55 | + |
|
| 56 | + }//end process() |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | }//end class |
@@ -16,38 +16,38 @@ |
||
| 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 [T_GLOBAL]; |
|
| 27 | - |
|
| 28 | - }//end register() |
|
| 29 | - |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Processes this test, when one of its tokens is encountered. |
|
| 33 | - * |
|
| 34 | - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
|
| 35 | - * @param int $stackPtr The position of the current token in the |
|
| 36 | - * stack passed in $tokens. |
|
| 37 | - * |
|
| 38 | - * @return void |
|
| 39 | - */ |
|
| 40 | - public function process(File $phpcsFile, $stackPtr) |
|
| 41 | - { |
|
| 42 | - $tokens = $phpcsFile->getTokens(); |
|
| 43 | - |
|
| 44 | - $nextVar = $tokens[$phpcsFile->findNext([T_VARIABLE], $stackPtr)]; |
|
| 45 | - $varName = str_replace('$', '', $nextVar['content']); |
|
| 46 | - $error = 'Use of the "global" keyword is forbidden; use "$GLOBALS[\'%s\']" instead'; |
|
| 47 | - $data = [$varName]; |
|
| 48 | - $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); |
|
| 49 | - |
|
| 50 | - }//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 [T_GLOBAL]; |
|
| 27 | + |
|
| 28 | + }//end register() |
|
| 29 | + |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Processes this test, when one of its tokens is encountered. |
|
| 33 | + * |
|
| 34 | + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
|
| 35 | + * @param int $stackPtr The position of the current token in the |
|
| 36 | + * stack passed in $tokens. |
|
| 37 | + * |
|
| 38 | + * @return void |
|
| 39 | + */ |
|
| 40 | + public function process(File $phpcsFile, $stackPtr) |
|
| 41 | + { |
|
| 42 | + $tokens = $phpcsFile->getTokens(); |
|
| 43 | + |
|
| 44 | + $nextVar = $tokens[$phpcsFile->findNext([T_VARIABLE], $stackPtr)]; |
|
| 45 | + $varName = str_replace('$', '', $nextVar['content']); |
|
| 46 | + $error = 'Use of the "global" keyword is forbidden; use "$GLOBALS[\'%s\']" instead'; |
|
| 47 | + $data = [$varName]; |
|
| 48 | + $phpcsFile->addError($error, $stackPtr, 'NotAllowed', $data); |
|
| 49 | + |
|
| 50 | + }//end process() |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | }//end class |