Completed
Push — master ( d4c835...dc124a )
by Bill
9s
created
src/Codor/Sniffs/Classes/ExtendsSniff.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public function register(): array
21 21
     {
22
-        return [T_CLASS];
22
+        return [ T_CLASS ];
23 23
     }
24 24
 
25 25
     /**
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
      */
47 47
     protected function handleToken($token)
48 48
     {
49
-        if ($token['type'] !== 'T_EXTENDS') {
49
+        if ($token[ 'type' ] !== 'T_EXTENDS') {
50 50
             return;
51 51
         }
52 52
         $warning = "Class extends another class - consider composition over inheritance.";
53
-        $this->phpcsFile->addWarning($warning, $token['line'], __CLASS__);
53
+        $this->phpcsFile->addWarning($warning, $token[ 'line' ], __CLASS__);
54 54
     }
55 55
 }
Please login to merge, or discard this patch.
src/Codor/Sniffs/Classes/FinalPrivateSniff.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public function register(): array
18 18
     {
19
-        return [T_CLASS];
19
+        return [ T_CLASS ];
20 20
     }
21 21
 
22 22
     /**
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
      * List of protected methods found.
30 30
      * @var array
31 31
      */
32
-    protected $protectedMethodTokens = [];
32
+    protected $protectedMethodTokens = [ ];
33 33
 
34 34
     /**
35 35
      * List of protected variables found.
36 36
      * @var array
37 37
      */
38
-    protected $protectedVariableTokens = [];
38
+    protected $protectedVariableTokens = [ ];
39 39
 
40 40
     /**
41 41
      * Processes the tokens that this sniff is interested in.
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
     public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
50 50
     {
51 51
         $this->classIsMarkedFinal = false;
52
-        $this->protectedMethodTokens = [];
53
-        $this->protectedVariableTokens = [];
52
+        $this->protectedMethodTokens = [ ];
53
+        $this->protectedVariableTokens = [ ];
54 54
 
55 55
         $tokens = $phpcsFile->getTokens();
56 56
 
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
      */
70 70
     protected function handleToken($tokens, $index)
71 71
     {
72
-        $tokenType = $tokens[$index]['type'];
72
+        $tokenType = $tokens[ $index ][ 'type' ];
73 73
 
74 74
         if ($tokenType === 'T_FINAL') {
75 75
             $this->classIsMarkedFinal = true;
76 76
             return;
77 77
         }
78 78
 
79
-        if (! $this->classIsMarkedFinal) {
79
+        if (!$this->classIsMarkedFinal) {
80 80
             return;
81 81
         }
82 82
 
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
      */
97 97
     protected function handleFoundProtectedElement($tokens, $index)
98 98
     {
99
-        $type = $tokens[$index+2]['type'];
99
+        $type = $tokens[ $index + 2 ][ 'type' ];
100 100
 
101 101
         if ($type === 'T_VARIABLE') {
102
-            $this->protectedVariableTokens[] = $tokens[$index+2];
102
+            $this->protectedVariableTokens[ ] = $tokens[ $index + 2 ];
103 103
             return;
104 104
         }
105 105
 
106
-        $this->protectedMethodTokens[] = $tokens[$index+4];
106
+        $this->protectedMethodTokens[ ] = $tokens[ $index + 4 ];
107 107
     }
108 108
 
109 109
     /**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
      */
132 132
     protected function handleProtectedMethodToken($token, $phpcsFile)
133 133
     {
134
-        $methodName = $token['content'];
135
-        $line = $token['line'];
134
+        $methodName = $token[ 'content' ];
135
+        $line = $token[ 'line' ];
136 136
         $phpcsFile->addError("Final Class contains a protected method {$methodName} - should be private.", $line, __CLASS__);
137 137
     }
138 138
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
      */
145 145
     protected function handleProtectedVariableToken($token, $phpcsFile)
146 146
     {
147
-        $variableName = $token['content'];
148
-        $line = $token['line'];
147
+        $variableName = $token[ 'content' ];
148
+        $line = $token[ 'line' ];
149 149
         $phpcsFile->addError("Final Class contains a protected variable {$variableName} - should be private.", $line, __CLASS__);
150 150
     }
151 151
 }
Please login to merge, or discard this patch.
src/Codor/Sniffs/Classes/ConstructorLoopSniff.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      * The loop tokens we're lookin for.
13 13
      * @var array
14 14
      */
15
-    protected $loops = ['T_FOR', 'T_FOREACH', 'T_WHILE'];
15
+    protected $loops = [ 'T_FOR', 'T_FOREACH', 'T_WHILE' ];
16 16
 
17 17
     /**
18 18
      * Returns the token types that this sniff is interested in.
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function register(): array
22 22
     {
23
-        return [T_FUNCTION];
23
+        return [ T_FUNCTION ];
24 24
     }
25 25
 
26 26
     /**
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
     public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
35 35
     {
36 36
         $tokens            = $phpcsFile->getTokens();
37
-        $token             = $tokens[$stackPtr];
38
-        $functionNameToken = $tokens[$stackPtr + 2];
39
-        $functionName      = $functionNameToken['content'];
37
+        $token             = $tokens[ $stackPtr ];
38
+        $functionNameToken = $tokens[ $stackPtr + 2 ];
39
+        $functionName      = $functionNameToken[ 'content' ];
40 40
 
41 41
         if ($functionName !== '__construct') {
42 42
             return;
43 43
         }
44 44
         // If this is an interface we don't check it.
45
-        if (! isset($token['scope_opener'])) {
45
+        if (!isset($token[ 'scope_opener' ])) {
46 46
             return;
47 47
         }
48 48
 
49
-        for ($index=$token['scope_opener']; $index <= $token['scope_closer']; $index++) {
50
-            if (in_array($tokens[$index]['type'], $this->loops)) {
49
+        for ($index = $token[ 'scope_opener' ]; $index <= $token[ 'scope_closer' ]; $index++) {
50
+            if (in_array($tokens[ $index ][ 'type' ], $this->loops)) {
51 51
                 $phpcsFile->addError("Class constructor cannot contain a loop.", $stackPtr, __CLASS__);
52 52
                 continue;
53 53
             }
Please login to merge, or discard this patch.
src/Codor/Sniffs/Classes/ClassLengthSniff.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function register(): array
23 23
     {
24
-        return [T_CLASS];
24
+        return [ T_CLASS ];
25 25
     }
26 26
 
27 27
     /**
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
     public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
36 36
     {
37 37
         $tokens = $phpcsFile->getTokens();
38
-        $token = $tokens[$stackPtr];
38
+        $token = $tokens[ $stackPtr ];
39 39
         
40
-        $openParenthesis = $tokens[$token['scope_opener']];
41
-        $closedParenthesis = $tokens[$token['scope_closer']];
40
+        $openParenthesis = $tokens[ $token[ 'scope_opener' ] ];
41
+        $closedParenthesis = $tokens[ $token[ 'scope_closer' ] ];
42 42
 
43
-        $length = $closedParenthesis['line'] - $openParenthesis['line'];
43
+        $length = $closedParenthesis[ 'line' ] - $openParenthesis[ 'line' ];
44 44
 
45 45
         if ($length > $this->maxLength) {
46 46
             $phpcsFile->addError("Class is {$length} lines. Must be {$this->maxLength} lines or fewer.", $stackPtr, __CLASS__);
Please login to merge, or discard this patch.
src/Codor/Sniffs/ControlStructures/NoElseSniff.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function register(): array
19 19
     {
20
-        return [T_ELSE, T_ELSEIF];
20
+        return [ T_ELSE, T_ELSEIF ];
21 21
     }
22 22
 
23 23
     /**
@@ -30,6 +30,6 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
32 32
     {
33
-        $phpcsFile->addError('Do not use "else" or "elseif"', $stackPtr,  __CLASS__);
33
+        $phpcsFile->addError('Do not use "else" or "elseif"', $stackPtr, __CLASS__);
34 34
     }
35 35
 }
Please login to merge, or discard this patch.
src/Codor/Sniffs/ControlStructures/NestedIfSniff.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      */
15 15
     public function register(): array
16 16
     {
17
-        return [T_IF];
17
+        return [ T_IF ];
18 18
     }
19 19
 
20 20
     /**
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
     {
42 42
         $this->phpcsFile = $phpcsFile;
43 43
         $tokens          = $phpcsFile->getTokens();
44
-        $token           = $tokens[$stackPtr];
45
-        $start           = $token['scope_opener'];
46
-        $end             = $token['scope_closer'];
44
+        $token           = $tokens[ $stackPtr ];
45
+        $start           = $token[ 'scope_opener' ];
46
+        $end             = $token[ 'scope_closer' ];
47 47
 
48
-        $this->errorStack = [];
49
-        for ($index=$start; $index <= $end; $index++) {
50
-            $this->checkForNestedIf($tokens[$index], $stackPtr);
48
+        $this->errorStack = [ ];
49
+        for ($index = $start; $index <= $end; $index++) {
50
+            $this->checkForNestedIf($tokens[ $index ], $stackPtr);
51 51
         }
52 52
     }
53 53
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     protected function checkForNestedIf(array $token, int $stackPtr)
61 61
     {
62
-        if (! $this->isIfStatement($token)) {
62
+        if (!$this->isIfStatement($token)) {
63 63
             return;
64 64
         }
65 65
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         }
69 69
 
70 70
         $this->phpcsFile->addError('Nested if statement found.', $stackPtr, __CLASS__);
71
-        $this->errorStack[] = $stackPtr;
71
+        $this->errorStack[ ] = $stackPtr;
72 72
     }
73 73
 
74 74
     /**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     protected function isIfStatement(array $token): bool
95 95
     {
96
-        if ($token['type'] === 'T_IF') {
96
+        if ($token[ 'type' ] === 'T_IF') {
97 97
             return true;
98 98
         }
99 99
 
Please login to merge, or discard this patch.
src/Codor/Sniffs/Files/ReturnNullSniff.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      */
15 15
     public function register(): array
16 16
     {
17
-        return [T_RETURN];
17
+        return [ T_RETURN ];
18 18
     }
19 19
 
20 20
     /**
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
         $returnTokenIndex = $stackPtr;
31 31
 
32 32
         $scope = array_slice($tokens, $returnTokenIndex, null, true);
33
-        $semicolons = array_filter($scope, function ($token) {
34
-            return $token['type'] === 'T_SEMICOLON';
33
+        $semicolons = array_filter($scope, function($token) {
34
+            return $token[ 'type' ] === 'T_SEMICOLON';
35 35
         });
36 36
 
37 37
         $returnValueIndex = key($semicolons) - 1;
38 38
 
39
-        if ($scope[$returnValueIndex]['type'] === 'T_NULL') {
39
+        if ($scope[ $returnValueIndex ][ 'type' ] === 'T_NULL') {
40 40
             $error = "Return null value found.";
41 41
             $phpcsFile->addError($error, $returnValueIndex, __CLASS__);
42 42
         }
Please login to merge, or discard this patch.
src/Codor/Sniffs/Files/FunctionParameterSniff.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function register(): array
22 22
     {
23
-        return [T_FUNCTION];
23
+        return [ T_FUNCTION ];
24 24
     }
25 25
 
26 26
     /**
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
34 34
     public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
35 35
     {
36 36
         $tokens           = $phpcsFile->getTokens();
37
-        $token            = $tokens[$stackPtr];
38
-        $openParenIndex   = $token['parenthesis_opener'];
39
-        $closedParenIndex = $token['parenthesis_closer'];
37
+        $token            = $tokens[ $stackPtr ];
38
+        $openParenIndex   = $token[ 'parenthesis_opener' ];
39
+        $closedParenIndex = $token[ 'parenthesis_closer' ];
40 40
 
41 41
         $numberOfParameters = 0;
42
-        for ($index=$openParenIndex+1; $index <= $closedParenIndex; $index++) {
43
-            $tokens[$index]['type'] == 'T_VARIABLE' ? $numberOfParameters++ : null;
42
+        for ($index = $openParenIndex + 1; $index <= $closedParenIndex; $index++) {
43
+            $tokens[ $index ][ 'type' ] == 'T_VARIABLE' ? $numberOfParameters++ : null;
44 44
         }
45 45
 
46 46
         if ($numberOfParameters > $this->maxParameters) {
47
-            $phpcsFile->addError("Function has more than {$this->maxParameters} parameters. Please reduce.", $stackPtr, __CLASS__ . 'MoreThan');
47
+            $phpcsFile->addError("Function has more than {$this->maxParameters} parameters. Please reduce.", $stackPtr, __CLASS__.'MoreThan');
48 48
         }
49 49
 
50 50
         if ($numberOfParameters == $this->maxParameters) {
51
-            $phpcsFile->addWarning("Function has {$this->maxParameters} parameters.", $stackPtr, __CLASS__ . 'hasMax');
51
+            $phpcsFile->addWarning("Function has {$this->maxParameters} parameters.", $stackPtr, __CLASS__.'hasMax');
52 52
         }
53 53
     }
54 54
 }
Please login to merge, or discard this patch.
src/Codor/Sniffs/Files/MethodFlagParameterSniff.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      * The two token types we're looking for.
13 13
      * @var array
14 14
      */
15
-    protected $booleans = ['T_FALSE', 'T_TRUE'];
15
+    protected $booleans = [ 'T_FALSE', 'T_TRUE' ];
16 16
 
17 17
     /**
18 18
      * Returns the token types that this sniff is interested in.
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function register(): array
22 22
     {
23
-        return [T_FUNCTION];
23
+        return [ T_FUNCTION ];
24 24
     }
25 25
 
26 26
     /**
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $tokens           = $phpcsFile->getTokens();
37 37
 
38
-        $token            = $tokens[$stackPtr];
39
-        $openParenIndex   = $token['parenthesis_opener'];
40
-        $closedParenIndex = $token['parenthesis_closer'];
38
+        $token            = $tokens[ $stackPtr ];
39
+        $openParenIndex   = $token[ 'parenthesis_opener' ];
40
+        $closedParenIndex = $token[ 'parenthesis_closer' ];
41 41
 
42
-        for ($index=$openParenIndex+1; $index <= $closedParenIndex; $index++) {
43
-            if (in_array($tokens[$index]['type'], $this->booleans)) {
42
+        for ($index = $openParenIndex + 1; $index <= $closedParenIndex; $index++) {
43
+            if (in_array($tokens[ $index ][ 'type' ], $this->booleans)) {
44 44
                 $phpcsFile->addError("Function/method contains a flag parameter.", $stackPtr, __CLASS__);
45 45
                 continue;
46 46
             }
Please login to merge, or discard this patch.