Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
PHPCompatibility/Sniffs/Keywords/ForbiddenNamesAsInvokedFunctionsSniff.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function register()
89 89
     {
90
-        $tokens   = array_keys($this->targetedTokens);
91
-        $tokens[] = \T_STRING;
90
+        $tokens   = array_keys( $this->targetedTokens );
91
+        $tokens[ ] = \T_STRING;
92 92
 
93 93
         return $tokens;
94 94
     }
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @return void
104 104
      */
105
-    public function process(File $phpcsFile, $stackPtr)
105
+    public function process( File $phpcsFile, $stackPtr )
106 106
     {
107 107
         $tokens         = $phpcsFile->getTokens();
108
-        $tokenCode      = $tokens[$stackPtr]['code'];
109
-        $tokenContentLc = strtolower($tokens[$stackPtr]['content']);
108
+        $tokenCode      = $tokens[ $stackPtr ][ 'code' ];
109
+        $tokenContentLc = strtolower( $tokens[ $stackPtr ][ 'content' ] );
110 110
         $isString       = false;
111 111
 
112 112
         /*
@@ -115,26 +115,26 @@  discard block
 block discarded – undo
115 115
          * token doesn't exist yet for that keyword or in later versions when the
116 116
          * token is used in a method invocation.
117 117
          */
118
-        if ($tokenCode === \T_STRING
119
-            && (isset($this->targetedStringTokens[$tokenContentLc]) === false)
118
+        if ( $tokenCode === \T_STRING
119
+            && ( isset( $this->targetedStringTokens[ $tokenContentLc ] ) === false )
120 120
         ) {
121 121
             return;
122 122
         }
123 123
 
124
-        if ($tokenCode === \T_STRING) {
124
+        if ( $tokenCode === \T_STRING ) {
125 125
             $isString = true;
126 126
         }
127 127
 
128 128
         // Make sure this is a function call.
129
-        $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
130
-        if ($next === false || $tokens[$next]['code'] !== \T_OPEN_PARENTHESIS) {
129
+        $next = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
130
+        if ( $next === false || $tokens[ $next ][ 'code' ] !== \T_OPEN_PARENTHESIS ) {
131 131
             // Not a function call.
132 132
             return;
133 133
         }
134 134
 
135 135
         // This sniff isn't concerned about function declarations.
136
-        $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
137
-        if ($prev !== false && $tokens[$prev]['code'] === \T_FUNCTION) {
136
+        $prev = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
137
+        if ( $prev !== false && $tokens[ $prev ][ 'code' ] === \T_FUNCTION ) {
138 138
             return;
139 139
         }
140 140
 
@@ -145,37 +145,37 @@  discard block
 block discarded – undo
145 145
          *
146 146
          * Only needed for those keywords which we sniff out via T_STRING.
147 147
          */
148
-        if (($tokens[$prev]['code'] === \T_OBJECT_OPERATOR || $tokens[$prev]['code'] === \T_DOUBLE_COLON)
149
-            && $this->supportsBelow('5.6') === false
148
+        if ( ( $tokens[ $prev ][ 'code' ] === \T_OBJECT_OPERATOR || $tokens[ $prev ][ 'code' ] === \T_DOUBLE_COLON )
149
+            && $this->supportsBelow( '5.6' ) === false
150 150
         ) {
151 151
             return;
152 152
         }
153 153
 
154 154
         // For the word catch, it is valid to have an open parenthesis
155 155
         // after it, but only if it is preceded by a right curly brace.
156
-        if ($tokenCode === \T_CATCH) {
157
-            if ($prev !== false && $tokens[$prev]['code'] === \T_CLOSE_CURLY_BRACKET) {
156
+        if ( $tokenCode === \T_CATCH ) {
157
+            if ( $prev !== false && $tokens[ $prev ][ 'code' ] === \T_CLOSE_CURLY_BRACKET ) {
158 158
                 // Ok, it's fine.
159 159
                 return;
160 160
             }
161 161
         }
162 162
 
163
-        if ($isString === true) {
164
-            $version = $this->targetedStringTokens[$tokenContentLc];
163
+        if ( $isString === true ) {
164
+            $version = $this->targetedStringTokens[ $tokenContentLc ];
165 165
         } else {
166
-            $version = $this->targetedTokens[$tokenCode];
166
+            $version = $this->targetedTokens[ $tokenCode ];
167 167
         }
168 168
 
169
-        if ($this->supportsAbove($version)) {
169
+        if ( $this->supportsAbove( $version ) ) {
170 170
             $error     = "'%s' is a reserved keyword introduced in PHP version %s and cannot be invoked as a function (%s)";
171
-            $errorCode = $this->stringToErrorCode($tokenContentLc) . 'Found';
171
+            $errorCode = $this->stringToErrorCode( $tokenContentLc ) . 'Found';
172 172
             $data      = array(
173 173
                 $tokenContentLc,
174 174
                 $version,
175
-                $tokens[$stackPtr]['type'],
175
+                $tokens[ $stackPtr ][ 'type' ],
176 176
             );
177 177
 
178
-            $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
178
+            $phpcsFile->addError( $error, $stackPtr, $errorCode, $data );
179 179
         }
180 180
     }
181 181
 }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Keywords/ForbiddenNamesAsDeclaredSniff.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     public function register()
97 97
     {
98 98
         // Do the list merge only once.
99
-        $this->allForbiddenNames = array_merge($this->forbiddenNames, $this->softReservedNames);
99
+        $this->allForbiddenNames = array_merge( $this->forbiddenNames, $this->softReservedNames );
100 100
 
101 101
         $targets = array(
102 102
             \T_CLASS,
@@ -119,94 +119,94 @@  discard block
 block discarded – undo
119 119
      *
120 120
      * @return void
121 121
      */
122
-    public function process(File $phpcsFile, $stackPtr)
122
+    public function process( File $phpcsFile, $stackPtr )
123 123
     {
124
-        if ($this->supportsAbove('7.0') === false) {
124
+        if ( $this->supportsAbove( '7.0' ) === false ) {
125 125
             return;
126 126
         }
127 127
 
128 128
         $tokens         = $phpcsFile->getTokens();
129
-        $tokenCode      = $tokens[$stackPtr]['code'];
130
-        $tokenType      = $tokens[$stackPtr]['type'];
131
-        $tokenContentLc = strtolower($tokens[$stackPtr]['content']);
129
+        $tokenCode      = $tokens[ $stackPtr ][ 'code' ];
130
+        $tokenType      = $tokens[ $stackPtr ][ 'type' ];
131
+        $tokenContentLc = strtolower( $tokens[ $stackPtr ][ 'content' ] );
132 132
 
133 133
         // For string tokens we only care about 'trait' as that is the only one
134 134
         // which may not be correctly recognized as it's own token.
135 135
         // This only happens in older versions of PHP where the token doesn't exist yet as a keyword.
136
-        if ($tokenCode === \T_STRING && $tokenContentLc !== 'trait') {
136
+        if ( $tokenCode === \T_STRING && $tokenContentLc !== 'trait' ) {
137 137
             return;
138 138
         }
139 139
 
140
-        if (\in_array($tokenType, array('T_CLASS', 'T_INTERFACE', 'T_TRAIT'), true)) {
140
+        if ( \in_array( $tokenType, array( 'T_CLASS', 'T_INTERFACE', 'T_TRAIT' ), true ) ) {
141 141
             // Check for the declared name being a name which is not tokenized as T_STRING.
142
-            $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
143
-            if ($nextNonEmpty !== false && isset($this->forbiddenTokens[$tokens[$nextNonEmpty]['code']]) === true) {
144
-                $name = $tokens[$nextNonEmpty]['content'];
142
+            $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
143
+            if ( $nextNonEmpty !== false && isset( $this->forbiddenTokens[ $tokens[ $nextNonEmpty ][ 'code' ] ] ) === true ) {
144
+                $name = $tokens[ $nextNonEmpty ][ 'content' ];
145 145
             } else {
146 146
                 // Get the declared name if it's a T_STRING.
147
-                $name = $phpcsFile->getDeclarationName($stackPtr);
147
+                $name = $phpcsFile->getDeclarationName( $stackPtr );
148 148
             }
149
-            unset($nextNonEmpty);
149
+            unset( $nextNonEmpty );
150 150
 
151
-            if (isset($name) === false || \is_string($name) === false || $name === '') {
151
+            if ( isset( $name ) === false || \is_string( $name ) === false || $name === '' ) {
152 152
                 return;
153 153
             }
154 154
 
155
-            $nameLc = strtolower($name);
156
-            if (isset($this->allForbiddenNames[$nameLc]) === false) {
155
+            $nameLc = strtolower( $name );
156
+            if ( isset( $this->allForbiddenNames[ $nameLc ] ) === false ) {
157 157
                 return;
158 158
             }
159 159
 
160
-        } elseif ($tokenCode === \T_NAMESPACE) {
161
-            $namespaceName = $this->getDeclaredNamespaceName($phpcsFile, $stackPtr);
160
+        } elseif ( $tokenCode === \T_NAMESPACE ) {
161
+            $namespaceName = $this->getDeclaredNamespaceName( $phpcsFile, $stackPtr );
162 162
 
163
-            if ($namespaceName === false || $namespaceName === '') {
163
+            if ( $namespaceName === false || $namespaceName === '' ) {
164 164
                 return;
165 165
             }
166 166
 
167
-            $namespaceParts = explode('\\', $namespaceName);
168
-            foreach ($namespaceParts as $namespacePart) {
169
-                $partLc = strtolower($namespacePart);
170
-                if (isset($this->allForbiddenNames[$partLc]) === true) {
167
+            $namespaceParts = explode( '\\', $namespaceName );
168
+            foreach ( $namespaceParts as $namespacePart ) {
169
+                $partLc = strtolower( $namespacePart );
170
+                if ( isset( $this->allForbiddenNames[ $partLc ] ) === true ) {
171 171
                     $name   = $namespacePart;
172 172
                     $nameLc = $partLc;
173 173
                     break;
174 174
                 }
175 175
             }
176
-        } elseif ($tokenCode === \T_STRING) {
176
+        } elseif ( $tokenCode === \T_STRING ) {
177 177
             // Traits which are not yet tokenized as T_TRAIT.
178
-            $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
179
-            if ($nextNonEmpty === false) {
178
+            $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
179
+            if ( $nextNonEmpty === false ) {
180 180
                 return;
181 181
             }
182 182
 
183
-            $nextNonEmptyCode = $tokens[$nextNonEmpty]['code'];
183
+            $nextNonEmptyCode = $tokens[ $nextNonEmpty ][ 'code' ];
184 184
 
185
-            if ($nextNonEmptyCode !== \T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) {
186
-                $name   = $tokens[$nextNonEmpty]['content'];
187
-                $nameLc = strtolower($tokens[$nextNonEmpty]['content']);
188
-            } elseif ($nextNonEmptyCode === \T_STRING) {
189
-                $endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_OPEN_CURLY_BRACKET), ($stackPtr + 1));
190
-                if ($endOfStatement === false) {
185
+            if ( $nextNonEmptyCode !== \T_STRING && isset( $this->forbiddenTokens[ $nextNonEmptyCode ] ) === true ) {
186
+                $name   = $tokens[ $nextNonEmpty ][ 'content' ];
187
+                $nameLc = strtolower( $tokens[ $nextNonEmpty ][ 'content' ] );
188
+            } elseif ( $nextNonEmptyCode === \T_STRING ) {
189
+                $endOfStatement = $phpcsFile->findNext( array( \T_SEMICOLON, \T_OPEN_CURLY_BRACKET ), ( $stackPtr + 1 ) );
190
+                if ( $endOfStatement === false ) {
191 191
                     return;
192 192
                 }
193 193
 
194 194
                 do {
195
-                    $nextNonEmptyLc = strtolower($tokens[$nextNonEmpty]['content']);
195
+                    $nextNonEmptyLc = strtolower( $tokens[ $nextNonEmpty ][ 'content' ] );
196 196
 
197
-                    if (isset($this->allForbiddenNames[$nextNonEmptyLc]) === true) {
198
-                        $name   = $tokens[$nextNonEmpty]['content'];
197
+                    if ( isset( $this->allForbiddenNames[ $nextNonEmptyLc ] ) === true ) {
198
+                        $name   = $tokens[ $nextNonEmpty ][ 'content' ];
199 199
                         $nameLc = $nextNonEmptyLc;
200 200
                         break;
201 201
                     }
202 202
 
203
-                    $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), $endOfStatement, true);
204
-                } while ($nextNonEmpty !== false);
203
+                    $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $nextNonEmpty + 1 ), $endOfStatement, true );
204
+                } while ( $nextNonEmpty !== false );
205 205
             }
206
-            unset($nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement);
206
+            unset( $nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement );
207 207
         }
208 208
 
209
-        if (isset($name, $nameLc) === false) {
209
+        if ( isset( $name, $nameLc ) === false ) {
210 210
             return;
211 211
         }
212 212
 
@@ -214,35 +214,35 @@  discard block
 block discarded – undo
214 214
         // Build up the error message.
215 215
         $error     = "'%s' is a";
216 216
         $isError   = null;
217
-        $errorCode = $this->stringToErrorCode($nameLc) . 'Found';
217
+        $errorCode = $this->stringToErrorCode( $nameLc ) . 'Found';
218 218
         $data      = array(
219 219
             $nameLc,
220 220
         );
221 221
 
222
-        if (isset($this->softReservedNames[$nameLc]) === true
223
-            && $this->supportsAbove($this->softReservedNames[$nameLc]) === true
222
+        if ( isset( $this->softReservedNames[ $nameLc ] ) === true
223
+            && $this->supportsAbove( $this->softReservedNames[ $nameLc ] ) === true
224 224
         ) {
225 225
             $error  .= ' soft reserved keyword as of PHP version %s';
226 226
             $isError = false;
227
-            $data[]  = $this->softReservedNames[$nameLc];
227
+            $data[ ]  = $this->softReservedNames[ $nameLc ];
228 228
         }
229 229
 
230
-        if (isset($this->forbiddenNames[$nameLc]) === true
231
-            && $this->supportsAbove($this->forbiddenNames[$nameLc]) === true
230
+        if ( isset( $this->forbiddenNames[ $nameLc ] ) === true
231
+            && $this->supportsAbove( $this->forbiddenNames[ $nameLc ] ) === true
232 232
         ) {
233
-            if (isset($isError) === true) {
233
+            if ( isset( $isError ) === true ) {
234 234
                 $error .= ' and a';
235 235
             }
236 236
             $error  .= ' reserved keyword as of PHP version %s';
237 237
             $isError = true;
238
-            $data[]  = $this->forbiddenNames[$nameLc];
238
+            $data[ ]  = $this->forbiddenNames[ $nameLc ];
239 239
         }
240 240
 
241
-        if (isset($isError) === true) {
241
+        if ( isset( $isError ) === true ) {
242 242
             $error .= ' and should not be used to name a class, interface or trait or as part of a namespace (%s)';
243
-            $data[] = $tokens[$stackPtr]['type'];
243
+            $data[ ] = $tokens[ $stackPtr ][ 'type' ];
244 244
 
245
-            $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
245
+            $this->addMessage( $phpcsFile, $error, $stackPtr, $isError, $errorCode, $data );
246 246
         }
247 247
     }
248 248
 }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Keywords/CaseSensitiveKeywordsSniff.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,21 +52,21 @@
 block discarded – undo
52 52
      *
53 53
      * @return void
54 54
      */
55
-    public function process(File $phpcsFile, $stackPtr)
55
+    public function process( File $phpcsFile, $stackPtr )
56 56
     {
57
-        if ($this->supportsBelow('5.4') === false) {
57
+        if ( $this->supportsBelow( '5.4' ) === false ) {
58 58
             return;
59 59
         }
60 60
 
61 61
         $tokens         = $phpcsFile->getTokens();
62
-        $tokenContentLC = strtolower($tokens[$stackPtr]['content']);
62
+        $tokenContentLC = strtolower( $tokens[ $stackPtr ][ 'content' ] );
63 63
 
64
-        if ($tokenContentLC !== $tokens[$stackPtr]['content']) {
64
+        if ( $tokenContentLC !== $tokens[ $stackPtr ][ 'content' ] ) {
65 65
             $phpcsFile->addError(
66 66
                 'The keyword \'%s\' was treated in a case-sensitive fashion in certain cases in PHP 5.4 or earlier. Use the lowercase version for consistent support.',
67 67
                 $stackPtr,
68 68
                 'NonLowercaseFound',
69
-                array($tokenContentLC)
69
+                array( $tokenContentLC )
70 70
             );
71 71
         }
72 72
     }
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/Sniffs/Keywords/ForbiddenNamesSniff.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
     public function register()
137 137
     {
138 138
         $this->allowedModifiers           = Tokens::$scopeModifiers;
139
-        $this->allowedModifiers[\T_FINAL] = \T_FINAL;
139
+        $this->allowedModifiers[ \T_FINAL ] = \T_FINAL;
140 140
 
141 141
         $tokens = $this->targetedTokens;
142 142
 
143
-        if (\defined('T_ANON_CLASS')) {
144
-            $tokens[] = \T_ANON_CLASS;
143
+        if ( \defined( 'T_ANON_CLASS' ) ) {
144
+            $tokens[ ] = \T_ANON_CLASS;
145 145
         }
146 146
 
147 147
         return $tokens;
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
      *
157 157
      * @return void
158 158
      */
159
-    public function process(File $phpcsFile, $stackPtr)
159
+    public function process( File $phpcsFile, $stackPtr )
160 160
     {
161 161
         $tokens = $phpcsFile->getTokens();
162 162
 
163 163
         /*
164 164
          * We distinguish between the class, function and namespace names vs the define statements.
165 165
          */
166
-        if ($tokens[$stackPtr]['type'] === 'T_STRING') {
167
-            $this->processString($phpcsFile, $stackPtr, $tokens);
166
+        if ( $tokens[ $stackPtr ][ 'type' ] === 'T_STRING' ) {
167
+            $this->processString( $phpcsFile, $stackPtr, $tokens );
168 168
         } else {
169
-            $this->processNonString($phpcsFile, $stackPtr, $tokens);
169
+            $this->processNonString( $phpcsFile, $stackPtr, $tokens );
170 170
         }
171 171
     }
172 172
 
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
      *
182 182
      * @return void
183 183
      */
184
-    public function processNonString(File $phpcsFile, $stackPtr, $tokens)
184
+    public function processNonString( File $phpcsFile, $stackPtr, $tokens )
185 185
     {
186
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
187
-        if ($nextNonEmpty === false) {
186
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
187
+        if ( $nextNonEmpty === false ) {
188 188
             return;
189 189
         }
190 190
 
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
          * misidentified as `T_ANON_CLASS`.
194 194
          * In PHPCS < 2.3.4 these were tokenized as T_CLASS no matter what.
195 195
          */
196
-        if ($tokens[$stackPtr]['type'] === 'T_ANON_CLASS' || $tokens[$stackPtr]['type'] === 'T_CLASS') {
197
-            $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
198
-            if ($prevNonEmpty !== false && $tokens[$prevNonEmpty]['type'] === 'T_NEW') {
196
+        if ( $tokens[ $stackPtr ][ 'type' ] === 'T_ANON_CLASS' || $tokens[ $stackPtr ][ 'type' ] === 'T_CLASS' ) {
197
+            $prevNonEmpty = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
198
+            if ( $prevNonEmpty !== false && $tokens[ $prevNonEmpty ][ 'type' ] === 'T_NEW' ) {
199 199
                 return;
200 200
             }
201 201
         }
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
          * - `use function HelloWorld` => move to the next token (HelloWorld) to verify.
206 206
          * - `use const HelloWorld` => move to the next token (HelloWorld) to verify.
207 207
          */
208
-        elseif ($tokens[$stackPtr]['type'] === 'T_USE'
209
-            && isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === true
208
+        elseif ( $tokens[ $stackPtr ][ 'type' ] === 'T_USE'
209
+            && isset( $this->validUseNames[ strtolower( $tokens[ $nextNonEmpty ][ 'content' ] ) ] ) === true
210 210
         ) {
211
-            $maybeUseNext = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
212
-            if ($maybeUseNext !== false && $this->isEndOfUseStatement($tokens[$maybeUseNext]) === false) {
211
+            $maybeUseNext = $phpcsFile->findNext( Tokens::$emptyTokens, ( $nextNonEmpty + 1 ), null, true, null, true );
212
+            if ( $maybeUseNext !== false && $this->isEndOfUseStatement( $tokens[ $maybeUseNext ] ) === false ) {
213 213
                 $nextNonEmpty = $maybeUseNext;
214 214
             }
215 215
         }
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
          * - `use HelloWorld { sayHello as protected; }` => valid, bow out.
220 220
          * - `use HelloWorld { sayHello as private myPrivateHello; }` => move to the next token to verify.
221 221
          */
222
-        elseif ($tokens[$stackPtr]['type'] === 'T_AS'
223
-            && isset($this->allowedModifiers[$tokens[$nextNonEmpty]['code']]) === true
224
-            && $phpcsFile->hasCondition($stackPtr, \T_USE) === true
222
+        elseif ( $tokens[ $stackPtr ][ 'type' ] === 'T_AS'
223
+            && isset( $this->allowedModifiers[ $tokens[ $nextNonEmpty ][ 'code' ] ] ) === true
224
+            && $phpcsFile->hasCondition( $stackPtr, \T_USE ) === true
225 225
         ) {
226
-            $maybeUseNext = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
227
-            if ($maybeUseNext === false || $this->isEndOfUseStatement($tokens[$maybeUseNext]) === true) {
226
+            $maybeUseNext = $phpcsFile->findNext( Tokens::$emptyTokens, ( $nextNonEmpty + 1 ), null, true, null, true );
227
+            if ( $maybeUseNext === false || $this->isEndOfUseStatement( $tokens[ $maybeUseNext ] ) === true ) {
228 228
                 return;
229 229
             }
230 230
 
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
         /*
235 235
          * Deal with functions declared to return by reference.
236 236
          */
237
-        elseif ($tokens[$stackPtr]['type'] === 'T_FUNCTION'
238
-            && $tokens[$nextNonEmpty]['type'] === 'T_BITWISE_AND'
237
+        elseif ( $tokens[ $stackPtr ][ 'type' ] === 'T_FUNCTION'
238
+            && $tokens[ $nextNonEmpty ][ 'type' ] === 'T_BITWISE_AND'
239 239
         ) {
240
-            $maybeUseNext = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true);
241
-            if ($maybeUseNext === false) {
240
+            $maybeUseNext = $phpcsFile->findNext( Tokens::$emptyTokens, ( $nextNonEmpty + 1 ), null, true, null, true );
241
+            if ( $maybeUseNext === false ) {
242 242
                 // Live coding.
243 243
                 return;
244 244
             }
@@ -249,38 +249,38 @@  discard block
 block discarded – undo
249 249
         /*
250 250
          * Deal with nested namespaces.
251 251
          */
252
-        elseif ($tokens[$stackPtr]['type'] === 'T_NAMESPACE') {
253
-            if ($tokens[$stackPtr + 1]['code'] === \T_NS_SEPARATOR) {
252
+        elseif ( $tokens[ $stackPtr ][ 'type' ] === 'T_NAMESPACE' ) {
253
+            if ( $tokens[ $stackPtr + 1 ][ 'code' ] === \T_NS_SEPARATOR ) {
254 254
                 // Not a namespace declaration, but use of, i.e. namespace\someFunction();
255 255
                 return;
256 256
             }
257 257
 
258
-            $endToken      = $phpcsFile->findNext(array(\T_SEMICOLON, \T_OPEN_CURLY_BRACKET), ($stackPtr + 1), null, false, null, true);
259
-            $namespaceName = trim($phpcsFile->getTokensAsString(($stackPtr + 1), ($endToken - $stackPtr - 1)));
260
-            if (empty($namespaceName) === true) {
258
+            $endToken      = $phpcsFile->findNext( array( \T_SEMICOLON, \T_OPEN_CURLY_BRACKET ), ( $stackPtr + 1 ), null, false, null, true );
259
+            $namespaceName = trim( $phpcsFile->getTokensAsString( ( $stackPtr + 1 ), ( $endToken - $stackPtr - 1 ) ) );
260
+            if ( empty( $namespaceName ) === true ) {
261 261
                 return;
262 262
             }
263 263
 
264
-            $namespaceParts = explode('\\', $namespaceName);
265
-            foreach ($namespaceParts as $namespacePart) {
266
-                $partLc = strtolower($namespacePart);
267
-                if (isset($this->invalidNames[$partLc]) === false) {
264
+            $namespaceParts = explode( '\\', $namespaceName );
265
+            foreach ( $namespaceParts as $namespacePart ) {
266
+                $partLc = strtolower( $namespacePart );
267
+                if ( isset( $this->invalidNames[ $partLc ] ) === false ) {
268 268
                     continue;
269 269
                 }
270 270
 
271 271
                 // Find the token position of the part which matched.
272
-                for ($i = ($stackPtr + 1); $i < $endToken; $i++) {
273
-                    if ($tokens[$i]['content'] === $namespacePart) {
272
+                for ( $i = ( $stackPtr + 1 ); $i < $endToken; $i++ ) {
273
+                    if ( $tokens[ $i ][ 'content' ] === $namespacePart ) {
274 274
                         $nextNonEmpty = $i;
275 275
                         break;
276 276
                     }
277 277
                 }
278 278
             }
279
-            unset($i, $namespacePart, $partLc);
279
+            unset( $i, $namespacePart, $partLc );
280 280
         }
281 281
 
282
-        $nextContentLc = strtolower($tokens[$nextNonEmpty]['content']);
283
-        if (isset($this->invalidNames[$nextContentLc]) === false) {
282
+        $nextContentLc = strtolower( $tokens[ $nextNonEmpty ][ 'content' ] );
283
+        if ( isset( $this->invalidNames[ $nextContentLc ] ) === false ) {
284 284
             return;
285 285
         }
286 286
 
@@ -289,22 +289,22 @@  discard block
 block discarded – undo
289 289
          * "As of PHP 7.0.0 these keywords are allowed as property, constant, and method names
290 290
          * of classes, interfaces and traits, except that class may not be used as constant name."
291 291
          */
292
-        if ((($tokens[$stackPtr]['type'] === 'T_FUNCTION'
293
-                && $this->inClassScope($phpcsFile, $stackPtr, false) === true)
294
-            || ($tokens[$stackPtr]['type'] === 'T_CONST'
295
-                && $this->isClassConstant($phpcsFile, $stackPtr) === true
296
-                && $nextContentLc !== 'class'))
297
-            && $this->supportsBelow('5.6') === false
292
+        if ( ( ( $tokens[ $stackPtr ][ 'type' ] === 'T_FUNCTION'
293
+                && $this->inClassScope( $phpcsFile, $stackPtr, false ) === true )
294
+            || ( $tokens[ $stackPtr ][ 'type' ] === 'T_CONST'
295
+                && $this->isClassConstant( $phpcsFile, $stackPtr ) === true
296
+                && $nextContentLc !== 'class' ) )
297
+            && $this->supportsBelow( '5.6' ) === false
298 298
         ) {
299 299
             return;
300 300
         }
301 301
 
302
-        if ($this->supportsAbove($this->invalidNames[$nextContentLc])) {
302
+        if ( $this->supportsAbove( $this->invalidNames[ $nextContentLc ] ) ) {
303 303
             $data = array(
304
-                $tokens[$nextNonEmpty]['content'],
305
-                $this->invalidNames[$nextContentLc],
304
+                $tokens[ $nextNonEmpty ][ 'content' ],
305
+                $this->invalidNames[ $nextContentLc ],
306 306
             );
307
-            $this->addError($phpcsFile, $stackPtr, $tokens[$nextNonEmpty]['content'], $data);
307
+            $this->addError( $phpcsFile, $stackPtr, $tokens[ $nextNonEmpty ][ 'content' ], $data );
308 308
         }
309 309
     }
310 310
 
@@ -319,40 +319,40 @@  discard block
 block discarded – undo
319 319
      *
320 320
      * @return void
321 321
      */
322
-    public function processString(File $phpcsFile, $stackPtr, $tokens)
322
+    public function processString( File $phpcsFile, $stackPtr, $tokens )
323 323
     {
324
-        $tokenContentLc = strtolower($tokens[$stackPtr]['content']);
324
+        $tokenContentLc = strtolower( $tokens[ $stackPtr ][ 'content' ] );
325 325
 
326 326
         /*
327 327
          * Special case for PHP versions where the target is not yet identified as
328 328
          * its own token, but presents as T_STRING.
329 329
          * - trait keyword in PHP < 5.4
330 330
          */
331
-        if (version_compare(\PHP_VERSION_ID, '50400', '<') && $tokenContentLc === 'trait') {
332
-            $this->processNonString($phpcsFile, $stackPtr, $tokens);
331
+        if ( version_compare( \PHP_VERSION_ID, '50400', '<' ) && $tokenContentLc === 'trait' ) {
332
+            $this->processNonString( $phpcsFile, $stackPtr, $tokens );
333 333
             return;
334 334
         }
335 335
 
336 336
         // Look for any define/defined tokens (both T_STRING ones, blame Tokenizer).
337
-        if ($tokenContentLc !== 'define' && $tokenContentLc !== 'defined') {
337
+        if ( $tokenContentLc !== 'define' && $tokenContentLc !== 'defined' ) {
338 338
             return;
339 339
         }
340 340
 
341 341
         // Retrieve the define(d) constant name.
342
-        $firstParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
343
-        if ($firstParam === false) {
342
+        $firstParam = $this->getFunctionCallParameter( $phpcsFile, $stackPtr, 1 );
343
+        if ( $firstParam === false ) {
344 344
             return;
345 345
         }
346 346
 
347
-        $defineName   = $this->stripQuotes($firstParam['raw']);
348
-        $defineNameLc = strtolower($defineName);
347
+        $defineName   = $this->stripQuotes( $firstParam[ 'raw' ] );
348
+        $defineNameLc = strtolower( $defineName );
349 349
 
350
-        if (isset($this->invalidNames[$defineNameLc]) && $this->supportsAbove($this->invalidNames[$defineNameLc])) {
350
+        if ( isset( $this->invalidNames[ $defineNameLc ] ) && $this->supportsAbove( $this->invalidNames[ $defineNameLc ] ) ) {
351 351
             $data = array(
352 352
                 $defineName,
353
-                $this->invalidNames[$defineNameLc],
353
+                $this->invalidNames[ $defineNameLc ],
354 354
             );
355
-            $this->addError($phpcsFile, $stackPtr, $defineNameLc, $data);
355
+            $this->addError( $phpcsFile, $stackPtr, $defineNameLc, $data );
356 356
         }
357 357
     }
358 358
 
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
      *
369 369
      * @return void
370 370
      */
371
-    protected function addError(File $phpcsFile, $stackPtr, $content, $data)
371
+    protected function addError( File $phpcsFile, $stackPtr, $content, $data )
372 372
     {
373 373
         $error     = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since version %s)";
374
-        $errorCode = $this->stringToErrorCode($content) . 'Found';
375
-        $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
374
+        $errorCode = $this->stringToErrorCode( $content ) . 'Found';
375
+        $phpcsFile->addError( $error, $stackPtr, $errorCode, $data );
376 376
     }
377 377
 
378 378
 
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
      *
385 385
      * @return bool
386 386
      */
387
-    protected function isEndOfUseStatement($token)
387
+    protected function isEndOfUseStatement( $token )
388 388
     {
389
-        return \in_array($token['code'], array(\T_CLOSE_CURLY_BRACKET, \T_SEMICOLON, \T_COMMA), true);
389
+        return \in_array( $token[ 'code' ], array( \T_CLOSE_CURLY_BRACKET, \T_SEMICOLON, \T_COMMA ), true );
390 390
     }
391 391
 }
Please login to merge, or discard this patch.
Sniffs/ControlStructures/DiscouragedSwitchContinueSniff.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $this->acceptedLevelTokens += Tokens::$arithmeticTokens;
77 77
         $this->acceptedLevelTokens += Tokens::$emptyTokens;
78 78
 
79
-        return array(\T_SWITCH);
79
+        return array( \T_SWITCH );
80 80
     }
81 81
 
82 82
     /**
@@ -88,43 +88,43 @@  discard block
 block discarded – undo
88 88
      *
89 89
      * @return void
90 90
      */
91
-    public function process(File $phpcsFile, $stackPtr)
91
+    public function process( File $phpcsFile, $stackPtr )
92 92
     {
93
-        if ($this->supportsAbove('7.3') === false) {
93
+        if ( $this->supportsAbove( '7.3' ) === false ) {
94 94
             return;
95 95
         }
96 96
 
97 97
         $tokens = $phpcsFile->getTokens();
98 98
 
99
-        if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
99
+        if ( isset( $tokens[ $stackPtr ][ 'scope_opener' ], $tokens[ $stackPtr ][ 'scope_closer' ] ) === false ) {
100 100
             return;
101 101
         }
102 102
 
103
-        $switchOpener = $tokens[$stackPtr]['scope_opener'];
104
-        $switchCloser = $tokens[$stackPtr]['scope_closer'];
103
+        $switchOpener = $tokens[ $stackPtr ][ 'scope_opener' ];
104
+        $switchCloser = $tokens[ $stackPtr ][ 'scope_closer' ];
105 105
 
106 106
         // Quick check whether we need to bother with the more complex logic.
107
-        $hasContinue = $phpcsFile->findNext(\T_CONTINUE, ($switchOpener + 1), $switchCloser);
108
-        if ($hasContinue === false) {
107
+        $hasContinue = $phpcsFile->findNext( \T_CONTINUE, ( $switchOpener + 1 ), $switchCloser );
108
+        if ( $hasContinue === false ) {
109 109
             return;
110 110
         }
111 111
 
112 112
         $caseDefault = $switchOpener;
113 113
 
114 114
         do {
115
-            $caseDefault = $phpcsFile->findNext($this->caseTokens, ($caseDefault + 1), $switchCloser);
116
-            if ($caseDefault === false) {
115
+            $caseDefault = $phpcsFile->findNext( $this->caseTokens, ( $caseDefault + 1 ), $switchCloser );
116
+            if ( $caseDefault === false ) {
117 117
                 break;
118 118
             }
119 119
 
120
-            if (isset($tokens[$caseDefault]['scope_opener']) === false) {
120
+            if ( isset( $tokens[ $caseDefault ][ 'scope_opener' ] ) === false ) {
121 121
                 // Unknown start of the case, skip.
122 122
                 continue;
123 123
             }
124 124
 
125
-            $caseOpener      = $tokens[$caseDefault]['scope_opener'];
126
-            $nextCaseDefault = $phpcsFile->findNext($this->caseTokens, ($caseDefault + 1), $switchCloser);
127
-            if ($nextCaseDefault === false) {
125
+            $caseOpener      = $tokens[ $caseDefault ][ 'scope_opener' ];
126
+            $nextCaseDefault = $phpcsFile->findNext( $this->caseTokens, ( $caseDefault + 1 ), $switchCloser );
127
+            if ( $nextCaseDefault === false ) {
128 128
                 $caseCloser = $switchCloser;
129 129
             } else {
130 130
                 $caseCloser = $nextCaseDefault;
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
             // Check for unscoped control structures within the case.
134 134
             $controlStructure = $caseOpener;
135 135
             $doCount          = 0;
136
-            while (($controlStructure = $phpcsFile->findNext($this->loopStructures, ($controlStructure + 1), $caseCloser)) !== false) {
137
-                if ($tokens[$controlStructure]['code'] === \T_DO) {
136
+            while ( ( $controlStructure = $phpcsFile->findNext( $this->loopStructures, ( $controlStructure + 1 ), $caseCloser ) ) !== false ) {
137
+                if ( $tokens[ $controlStructure ][ 'code' ] === \T_DO ) {
138 138
                     $doCount++;
139 139
                 }
140 140
 
141
-                if (isset($tokens[$controlStructure]['scope_opener'], $tokens[$controlStructure]['scope_closer']) === false) {
142
-                    if ($tokens[$controlStructure]['code'] === \T_WHILE && $doCount > 0) {
141
+                if ( isset( $tokens[ $controlStructure ][ 'scope_opener' ], $tokens[ $controlStructure ][ 'scope_closer' ] ) === false ) {
142
+                    if ( $tokens[ $controlStructure ][ 'code' ] === \T_WHILE && $doCount > 0 ) {
143 143
                         // While in a do-while construct.
144 144
                         $doCount--;
145 145
                         continue;
@@ -154,61 +154,61 @@  discard block
 block discarded – undo
154 154
             $continue = $caseOpener;
155 155
 
156 156
             do {
157
-                $continue = $phpcsFile->findNext(\T_CONTINUE, ($continue + 1), $caseCloser);
158
-                if ($continue === false) {
157
+                $continue = $phpcsFile->findNext( \T_CONTINUE, ( $continue + 1 ), $caseCloser );
158
+                if ( $continue === false ) {
159 159
                     break;
160 160
                 }
161 161
 
162
-                $nextSemicolon = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($continue + 1), $caseCloser);
162
+                $nextSemicolon = $phpcsFile->findNext( array( \T_SEMICOLON, \T_CLOSE_TAG ), ( $continue + 1 ), $caseCloser );
163 163
                 $codeString    = '';
164
-                for ($i = ($continue + 1); $i < $nextSemicolon; $i++) {
165
-                    if (isset($this->acceptedLevelTokens[$tokens[$i]['code']]) === false) {
164
+                for ( $i = ( $continue + 1 ); $i < $nextSemicolon; $i++ ) {
165
+                    if ( isset( $this->acceptedLevelTokens[ $tokens[ $i ][ 'code' ] ] ) === false ) {
166 166
                         // Function call/variable or other token which make numeric level impossible to determine.
167 167
                         continue 2;
168 168
                     }
169 169
 
170
-                    if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
170
+                    if ( isset( Tokens::$emptyTokens[ $tokens[ $i ][ 'code' ] ] ) === true ) {
171 171
                         continue;
172 172
                     }
173 173
 
174
-                    $codeString .= $tokens[$i]['content'];
174
+                    $codeString .= $tokens[ $i ][ 'content' ];
175 175
                 }
176 176
 
177 177
                 $level = null;
178
-                if ($codeString !== '') {
179
-                    if (is_numeric($codeString)) {
180
-                        $level = (int) $codeString;
178
+                if ( $codeString !== '' ) {
179
+                    if ( is_numeric( $codeString ) ) {
180
+                        $level = (int)$codeString;
181 181
                     } else {
182 182
                         // With the above logic, the string can only contain digits and operators, eval!
183
-                        $level = eval("return ( $codeString );");
183
+                        $level = eval( "return ( $codeString );" );
184 184
                     }
185 185
                 }
186 186
 
187
-                if (isset($level) === false || $level === 0) {
187
+                if ( isset( $level ) === false || $level === 0 ) {
188 188
                     $level = 1;
189 189
                 }
190 190
 
191 191
                 // Examine which control structure is being targeted by the continue statement.
192
-                if (isset($tokens[$continue]['conditions']) === false) {
192
+                if ( isset( $tokens[ $continue ][ 'conditions' ] ) === false ) {
193 193
                     continue;
194 194
                 }
195 195
 
196
-                $conditions = array_reverse($tokens[$continue]['conditions'], true);
196
+                $conditions = array_reverse( $tokens[ $continue ][ 'conditions' ], true );
197 197
                 // PHPCS adds more structures to the conditions array than we want to take into
198 198
                 // consideration, so clean up the array.
199
-                foreach ($conditions as $tokenPtr => $tokenCode) {
200
-                    if (isset($this->loopStructures[$tokenCode]) === false) {
201
-                        unset($conditions[$tokenPtr]);
199
+                foreach ( $conditions as $tokenPtr => $tokenCode ) {
200
+                    if ( isset( $this->loopStructures[ $tokenCode ] ) === false ) {
201
+                        unset( $conditions[ $tokenPtr ] );
202 202
                     }
203 203
                 }
204 204
 
205
-                $targetCondition = \array_slice($conditions, ($level - 1), 1, true);
206
-                if (empty($targetCondition)) {
205
+                $targetCondition = \array_slice( $conditions, ( $level - 1 ), 1, true );
206
+                if ( empty( $targetCondition ) ) {
207 207
                     continue;
208 208
                 }
209 209
 
210
-                $conditionToken = key($targetCondition);
211
-                if ($conditionToken === $stackPtr) {
210
+                $conditionToken = key( $targetCondition );
211
+                if ( $conditionToken === $stackPtr ) {
212 212
                     $phpcsFile->addWarning(
213 213
                         "Targeting a 'switch' control structure with a 'continue' statement is strongly discouraged and will throw a warning as of PHP 7.3.",
214 214
                         $continue,
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
                     );
217 217
                 }
218 218
 
219
-            } while ($continue < $caseCloser);
219
+            } while ( $continue < $caseCloser );
220 220
 
221
-        } while ($caseDefault < $switchCloser);
221
+        } while ( $caseDefault < $switchCloser );
222 222
     }
223 223
 }
Please login to merge, or discard this patch.
Sniffs/ControlStructures/ForbiddenBreakContinueVariableArgumentsSniff.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function register()
51 51
     {
52
-        return array(\T_BREAK, \T_CONTINUE);
52
+        return array( \T_BREAK, \T_CONTINUE );
53 53
     }
54 54
 
55 55
     /**
@@ -61,41 +61,41 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @return void
63 63
      */
64
-    public function process(File $phpcsFile, $stackPtr)
64
+    public function process( File $phpcsFile, $stackPtr )
65 65
     {
66
-        if ($this->supportsAbove('5.4') === false) {
66
+        if ( $this->supportsAbove( '5.4' ) === false ) {
67 67
             return;
68 68
         }
69 69
 
70 70
         $tokens             = $phpcsFile->getTokens();
71
-        $nextSemicolonToken = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr), null, false);
71
+        $nextSemicolonToken = $phpcsFile->findNext( array( \T_SEMICOLON, \T_CLOSE_TAG ), ( $stackPtr ), null, false );
72 72
         $errorType          = '';
73
-        for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
74
-            if ($tokens[$curToken]['type'] === 'T_STRING') {
73
+        for ( $curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++ ) {
74
+            if ( $tokens[ $curToken ][ 'type' ] === 'T_STRING' ) {
75 75
                 // If the next non-whitespace token after the string
76 76
                 // is an opening parenthesis then it's a function call.
77
-                $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, $curToken + 1, null, true);
78
-                if ($tokens[$openBracket]['code'] === \T_OPEN_PARENTHESIS) {
77
+                $openBracket = $phpcsFile->findNext( Tokens::$emptyTokens, $curToken + 1, null, true );
78
+                if ( $tokens[ $openBracket ][ 'code' ] === \T_OPEN_PARENTHESIS ) {
79 79
                     $errorType = 'variableArgument';
80 80
                     break;
81 81
                 }
82 82
 
83
-            } elseif (\in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) {
83
+            } elseif ( \in_array( $tokens[ $curToken ][ 'type' ], array( 'T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE' ), true ) ) {
84 84
                 $errorType = 'variableArgument';
85 85
                 break;
86 86
 
87
-            } elseif ($tokens[$curToken]['type'] === 'T_LNUMBER' && $tokens[$curToken]['content'] === '0') {
87
+            } elseif ( $tokens[ $curToken ][ 'type' ] === 'T_LNUMBER' && $tokens[ $curToken ][ 'content' ] === '0' ) {
88 88
                 $errorType = 'zeroArgument';
89 89
                 break;
90 90
             }
91 91
         }
92 92
 
93
-        if ($errorType !== '') {
93
+        if ( $errorType !== '' ) {
94 94
             $error     = 'Using %s on break or continue is forbidden since PHP 5.4';
95 95
             $errorCode = $errorType . 'Found';
96
-            $data      = array($this->errorTypes[$errorType]);
96
+            $data      = array( $this->errorTypes[ $errorType ] );
97 97
 
98
-            $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
98
+            $phpcsFile->addError( $error, $stackPtr, $errorCode, $data );
99 99
         }
100 100
     }
101 101
 }
Please login to merge, or discard this patch.
Sniffs/ControlStructures/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function register()
37 37
     {
38
-        return array(\T_SWITCH);
38
+        return array( \T_SWITCH );
39 39
     }
40 40
 
41 41
     /**
@@ -47,28 +47,28 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @return void
49 49
      */
50
-    public function process(File $phpcsFile, $stackPtr)
50
+    public function process( File $phpcsFile, $stackPtr )
51 51
     {
52
-        if ($this->supportsAbove('7.0') === false) {
52
+        if ( $this->supportsAbove( '7.0' ) === false ) {
53 53
             return;
54 54
         }
55 55
 
56 56
         $tokens = $phpcsFile->getTokens();
57
-        if (isset($tokens[$stackPtr]['scope_closer']) === false) {
57
+        if ( isset( $tokens[ $stackPtr ][ 'scope_closer' ] ) === false ) {
58 58
             return;
59 59
         }
60 60
 
61 61
         $defaultToken = $stackPtr;
62 62
         $defaultCount = 0;
63
-        $targetLevel  = $tokens[$stackPtr]['level'] + 1;
64
-        while ($defaultCount < 2 && ($defaultToken = $phpcsFile->findNext(array(\T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) !== false) {
63
+        $targetLevel  = $tokens[ $stackPtr ][ 'level' ] + 1;
64
+        while ( $defaultCount < 2 && ( $defaultToken = $phpcsFile->findNext( array( \T_DEFAULT ), $defaultToken + 1, $tokens[ $stackPtr ][ 'scope_closer' ] ) ) !== false ) {
65 65
             // Same level or one below (= two default cases after each other).
66
-            if ($tokens[$defaultToken]['level'] === $targetLevel || $tokens[$defaultToken]['level'] === ($targetLevel + 1)) {
66
+            if ( $tokens[ $defaultToken ][ 'level' ] === $targetLevel || $tokens[ $defaultToken ][ 'level' ] === ( $targetLevel + 1 ) ) {
67 67
                 $defaultCount++;
68 68
             }
69 69
         }
70 70
 
71
-        if ($defaultCount > 1) {
71
+        if ( $defaultCount > 1 ) {
72 72
             $phpcsFile->addError(
73 73
                 'Switch statements can not have multiple default blocks since PHP 7.0',
74 74
                 $stackPtr,
Please login to merge, or discard this patch.
Sniffs/ControlStructures/ForbiddenBreakContinueOutsideLoopSniff.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
      *
74 74
      * @return void
75 75
      */
76
-    public function process(File $phpcsFile, $stackPtr)
76
+    public function process( File $phpcsFile, $stackPtr )
77 77
     {
78 78
         $tokens = $phpcsFile->getTokens();
79
-        $token  = $tokens[$stackPtr];
79
+        $token  = $tokens[ $stackPtr ];
80 80
 
81 81
         // Check if the break/continue is within a valid loop structure.
82
-        if (empty($token['conditions']) === false) {
83
-            foreach ($token['conditions'] as $tokenCode) {
84
-                if (isset($this->validLoopStructures[$tokenCode]) === true) {
82
+        if ( empty( $token[ 'conditions' ] ) === false ) {
83
+            foreach ( $token[ 'conditions' ] as $tokenCode ) {
84
+                if ( isset( $this->validLoopStructures[ $tokenCode ] ) === true ) {
85 85
                     return;
86 86
                 }
87 87
             }
88 88
         } else {
89 89
             // Deal with older PHPCS versions.
90
-            if (isset($token['scope_condition']) === true && isset($this->backCompat[$tokens[$token['scope_condition']]['code']]) === true) {
90
+            if ( isset( $token[ 'scope_condition' ] ) === true && isset( $this->backCompat[ $tokens[ $token[ 'scope_condition' ] ][ 'code' ] ] ) === true ) {
91 91
                 return;
92 92
             }
93 93
         }
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
         $error     = "Using '%s' outside of a loop or switch structure is invalid";
97 97
         $isError   = false;
98 98
         $errorCode = 'Found';
99
-        $data      = array($token['content']);
99
+        $data      = array( $token[ 'content' ] );
100 100
 
101
-        if ($this->supportsAbove('7.0')) {
101
+        if ( $this->supportsAbove( '7.0' ) ) {
102 102
             $error    .= ' and will throw a fatal error since PHP 7.0';
103 103
             $isError   = true;
104 104
             $errorCode = 'FatalError';
105 105
         }
106 106
 
107
-        $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
107
+        $this->addMessage( $phpcsFile, $error, $stackPtr, $isError, $errorCode, $data );
108 108
     }
109 109
 }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ControlStructures/NewMultiCatchSniff.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function register()
36 36
     {
37
-        return array(\T_CATCH);
37
+        return array( \T_CATCH );
38 38
     }
39 39
 
40 40
     /**
@@ -46,23 +46,23 @@  discard block
 block discarded – undo
46 46
      *
47 47
      * @return void
48 48
      */
49
-    public function process(File $phpcsFile, $stackPtr)
49
+    public function process( File $phpcsFile, $stackPtr )
50 50
     {
51
-        if ($this->supportsBelow('7.0') === false) {
51
+        if ( $this->supportsBelow( '7.0' ) === false ) {
52 52
             return;
53 53
         }
54 54
 
55 55
         $tokens = $phpcsFile->getTokens();
56
-        $token  = $tokens[$stackPtr];
56
+        $token  = $tokens[ $stackPtr ];
57 57
 
58 58
         // Bow out during live coding.
59
-        if (isset($token['parenthesis_opener'], $token['parenthesis_closer']) === false) {
59
+        if ( isset( $token[ 'parenthesis_opener' ], $token[ 'parenthesis_closer' ] ) === false ) {
60 60
             return;
61 61
         }
62 62
 
63
-        $hasBitwiseOr = $phpcsFile->findNext(\T_BITWISE_OR, $token['parenthesis_opener'], $token['parenthesis_closer']);
63
+        $hasBitwiseOr = $phpcsFile->findNext( \T_BITWISE_OR, $token[ 'parenthesis_opener' ], $token[ 'parenthesis_closer' ] );
64 64
 
65
-        if ($hasBitwiseOr === false) {
65
+        if ( $hasBitwiseOr === false ) {
66 66
             return;
67 67
         }
68 68
 
Please login to merge, or discard this patch.