Completed
Pull Request — master (#37)
by
unknown
07:28
created
src/Standards/BestIt/Sniffs/Formatting/ClassSortingSniff.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -116,19 +116,19 @@  discard block
 block discarded – undo
116 116
         $lastVisibility = null;
117 117
         $lastVisibilityEnd = -1;
118 118
 
119
-        for ($i = $position; $i < $endPosition; $i++){
119
+        for ($i = $position; $i < $endPosition; $i++) {
120 120
             if ($tokens[$i]['type'] === 'T_CONST') {
121 121
                 $classElements[] = [
122 122
                     'type' => 'T_CONST',
123 123
                     'visibility' => $i <= $lastVisibilityEnd ? $lastVisibility : 'T_PUBLIC',
124 124
                     'name' => $tokens[$file->findNext(T_STRING, $i)]['content']
125 125
                 ];
126
-            } elseif($tokens[$i]['type'] === 'T_FUNCTION'){
126
+            } elseif ($tokens[$i]['type'] === 'T_FUNCTION') {
127 127
                 $type = 'T_FUNCTION';
128 128
                 $name = $tokens[$file->findNext(T_STRING, $i)]['content'];
129
-                if (strcasecmp($name, '__destruct') === 0){
129
+                if (strcasecmp($name, '__destruct') === 0) {
130 130
                     $type .= '-DESTRUCT';
131
-                } elseif (strcasecmp($name, '__construct') === 0){
131
+                } elseif (strcasecmp($name, '__construct') === 0) {
132 132
                     $type .= '-CONSTRUCT';
133 133
                 }
134 134
 
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
                 ];
140 140
                 $functionStart = $i;
141 141
                 $functionEnd = $file->findEndOfStatement($i);
142
-            } elseif ($tokens[$i]['type'] === 'T_VARIABLE' && ($i < $functionStart || $i > $functionEnd)){
142
+            } elseif ($tokens[$i]['type'] === 'T_VARIABLE' && ($i < $functionStart || $i > $functionEnd)) {
143 143
                 $classElements[] = [
144 144
                     'type' => 'T_VARIABLE',
145 145
                     'visibility' => $i <= $lastVisibilityEnd ? $lastVisibility : 'T_PUBLIC',
146 146
                     'name' => $tokens[$i]['content']
147 147
                 ];
148
-            } elseif (in_array($tokens[$i]['type'], ['T_PRIVATE', 'T_PROTECTED', 'T_PUBLIC'])){
148
+            } elseif (in_array($tokens[$i]['type'], ['T_PRIVATE', 'T_PROTECTED', 'T_PUBLIC'])) {
149 149
                 $lastVisibility = $tokens[$i]['type'];
150 150
                 $lastVisibilityEnd = $file->findEndOfStatement($i);
151 151
             }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $originalClassElements = $classElements;
155 155
         usort($classElements, [$this, 'sort']);
156 156
 
157
-        if ($classElements !== $originalClassElements){
157
+        if ($classElements !== $originalClassElements) {
158 158
             self::throwError($file, $position);
159 159
         }
160 160
     }
Please login to merge, or discard this patch.