Completed
Push — master ( 540cab...2d0943 )
by Bill
02:23 queued 01:04
created
src/Codor/Sniffs/Syntax/LinesAfterMethodSniff.php 1 patch
Spacing   +7 added lines, -7 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_FUNCTION];
17
+        return [ T_FUNCTION ];
18 18
     }
19 19
 
20 20
     /**
@@ -27,20 +27,20 @@  discard block
 block discarded – undo
27 27
     public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
28 28
     {
29 29
         $tokens = $phpcsFile->getTokens();
30
-        if (! isset($tokens[$stackPtr]['scope_closer'])) {
30
+        if (!isset($tokens[ $stackPtr ][ 'scope_closer' ])) {
31 31
             return;
32 32
         }
33 33
 
34
-        $endOfMethodIndex = $tokens[$stackPtr]['scope_closer'];
34
+        $endOfMethodIndex = $tokens[ $stackPtr ][ 'scope_closer' ];
35 35
 
36
-        for ($index=$endOfMethodIndex + 1; $index <= count($tokens); $index++) {
37
-            if ($tokens[$index]['type'] !== 'T_WHITESPACE') {
38
-                $nextCodeLine = $tokens[$index]['line'];
36
+        for ($index = $endOfMethodIndex + 1; $index <= count($tokens); $index++) {
37
+            if ($tokens[ $index ][ 'type' ] !== 'T_WHITESPACE') {
38
+                $nextCodeLine = $tokens[ $index ][ 'line' ];
39 39
                 break;
40 40
             }
41 41
         }
42 42
 
43
-        $linesBetween = $nextCodeLine - $tokens[$endOfMethodIndex]['line'] - 1;
43
+        $linesBetween = $nextCodeLine - $tokens[ $endOfMethodIndex ][ 'line' ] - 1;
44 44
 
45 45
         if ($linesBetween > 1) {
46 46
             $phpcsFile->addError("No more than 1 line after a method/function is allowed.", $stackPtr);
Please login to merge, or discard this patch.
src/Codor/Sniffs/Classes/PropertyDeclarationSniff.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@  discard block
 block discarded – undo
12 12
      * The decalred member variables in the class.
13 13
      * @var array
14 14
      */
15
-    protected $memberVars = [];
15
+    protected $memberVars = [ ];
16 16
 
17 17
     /**
18 18
      * The referenced member variables in the class.
19 19
      * @var array
20 20
      */
21
-    protected $referencedMemberVars = [];
21
+    protected $referencedMemberVars = [ ];
22 22
 
23 23
     /**
24 24
      * Visibility Tokens.
25 25
      * @var array
26 26
      */
27
-    protected $visibilityTokens = ['T_PRIVATE', 'T_PUBLIC', 'T_PROTECTED'];
27
+    protected $visibilityTokens = [ 'T_PRIVATE', 'T_PUBLIC', 'T_PROTECTED' ];
28 28
 
29 29
     /**
30 30
      * Holds the value if the class is extended or not.
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function register(): array
40 40
     {
41
-        return [T_CLASS];
41
+        return [ T_CLASS ];
42 42
     }
43 43
 
44 44
     /**
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
54 54
     {
55
-        $this->memberVars = [];
56
-        $this->referencedMemberVars = [];
55
+        $this->memberVars = [ ];
56
+        $this->referencedMemberVars = [ ];
57 57
         $tokens = $phpcsFile->getTokens();
58 58
         foreach ($tokens as $index => $token) {
59 59
             $this->handleToken($tokens, $index);
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
      */
75 75
     protected function handleToken($tokens, $index)
76 76
     {
77
-        $token = $tokens[$index];
77
+        $token = $tokens[ $index ];
78 78
 
79
-        if ($token['type'] === 'T_EXTENDS') {
79
+        if ($token[ 'type' ] === 'T_EXTENDS') {
80 80
             $this->isExtendedClass = true;
81 81
             return;
82 82
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         }
88 88
 
89 89
 
90
-        if ($token['type'] === 'T_OBJECT_OPERATOR') {
90
+        if ($token[ 'type' ] === 'T_OBJECT_OPERATOR') {
91 91
             $this->handleObjectOperatorToken($tokens, $index);
92 92
             return;
93 93
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      */
101 101
     protected function isVisibilityToken($token): bool
102 102
     {
103
-        return in_array($token['type'], $this->visibilityTokens);
103
+        return in_array($token[ 'type' ], $this->visibilityTokens);
104 104
     }
105 105
 
106 106
     /**
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
      */
112 112
     protected function handleVisibilityToken($tokens, $index)
113 113
     {
114
-        $possibleVariable = $tokens[$index + 2];
115
-        if ($possibleVariable['type'] !== 'T_VARIABLE') {
114
+        $possibleVariable = $tokens[ $index + 2 ];
115
+        if ($possibleVariable[ 'type' ] !== 'T_VARIABLE') {
116 116
             return;
117 117
         }
118
-        $this->memberVars[] = str_replace('$', '', $possibleVariable['content']);
118
+        $this->memberVars[ ] = str_replace('$', '', $possibleVariable[ 'content' ]);
119 119
     }
120 120
 
121 121
     /**
@@ -126,19 +126,19 @@  discard block
 block discarded – undo
126 126
      */
127 127
     protected function handleObjectOperatorToken($tokens, $index)
128 128
     {
129
-        $previousToken = $tokens[$index-1];
130
-        $nextToken = $tokens[$index+1];
131
-        $tokenAfterNext = $tokens[$index+2];
129
+        $previousToken = $tokens[ $index - 1 ];
130
+        $nextToken = $tokens[ $index + 1 ];
131
+        $tokenAfterNext = $tokens[ $index + 2 ];
132 132
 
133
-        if ($previousToken['content'] !== '$this') {
133
+        if ($previousToken[ 'content' ] !== '$this') {
134 134
             return;
135 135
         }
136 136
 
137
-        if (($tokenAfterNext['type'] !== 'T_WHITESPACE') && ($tokenAfterNext['type'] !== 'T_EQUAL')) {
137
+        if (($tokenAfterNext[ 'type' ] !== 'T_WHITESPACE') && ($tokenAfterNext[ 'type' ] !== 'T_EQUAL')) {
138 138
             return;
139 139
         }
140 140
 
141
-        $this->referencedMemberVars[] = $nextToken['content'];
141
+        $this->referencedMemberVars[ ] = $nextToken[ 'content' ];
142 142
     }
143 143
 
144 144
     /**
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);
52 52
                 continue;
53 53
             }
Please login to merge, or discard this patch.
src/Codor/Sniffs/Classes/FinalPrivateSniff.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      */
14 14
     public function register(): array
15 15
     {
16
-        return [T_CLASS];
16
+        return [ T_CLASS ];
17 17
     }
18 18
 
19 19
     /**
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
      * List of protected methods found.
27 27
      * @var array
28 28
      */
29
-    protected $protectedMethods = [];
29
+    protected $protectedMethods = [ ];
30 30
 
31 31
     /**
32 32
      * List of protected variables found.
33 33
      * @var array
34 34
      */
35
-    protected $protectedVariables = [];
35
+    protected $protectedVariables = [ ];
36 36
 
37 37
     /**
38 38
      * Processes the tokens that this sniff is interested in.
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
      */
63 63
     protected function handleToken($tokens, $index)
64 64
     {
65
-        $tokenType = $tokens[$index]['type'];
65
+        $tokenType = $tokens[ $index ][ 'type' ];
66 66
 
67 67
         if ($tokenType === 'T_FINAL') {
68 68
             $this->classIsMarkedFinal = true;
69 69
             return;
70 70
         }
71 71
 
72
-        if (! $this->classIsMarkedFinal) {
72
+        if (!$this->classIsMarkedFinal) {
73 73
             return;
74 74
         }
75 75
 
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
      */
90 90
     protected function handleFoundProtectedElement($tokens, $index)
91 91
     {
92
-        $type = $tokens[$index+2]['type'];
92
+        $type = $tokens[ $index + 2 ][ 'type' ];
93 93
 
94 94
         if ($type === 'T_VARIABLE') {
95
-            $variableName = $tokens[$index+2]['content'];
96
-            $this->protectedVariables[] = $variableName;
95
+            $variableName = $tokens[ $index + 2 ][ 'content' ];
96
+            $this->protectedVariables[ ] = $variableName;
97 97
             return;
98 98
         }
99 99
 
100
-        $methodName = $tokens[$index+4]['content'];
101
-        $this->protectedMethods[] = $methodName;
100
+        $methodName = $tokens[ $index + 4 ][ 'content' ];
101
+        $this->protectedMethods[ ] = $methodName;
102 102
     }
103 103
 
104 104
     /**
Please login to merge, or discard this patch.