Passed
Pull Request — master (#154)
by Fabien
02:30
created
src/Codor/Sniffs/Classes/PropertyDeclarationSniff.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Codor\Sniffs\Classes;
4 4
 
@@ -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
     /**
@@ -114,20 +114,20 @@  discard block
 block discarded – undo
114 114
         $count = count($tokens);
115 115
 
116 116
         for ($i = $index + 1; $i < $count; $i++) {
117
-            $possibleVariable = $tokens[$i];
117
+            $possibleVariable = $tokens[ $i ];
118 118
 
119
-            if ($possibleVariable['type'] === 'T_CONST'
120
-                || $possibleVariable['type'] === 'T_FUNCTION'
121
-                || $possibleVariable['type'] === 'T_SEMICOLON'
119
+            if ($possibleVariable[ 'type' ] === 'T_CONST'
120
+                || $possibleVariable[ 'type' ] === 'T_FUNCTION'
121
+                || $possibleVariable[ 'type' ] === 'T_SEMICOLON'
122 122
             ) {
123 123
                 return;
124 124
             }
125 125
 
126
-            if ($possibleVariable['type'] !== 'T_VARIABLE') {
126
+            if ($possibleVariable[ 'type' ] !== 'T_VARIABLE') {
127 127
                 continue;
128 128
             }
129 129
 
130
-            $this->memberVars[] = str_replace('$', '', $possibleVariable['content']);
130
+            $this->memberVars[ ] = str_replace('$', '', $possibleVariable[ 'content' ]);
131 131
             return;
132 132
         }
133 133
     }
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
      */
141 141
     protected function handleObjectOperatorToken($tokens, $index)
142 142
     {
143
-        $previousToken = $tokens[$index-1];
144
-        $nextToken = $tokens[$index+1];
145
-        $tokenAfterNext = $tokens[$index+2];
143
+        $previousToken = $tokens[ $index - 1 ];
144
+        $nextToken = $tokens[ $index + 1 ];
145
+        $tokenAfterNext = $tokens[ $index + 2 ];
146 146
 
147
-        if ($previousToken['content'] !== '$this') {
147
+        if ($previousToken[ 'content' ] !== '$this') {
148 148
             return;
149 149
         }
150 150
 
151
-        if (($tokenAfterNext['type'] !== 'T_WHITESPACE') && ($tokenAfterNext['type'] !== 'T_EQUAL')) {
151
+        if (($tokenAfterNext[ 'type' ] !== 'T_WHITESPACE') && ($tokenAfterNext[ 'type' ] !== 'T_EQUAL')) {
152 152
             return;
153 153
         }
154 154
 
155
-        $this->referencedMemberVars[] = $nextToken['content'];
155
+        $this->referencedMemberVars[ ] = $nextToken[ 'content' ];
156 156
     }
157 157
 
158 158
     /**
Please login to merge, or discard this patch.