Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function register()
50 50
     {
51
-        return [T_BOOLEAN_NOT];
51
+        return [ T_BOOLEAN_NOT ];
52 52
 
53 53
     }//end register()
54 54
 
@@ -62,42 +62,42 @@  discard block
 block discarded – undo
62 62
      *
63 63
      * @return void
64 64
      */
65
-    public function process(File $phpcsFile, $stackPtr)
65
+    public function process( File $phpcsFile, $stackPtr )
66 66
     {
67 67
         $tokens        = $phpcsFile->getTokens();
68
-        $this->spacing = (int) $this->spacing;
68
+        $this->spacing = (int)$this->spacing;
69 69
 
70
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
71
-        if ($nextNonEmpty === false) {
70
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
71
+        if ( $nextNonEmpty === false ) {
72 72
             return;
73 73
         }
74 74
 
75
-        if ($this->ignoreNewlines === true
76
-            && $tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']
75
+        if ( $this->ignoreNewlines === true
76
+            && $tokens[ $stackPtr ][ 'line' ] !== $tokens[ $nextNonEmpty ][ 'line' ]
77 77
         ) {
78 78
             return;
79 79
         }
80 80
 
81
-        if ($this->spacing === 0 && $nextNonEmpty === ($stackPtr + 1)) {
81
+        if ( $this->spacing === 0 && $nextNonEmpty === ( $stackPtr + 1 ) ) {
82 82
             return;
83 83
         }
84 84
 
85
-        $nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
86
-        if ($nextNonEmpty !== $nextNonWhitespace) {
85
+        $nextNonWhitespace = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
86
+        if ( $nextNonEmpty !== $nextNonWhitespace ) {
87 87
             $error = 'Expected %s space(s) after NOT operator; comment found';
88
-            $data  = [$this->spacing];
89
-            $phpcsFile->addError($error, $stackPtr, 'CommentFound', $data);
88
+            $data  = [ $this->spacing ];
89
+            $phpcsFile->addError( $error, $stackPtr, 'CommentFound', $data );
90 90
             return;
91 91
         }
92 92
 
93 93
         $found = 0;
94
-        if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) {
94
+        if ( $tokens[ $stackPtr ][ 'line' ] !== $tokens[ $nextNonEmpty ][ 'line' ] ) {
95 95
             $found = 'newline';
96
-        } else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
97
-            $found = $tokens[($stackPtr + 1)]['length'];
96
+        } else if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_WHITESPACE ) {
97
+            $found = $tokens[ ( $stackPtr + 1 ) ][ 'length' ];
98 98
         }
99 99
 
100
-        if ($found === $this->spacing) {
100
+        if ( $found === $this->spacing ) {
101 101
             return;
102 102
         }
103 103
 
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
             $found,
108 108
         ];
109 109
 
110
-        $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data);
111
-        if ($fix === true) {
112
-            $padding = str_repeat(' ', $this->spacing);
113
-            if ($found === 0) {
114
-                $phpcsFile->fixer->addContent($stackPtr, $padding);
110
+        $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'Incorrect', $data );
111
+        if ( $fix === true ) {
112
+            $padding = str_repeat( ' ', $this->spacing );
113
+            if ( $found === 0 ) {
114
+                $phpcsFile->fixer->addContent( $stackPtr, $padding );
115 115
             } else {
116 116
                 $phpcsFile->fixer->beginChangeset();
117
-                $start = ($stackPtr + 1);
117
+                $start = ( $stackPtr + 1 );
118 118
 
119
-                if ($this->spacing > 0) {
120
-                    $phpcsFile->fixer->replaceToken($start, $padding);
119
+                if ( $this->spacing > 0 ) {
120
+                    $phpcsFile->fixer->replaceToken( $start, $padding );
121 121
                     ++$start;
122 122
                 }
123 123
 
124
-                for ($i = $start; $i < $nextNonWhitespace; $i++) {
125
-                    $phpcsFile->fixer->replaceToken($i, '');
124
+                for ( $i = $start; $i < $nextNonWhitespace; $i++ ) {
125
+                    $phpcsFile->fixer->replaceToken( $i, '' );
126 126
                 }
127 127
 
128 128
                 $phpcsFile->fixer->endChangeset();
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -38,32 +38,32 @@
 block discarded – undo
38 38
      *
39 39
      * @return void
40 40
      */
41
-    public function process(File $phpcsFile, $stackPtr)
41
+    public function process( File $phpcsFile, $stackPtr )
42 42
     {
43 43
         $tokens = $phpcsFile->getTokens();
44 44
 
45
-        if ($tokens[$stackPtr]['column'] === 1) {
45
+        if ( $tokens[ $stackPtr ][ 'column' ] === 1 ) {
46 46
             return;
47 47
         }
48 48
 
49
-        if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
49
+        if ( $tokens[ ( $stackPtr - 1 ) ][ 'code' ] !== T_WHITESPACE ) {
50 50
             $error = 'A cast statement must be preceded by a single space';
51
-            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpace');
52
-            if ($fix === true) {
53
-                $phpcsFile->fixer->addContentBefore($stackPtr, ' ');
51
+            $fix   = $phpcsFile->addFixableError( $error, $stackPtr, 'NoSpace' );
52
+            if ( $fix === true ) {
53
+                $phpcsFile->fixer->addContentBefore( $stackPtr, ' ' );
54 54
             }
55 55
 
56
-            $phpcsFile->recordMetric($stackPtr, 'Spacing before cast statement', 0);
56
+            $phpcsFile->recordMetric( $stackPtr, 'Spacing before cast statement', 0 );
57 57
             return;
58 58
         }
59 59
 
60
-        $phpcsFile->recordMetric($stackPtr, 'Spacing before cast statement', $tokens[($stackPtr - 1)]['length']);
60
+        $phpcsFile->recordMetric( $stackPtr, 'Spacing before cast statement', $tokens[ ( $stackPtr - 1 ) ][ 'length' ] );
61 61
 
62
-        if ($tokens[($stackPtr - 1)]['column'] !== 1 && $tokens[($stackPtr - 1)]['length'] !== 1) {
62
+        if ( $tokens[ ( $stackPtr - 1 ) ][ 'column' ] !== 1 && $tokens[ ( $stackPtr - 1 ) ][ 'length' ] !== 1 ) {
63 63
             $error = 'A cast statement must be preceded by a single space';
64
-            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'TooMuchSpace');
65
-            if ($fix === true) {
66
-                $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' ');
64
+            $fix   = $phpcsFile->addFixableError( $error, $stackPtr, 'TooMuchSpace' );
65
+            if ( $fix === true ) {
66
+                $phpcsFile->fixer->replaceToken( ( $stackPtr - 1 ), ' ' );
67 67
             }
68 68
         }
69 69
 
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     public function register()
57 57
     {
58 58
         $tokens = Tokens::$assignmentTokens;
59
-        unset($tokens[T_DOUBLE_ARROW]);
59
+        unset( $tokens[ T_DOUBLE_ARROW ] );
60 60
         return $tokens;
61 61
 
62 62
     }//end register()
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
      *
72 72
      * @return int
73 73
      */
74
-    public function process(File $phpcsFile, $stackPtr)
74
+    public function process( File $phpcsFile, $stackPtr )
75 75
     {
76 76
         $tokens = $phpcsFile->getTokens();
77 77
 
78 78
         // Ignore assignments used in a condition, like an IF or FOR.
79
-        if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
80
-            foreach ($tokens[$stackPtr]['nested_parenthesis'] as $start => $end) {
81
-                if (isset($tokens[$start]['parenthesis_owner']) === true) {
79
+        if ( isset( $tokens[ $stackPtr ][ 'nested_parenthesis' ] ) === true ) {
80
+            foreach ( $tokens[ $stackPtr ][ 'nested_parenthesis' ] as $start => $end ) {
81
+                if ( isset( $tokens[ $start ][ 'parenthesis_owner' ] ) === true ) {
82 82
                     return;
83 83
                 }
84 84
             }
85 85
         }
86 86
 
87
-        $lastAssign = $this->checkAlignment($phpcsFile, $stackPtr);
88
-        return ($lastAssign + 1);
87
+        $lastAssign = $this->checkAlignment( $phpcsFile, $stackPtr );
88
+        return ( $lastAssign + 1 );
89 89
 
90 90
     }//end process()
91 91
 
@@ -101,88 +101,88 @@  discard block
 block discarded – undo
101 101
      *
102 102
      * @return int
103 103
      */
104
-    public function checkAlignment($phpcsFile, $stackPtr, $end=null)
104
+    public function checkAlignment( $phpcsFile, $stackPtr, $end = null )
105 105
     {
106 106
         $tokens = $phpcsFile->getTokens();
107 107
 
108
-        $assignments = [];
108
+        $assignments = [ ];
109 109
         $prevAssign  = null;
110
-        $lastLine    = $tokens[$stackPtr]['line'];
110
+        $lastLine    = $tokens[ $stackPtr ][ 'line' ];
111 111
         $maxPadding  = null;
112 112
         $stopped     = null;
113 113
         $lastCode    = $stackPtr;
114 114
         $lastSemi    = null;
115 115
         $arrayEnd    = null;
116 116
 
117
-        if ($end === null) {
117
+        if ( $end === null ) {
118 118
             $end = $phpcsFile->numTokens;
119 119
         }
120 120
 
121 121
         $find = Tokens::$assignmentTokens;
122
-        unset($find[T_DOUBLE_ARROW]);
122
+        unset( $find[ T_DOUBLE_ARROW ] );
123 123
 
124 124
         $scopes = Tokens::$scopeOpeners;
125
-        unset($scopes[T_CLOSURE]);
126
-        unset($scopes[T_ANON_CLASS]);
127
-        unset($scopes[T_OBJECT]);
125
+        unset( $scopes[ T_CLOSURE ] );
126
+        unset( $scopes[ T_ANON_CLASS ] );
127
+        unset( $scopes[ T_OBJECT ] );
128 128
 
129
-        for ($assign = $stackPtr; $assign < $end; $assign++) {
130
-            if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
129
+        for ( $assign = $stackPtr; $assign < $end; $assign++ ) {
130
+            if ( $tokens[ $assign ][ 'level' ] < $tokens[ $stackPtr ][ 'level' ] ) {
131 131
                 // Statement is in a different context, so the block is over.
132 132
                 break;
133 133
             }
134 134
 
135
-            if (isset($scopes[$tokens[$assign]['code']]) === true
136
-                && isset($tokens[$assign]['scope_opener']) === true
137
-                && $tokens[$assign]['level'] === $tokens[$stackPtr]['level']
135
+            if ( isset( $scopes[ $tokens[ $assign ][ 'code' ] ] ) === true
136
+                && isset( $tokens[ $assign ][ 'scope_opener' ] ) === true
137
+                && $tokens[ $assign ][ 'level' ] === $tokens[ $stackPtr ][ 'level' ]
138 138
             ) {
139 139
                 break;
140 140
             }
141 141
 
142
-            if ($assign === $arrayEnd) {
142
+            if ( $assign === $arrayEnd ) {
143 143
                 $arrayEnd = null;
144 144
             }
145 145
 
146
-            if (isset($find[$tokens[$assign]['code']]) === false) {
146
+            if ( isset( $find[ $tokens[ $assign ][ 'code' ] ] ) === false ) {
147 147
                 // A blank line indicates that the assignment block has ended.
148
-                if (isset(Tokens::$emptyTokens[$tokens[$assign]['code']]) === false
149
-                    && ($tokens[$assign]['line'] - $tokens[$lastCode]['line']) > 1
150
-                    && $tokens[$assign]['level'] === $tokens[$stackPtr]['level']
148
+                if ( isset( Tokens::$emptyTokens[ $tokens[ $assign ][ 'code' ] ] ) === false
149
+                    && ( $tokens[ $assign ][ 'line' ] - $tokens[ $lastCode ][ 'line' ] ) > 1
150
+                    && $tokens[ $assign ][ 'level' ] === $tokens[ $stackPtr ][ 'level' ]
151 151
                     && $arrayEnd === null
152 152
                 ) {
153 153
                     break;
154 154
                 }
155 155
 
156
-                if ($tokens[$assign]['code'] === T_CLOSE_TAG) {
156
+                if ( $tokens[ $assign ][ 'code' ] === T_CLOSE_TAG ) {
157 157
                     // Breaking out of PHP ends the assignment block.
158 158
                     break;
159 159
                 }
160 160
 
161
-                if ($tokens[$assign]['code'] === T_OPEN_SHORT_ARRAY
162
-                    && isset($tokens[$assign]['bracket_closer']) === true
161
+                if ( $tokens[ $assign ][ 'code' ] === T_OPEN_SHORT_ARRAY
162
+                    && isset( $tokens[ $assign ][ 'bracket_closer' ] ) === true
163 163
                 ) {
164
-                    $arrayEnd = $tokens[$assign]['bracket_closer'];
164
+                    $arrayEnd = $tokens[ $assign ][ 'bracket_closer' ];
165 165
                 }
166 166
 
167
-                if ($tokens[$assign]['code'] === T_ARRAY
168
-                    && isset($tokens[$assign]['parenthesis_opener']) === true
169
-                    && isset($tokens[$tokens[$assign]['parenthesis_opener']]['parenthesis_closer']) === true
167
+                if ( $tokens[ $assign ][ 'code' ] === T_ARRAY
168
+                    && isset( $tokens[ $assign ][ 'parenthesis_opener' ] ) === true
169
+                    && isset( $tokens[ $tokens[ $assign ][ 'parenthesis_opener' ] ][ 'parenthesis_closer' ] ) === true
170 170
                 ) {
171
-                    $arrayEnd = $tokens[$tokens[$assign]['parenthesis_opener']]['parenthesis_closer'];
171
+                    $arrayEnd = $tokens[ $tokens[ $assign ][ 'parenthesis_opener' ] ][ 'parenthesis_closer' ];
172 172
                 }
173 173
 
174
-                if (isset(Tokens::$emptyTokens[$tokens[$assign]['code']]) === false) {
174
+                if ( isset( Tokens::$emptyTokens[ $tokens[ $assign ][ 'code' ] ] ) === false ) {
175 175
                     $lastCode = $assign;
176 176
 
177
-                    if ($tokens[$assign]['code'] === T_SEMICOLON) {
178
-                        if ($tokens[$assign]['conditions'] === $tokens[$stackPtr]['conditions']) {
179
-                            if ($lastSemi !== null && $prevAssign !== null && $lastSemi > $prevAssign) {
177
+                    if ( $tokens[ $assign ][ 'code' ] === T_SEMICOLON ) {
178
+                        if ( $tokens[ $assign ][ 'conditions' ] === $tokens[ $stackPtr ][ 'conditions' ] ) {
179
+                            if ( $lastSemi !== null && $prevAssign !== null && $lastSemi > $prevAssign ) {
180 180
                                 // This statement did not have an assignment operator in it.
181 181
                                 break;
182 182
                             } else {
183 183
                                 $lastSemi = $assign;
184 184
                             }
185
-                        } else if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
185
+                        } else if ( $tokens[ $assign ][ 'level' ] < $tokens[ $stackPtr ][ 'level' ] ) {
186 186
                             // Statement is in a different context, so the block is over.
187 187
                             break;
188 188
                         }
@@ -190,36 +190,36 @@  discard block
 block discarded – undo
190 190
                 }//end if
191 191
 
192 192
                 continue;
193
-            } else if ($assign !== $stackPtr && $tokens[$assign]['line'] === $lastLine) {
193
+            } else if ( $assign !== $stackPtr && $tokens[ $assign ][ 'line' ] === $lastLine ) {
194 194
                 // Skip multiple assignments on the same line. We only need to
195 195
                 // try and align the first assignment.
196 196
                 continue;
197 197
             }//end if
198 198
 
199
-            if ($assign !== $stackPtr) {
200
-                if ($tokens[$assign]['level'] > $tokens[$stackPtr]['level']) {
199
+            if ( $assign !== $stackPtr ) {
200
+                if ( $tokens[ $assign ][ 'level' ] > $tokens[ $stackPtr ][ 'level' ] ) {
201 201
                     // Has to be nested inside the same conditions as the first assignment.
202 202
                     // We've gone one level down, so process this new block.
203
-                    $assign   = $this->checkAlignment($phpcsFile, $assign);
203
+                    $assign   = $this->checkAlignment( $phpcsFile, $assign );
204 204
                     $lastCode = $assign;
205 205
                     continue;
206
-                } else if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
206
+                } else if ( $tokens[ $assign ][ 'level' ] < $tokens[ $stackPtr ][ 'level' ] ) {
207 207
                     // We've gone one level up, so the block we are processing is done.
208 208
                     break;
209
-                } else if ($arrayEnd !== null) {
209
+                } else if ( $arrayEnd !== null ) {
210 210
                     // Assignments inside arrays are not part of
211 211
                     // the original block, so process this new block.
212
-                    $assign   = ($this->checkAlignment($phpcsFile, $assign, $arrayEnd) - 1);
212
+                    $assign   = ( $this->checkAlignment( $phpcsFile, $assign, $arrayEnd ) - 1 );
213 213
                     $arrayEnd = null;
214 214
                     $lastCode = $assign;
215 215
                     continue;
216 216
                 }
217 217
 
218 218
                 // Make sure it is not assigned inside a condition (eg. IF, FOR).
219
-                if (isset($tokens[$assign]['nested_parenthesis']) === true) {
220
-                    foreach ($tokens[$assign]['nested_parenthesis'] as $start => $end) {
221
-                        if (isset($tokens[$start]['parenthesis_owner']) === true) {
222
-                            break(2);
219
+                if ( isset( $tokens[ $assign ][ 'nested_parenthesis' ] ) === true ) {
220
+                    foreach ( $tokens[ $assign ][ 'nested_parenthesis' ] as $start => $end ) {
221
+                        if ( isset( $tokens[ $start ][ 'parenthesis_owner' ] ) === true ) {
222
+                            break( 2 );
223 223
                         }
224 224
                     }
225 225
                 }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
             $var = $phpcsFile->findPrevious(
229 229
                 Tokens::$emptyTokens,
230
-                ($assign - 1),
230
+                ( $assign - 1 ),
231 231
                 null,
232 232
                 true
233 233
             );
@@ -235,70 +235,70 @@  discard block
 block discarded – undo
235 235
             // Make sure we wouldn't break our max padding length if we
236 236
             // aligned with this statement, or they wouldn't break the max
237 237
             // padding length if they aligned with us.
238
-            $varEnd    = $tokens[($var + 1)]['column'];
239
-            $assignLen = $tokens[$assign]['length'];
240
-            if ($assign !== $stackPtr) {
241
-                if ($prevAssign === null) {
238
+            $varEnd    = $tokens[ ( $var + 1 ) ][ 'column' ];
239
+            $assignLen = $tokens[ $assign ][ 'length' ];
240
+            if ( $assign !== $stackPtr ) {
241
+                if ( $prevAssign === null ) {
242 242
                     // Processing an inner block but no assignments found.
243 243
                     break;
244 244
                 }
245 245
 
246
-                if (($varEnd + 1) > $assignments[$prevAssign]['assign_col']) {
246
+                if ( ( $varEnd + 1 ) > $assignments[ $prevAssign ][ 'assign_col' ] ) {
247 247
                     $padding      = 1;
248
-                    $assignColumn = ($varEnd + 1);
248
+                    $assignColumn = ( $varEnd + 1 );
249 249
                 } else {
250
-                    $padding = ($assignments[$prevAssign]['assign_col'] - $varEnd + $assignments[$prevAssign]['assign_len'] - $assignLen);
251
-                    if ($padding <= 0) {
250
+                    $padding = ( $assignments[ $prevAssign ][ 'assign_col' ] - $varEnd + $assignments[ $prevAssign ][ 'assign_len' ] - $assignLen );
251
+                    if ( $padding <= 0 ) {
252 252
                         $padding = 1;
253 253
                     }
254 254
 
255
-                    if ($padding > $this->maxPadding) {
255
+                    if ( $padding > $this->maxPadding ) {
256 256
                         $stopped = $assign;
257 257
                         break;
258 258
                     }
259 259
 
260
-                    $assignColumn = ($varEnd + $padding);
260
+                    $assignColumn = ( $varEnd + $padding );
261 261
                 }//end if
262 262
 
263
-                if (($assignColumn + $assignLen) > ($assignments[$maxPadding]['assign_col'] + $assignments[$maxPadding]['assign_len'])) {
264
-                    $newPadding = ($varEnd - $assignments[$maxPadding]['var_end'] + $assignLen - $assignments[$maxPadding]['assign_len'] + 1);
265
-                    if ($newPadding > $this->maxPadding) {
263
+                if ( ( $assignColumn + $assignLen ) > ( $assignments[ $maxPadding ][ 'assign_col' ] + $assignments[ $maxPadding ][ 'assign_len' ] ) ) {
264
+                    $newPadding = ( $varEnd - $assignments[ $maxPadding ][ 'var_end' ] + $assignLen - $assignments[ $maxPadding ][ 'assign_len' ] + 1 );
265
+                    if ( $newPadding > $this->maxPadding ) {
266 266
                         $stopped = $assign;
267 267
                         break;
268 268
                     } else {
269 269
                         // New alignment settings for previous assignments.
270
-                        foreach ($assignments as $i => $data) {
271
-                            if ($i === $assign) {
270
+                        foreach ( $assignments as $i => $data ) {
271
+                            if ( $i === $assign ) {
272 272
                                 break;
273 273
                             }
274 274
 
275
-                            $newPadding = ($varEnd - $data['var_end'] + $assignLen - $data['assign_len'] + 1);
276
-                            $assignments[$i]['expected']   = $newPadding;
277
-                            $assignments[$i]['assign_col'] = ($data['var_end'] + $newPadding);
275
+                            $newPadding = ( $varEnd - $data[ 'var_end' ] + $assignLen - $data[ 'assign_len' ] + 1 );
276
+                            $assignments[ $i ][ 'expected' ]   = $newPadding;
277
+                            $assignments[ $i ][ 'assign_col' ] = ( $data[ 'var_end' ] + $newPadding );
278 278
                         }
279 279
 
280 280
                         $padding      = 1;
281
-                        $assignColumn = ($varEnd + 1);
281
+                        $assignColumn = ( $varEnd + 1 );
282 282
                     }
283
-                } else if ($padding > $assignments[$maxPadding]['expected']) {
283
+                } else if ( $padding > $assignments[ $maxPadding ][ 'expected' ] ) {
284 284
                     $maxPadding = $assign;
285 285
                 }//end if
286 286
             } else {
287 287
                 $padding      = 1;
288
-                $assignColumn = ($varEnd + 1);
288
+                $assignColumn = ( $varEnd + 1 );
289 289
                 $maxPadding   = $assign;
290 290
             }//end if
291 291
 
292 292
             $found = 0;
293
-            if ($tokens[($var + 1)]['code'] === T_WHITESPACE) {
294
-                $found = $tokens[($var + 1)]['length'];
295
-                if ($found === 0) {
293
+            if ( $tokens[ ( $var + 1 ) ][ 'code' ] === T_WHITESPACE ) {
294
+                $found = $tokens[ ( $var + 1 ) ][ 'length' ];
295
+                if ( $found === 0 ) {
296 296
                     // This means a newline was found.
297 297
                     $found = 1;
298 298
                 }
299 299
             }
300 300
 
301
-            $assignments[$assign] = [
301
+            $assignments[ $assign ] = [
302 302
                 'var_end'    => $varEnd,
303 303
                 'assign_len' => $assignLen,
304 304
                 'assign_col' => $assignColumn,
@@ -306,37 +306,37 @@  discard block
 block discarded – undo
306 306
                 'found'      => $found,
307 307
             ];
308 308
 
309
-            $lastLine   = $tokens[$assign]['line'];
309
+            $lastLine   = $tokens[ $assign ][ 'line' ];
310 310
             $prevAssign = $assign;
311 311
         }//end for
312 312
 
313
-        if (empty($assignments) === true) {
313
+        if ( empty( $assignments ) === true ) {
314 314
             return $stackPtr;
315 315
         }
316 316
 
317
-        $numAssignments = count($assignments);
317
+        $numAssignments = count( $assignments );
318 318
 
319 319
         $errorGenerated = false;
320
-        foreach ($assignments as $assignment => $data) {
321
-            if ($data['found'] === $data['expected']) {
320
+        foreach ( $assignments as $assignment => $data ) {
321
+            if ( $data[ 'found' ] === $data[ 'expected' ] ) {
322 322
                 continue;
323 323
             }
324 324
 
325
-            $expectedText = $data['expected'].' space';
326
-            if ($data['expected'] !== 1) {
325
+            $expectedText = $data[ 'expected' ] . ' space';
326
+            if ( $data[ 'expected' ] !== 1 ) {
327 327
                 $expectedText .= 's';
328 328
             }
329 329
 
330
-            if ($data['found'] === null) {
330
+            if ( $data[ 'found' ] === null ) {
331 331
                 $foundText = 'a new line';
332 332
             } else {
333
-                $foundText = $data['found'].' space';
334
-                if ($data['found'] !== 1) {
333
+                $foundText = $data[ 'found' ] . ' space';
334
+                if ( $data[ 'found' ] !== 1 ) {
335 335
                     $foundText .= 's';
336 336
                 }
337 337
             }
338 338
 
339
-            if ($numAssignments === 1) {
339
+            if ( $numAssignments === 1 ) {
340 340
                 $type  = 'Incorrect';
341 341
                 $error = 'Equals sign not aligned correctly; expected %s but found %s';
342 342
             } else {
@@ -349,34 +349,34 @@  discard block
 block discarded – undo
349 349
                 $foundText,
350 350
             ];
351 351
 
352
-            if ($this->error === true) {
353
-                $fix = $phpcsFile->addFixableError($error, $assignment, $type, $errorData);
352
+            if ( $this->error === true ) {
353
+                $fix = $phpcsFile->addFixableError( $error, $assignment, $type, $errorData );
354 354
             } else {
355
-                $fix = $phpcsFile->addFixableWarning($error, $assignment, $type.'Warning', $errorData);
355
+                $fix = $phpcsFile->addFixableWarning( $error, $assignment, $type . 'Warning', $errorData );
356 356
             }
357 357
 
358 358
             $errorGenerated = true;
359 359
 
360
-            if ($fix === true && $data['found'] !== null) {
361
-                $newContent = str_repeat(' ', $data['expected']);
362
-                if ($data['found'] === 0) {
363
-                    $phpcsFile->fixer->addContentBefore($assignment, $newContent);
360
+            if ( $fix === true && $data[ 'found' ] !== null ) {
361
+                $newContent = str_repeat( ' ', $data[ 'expected' ] );
362
+                if ( $data[ 'found' ] === 0 ) {
363
+                    $phpcsFile->fixer->addContentBefore( $assignment, $newContent );
364 364
                 } else {
365
-                    $phpcsFile->fixer->replaceToken(($assignment - 1), $newContent);
365
+                    $phpcsFile->fixer->replaceToken( ( $assignment - 1 ), $newContent );
366 366
                 }
367 367
             }
368 368
         }//end foreach
369 369
 
370
-        if ($numAssignments > 1) {
371
-            if ($errorGenerated === true) {
372
-                $phpcsFile->recordMetric($stackPtr, 'Adjacent assignments aligned', 'no');
370
+        if ( $numAssignments > 1 ) {
371
+            if ( $errorGenerated === true ) {
372
+                $phpcsFile->recordMetric( $stackPtr, 'Adjacent assignments aligned', 'no' );
373 373
             } else {
374
-                $phpcsFile->recordMetric($stackPtr, 'Adjacent assignments aligned', 'yes');
374
+                $phpcsFile->recordMetric( $stackPtr, 'Adjacent assignments aligned', 'yes' );
375 375
             }
376 376
         }
377 377
 
378
-        if ($stopped !== null) {
379
-            return $this->checkAlignment($phpcsFile, $stopped);
378
+        if ( $stopped !== null ) {
379
+            return $this->checkAlignment( $phpcsFile, $stopped );
380 380
         } else {
381 381
             return $assign;
382 382
         }
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function register()
25 25
     {
26
-        return [T_OPEN_TAG];
26
+        return [ T_OPEN_TAG ];
27 27
 
28 28
     }//end register()
29 29
 
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @return void
39 39
      */
40
-    public function process(File $phpcsFile, $stackPtr)
40
+    public function process( File $phpcsFile, $stackPtr )
41 41
     {
42
-        $closeTag = $phpcsFile->findNext(T_CLOSE_TAG, $stackPtr);
43
-        if ($closeTag === false) {
42
+        $closeTag = $phpcsFile->findNext( T_CLOSE_TAG, $stackPtr );
43
+        if ( $closeTag === false ) {
44 44
             $error = 'The PHP open tag does not have a corresponding PHP close tag';
45
-            $phpcsFile->addError($error, $stackPtr, 'NotFound');
45
+            $phpcsFile->addError( $error, $stackPtr, 'NotFound' );
46 46
         }
47 47
 
48 48
     }//end process()
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function register()
38 38
     {
39
-        return [T_OPEN_TAG];
39
+        return [ T_OPEN_TAG ];
40 40
 
41 41
     }//end register()
42 42
 
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return void
52 52
      */
53
-    public function process(File $phpcsFile, $stackPtr)
53
+    public function process( File $phpcsFile, $stackPtr )
54 54
     {
55 55
         $expected = 0;
56
-        if ($stackPtr > 0) {
56
+        if ( $stackPtr > 0 ) {
57 57
             // Allow a byte-order mark.
58 58
             $tokens = $phpcsFile->getTokens();
59
-            foreach ($this->bomDefinitions as $bomName => $expectedBomHex) {
60
-                $bomByteLength = (strlen($expectedBomHex) / 2);
61
-                $htmlBomHex    = bin2hex(substr($tokens[0]['content'], 0, $bomByteLength));
62
-                if ($htmlBomHex === $expectedBomHex) {
59
+            foreach ( $this->bomDefinitions as $bomName => $expectedBomHex ) {
60
+                $bomByteLength = ( strlen( $expectedBomHex ) / 2 );
61
+                $htmlBomHex    = bin2hex( substr( $tokens[ 0 ][ 'content' ], 0, $bomByteLength ) );
62
+                if ( $htmlBomHex === $expectedBomHex ) {
63 63
                     $expected++;
64 64
                     break;
65 65
                 }
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 
68 68
             // Allow a shebang line.
69 69
             $tokens = $phpcsFile->getTokens();
70
-            if (substr($tokens[0]['content'], 0, 2) === '#!') {
70
+            if ( substr( $tokens[ 0 ][ 'content' ], 0, 2 ) === '#!' ) {
71 71
                 $expected++;
72 72
             }
73 73
         }
74 74
 
75
-        if ($stackPtr !== $expected) {
75
+        if ( $stackPtr !== $expected ) {
76 76
             $error = 'The opening PHP tag must be the first content in the file';
77
-            $phpcsFile->addError($error, $stackPtr, 'Found');
77
+            $phpcsFile->addError( $error, $stackPtr, 'Found' );
78 78
         }
79 79
 
80 80
         // Skip the rest of the file so we don't pick up additional
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -109,31 +109,31 @@
 block discarded – undo
109 109
      *
110 110
      * @return void
111 111
      */
112
-    public function process(File $phpcsFile, $stackPtr)
112
+    public function process( File $phpcsFile, $stackPtr )
113 113
     {
114 114
         $tokens  = $phpcsFile->getTokens();
115
-        $keyword = $tokens[$stackPtr]['content'];
116
-        if (strtolower($keyword) !== $keyword) {
117
-            if ($keyword === strtoupper($keyword)) {
118
-                $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'upper');
115
+        $keyword = $tokens[ $stackPtr ][ 'content' ];
116
+        if ( strtolower( $keyword ) !== $keyword ) {
117
+            if ( $keyword === strtoupper( $keyword ) ) {
118
+                $phpcsFile->recordMetric( $stackPtr, 'PHP keyword case', 'upper' );
119 119
             } else {
120
-                $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'mixed');
120
+                $phpcsFile->recordMetric( $stackPtr, 'PHP keyword case', 'mixed' );
121 121
             }
122 122
 
123
-            $messageKeyword = Util\Common::prepareForOutput($keyword);
123
+            $messageKeyword = Util\Common::prepareForOutput( $keyword );
124 124
 
125 125
             $error = 'PHP keywords must be lowercase; expected "%s" but found "%s"';
126 126
             $data  = [
127
-                strtolower($messageKeyword),
127
+                strtolower( $messageKeyword ),
128 128
                 $messageKeyword,
129 129
             ];
130 130
 
131
-            $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
132
-            if ($fix === true) {
133
-                $phpcsFile->fixer->replaceToken($stackPtr, strtolower($keyword));
131
+            $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'Found', $data );
132
+            if ( $fix === true ) {
133
+                $phpcsFile->fixer->replaceToken( $stackPtr, strtolower( $keyword ) );
134 134
             }
135 135
         } else {
136
-            $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'lower');
136
+            $phpcsFile->recordMetric( $stackPtr, 'PHP keyword case', 'lower' );
137 137
         }//end if
138 138
 
139 139
     }//end process()
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return void
43 43
      */
44
-    public function process(File $phpcsFile, $stackPtr)
44
+    public function process( File $phpcsFile, $stackPtr )
45 45
     {
46 46
         $tokens   = $phpcsFile->getTokens();
47
-        $keyword  = $tokens[$stackPtr]['content'];
48
-        $expected = strtoupper($keyword);
49
-        if ($keyword !== $expected) {
50
-            if ($keyword === strtolower($keyword)) {
51
-                $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'lower');
47
+        $keyword  = $tokens[ $stackPtr ][ 'content' ];
48
+        $expected = strtoupper( $keyword );
49
+        if ( $keyword !== $expected ) {
50
+            if ( $keyword === strtolower( $keyword ) ) {
51
+                $phpcsFile->recordMetric( $stackPtr, 'PHP constant case', 'lower' );
52 52
             } else {
53
-                $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'mixed');
53
+                $phpcsFile->recordMetric( $stackPtr, 'PHP constant case', 'mixed' );
54 54
             }
55 55
 
56 56
             $error = 'TRUE, FALSE and NULL must be uppercase; expected "%s" but found "%s"';
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
                 $keyword,
60 60
             ];
61 61
 
62
-            $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
63
-            if ($fix === true) {
64
-                $phpcsFile->fixer->replaceToken($stackPtr, $expected);
62
+            $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'Found', $data );
63
+            if ( $fix === true ) {
64
+                $phpcsFile->fixer->replaceToken( $stackPtr, $expected );
65 65
             }
66 66
         } else {
67
-            $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'upper');
67
+            $phpcsFile->recordMetric( $stackPtr, 'PHP constant case', 'upper' );
68 68
         }
69 69
 
70 70
     }//end process()
Please login to merge, or discard this patch.
squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function register()
34 34
     {
35
-        return [T_OPEN_TAG];
35
+        return [ T_OPEN_TAG ];
36 36
 
37 37
     }//end register()
38 38
 
@@ -46,24 +46,24 @@  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->phpPath === null) {
52
-            $this->phpPath = Config::getExecutablePath('php');
51
+        if ( $this->phpPath === null ) {
52
+            $this->phpPath = Config::getExecutablePath( 'php' );
53 53
         }
54 54
 
55
-        $fileName = escapeshellarg($phpcsFile->getFilename());
56
-        $cmd      = escapeshellcmd($this->phpPath)." -l -d display_errors=1 -d error_prepend_string='' $fileName 2>&1";
57
-        $output   = shell_exec($cmd);
58
-        $matches  = [];
59
-        if (preg_match('/^.*error:(.*) in .* on line ([0-9]+)/m', trim($output), $matches) === 1) {
60
-            $error = trim($matches[1]);
61
-            $line  = (int) $matches[2];
62
-            $phpcsFile->addErrorOnLine("PHP syntax error: $error", $line, 'PHPSyntax');
55
+        $fileName = escapeshellarg( $phpcsFile->getFilename() );
56
+        $cmd      = escapeshellcmd( $this->phpPath ) . " -l -d display_errors=1 -d error_prepend_string='' $fileName 2>&1";
57
+        $output   = shell_exec( $cmd );
58
+        $matches  = [ ];
59
+        if ( preg_match( '/^.*error:(.*) in .* on line ([0-9]+)/m', trim( $output ), $matches ) === 1 ) {
60
+            $error = trim( $matches[ 1 ] );
61
+            $line  = (int)$matches[ 2 ];
62
+            $phpcsFile->addErrorOnLine( "PHP syntax error: $error", $line, 'PHPSyntax' );
63 63
         }
64 64
 
65 65
         // Ignore the rest of the file.
66
-        return ($phpcsFile->numTokens + 1);
66
+        return ( $phpcsFile->numTokens + 1 );
67 67
 
68 68
     }//end process()
69 69
 
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
             T_OPEN_TAG_WITH_ECHO,
30 30
         ];
31 31
 
32
-        $shortOpenTags = (bool) ini_get('short_open_tag');
33
-        if ($shortOpenTags === false) {
34
-            $targets[] = T_INLINE_HTML;
32
+        $shortOpenTags = (bool)ini_get( 'short_open_tag' );
33
+        if ( $shortOpenTags === false ) {
34
+            $targets[ ] = T_INLINE_HTML;
35 35
         }
36 36
 
37 37
         return $targets;
@@ -48,69 +48,69 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return void
50 50
      */
51
-    public function process(File $phpcsFile, $stackPtr)
51
+    public function process( File $phpcsFile, $stackPtr )
52 52
     {
53 53
         $tokens = $phpcsFile->getTokens();
54
-        $token  = $tokens[$stackPtr];
54
+        $token  = $tokens[ $stackPtr ];
55 55
 
56
-        if ($token['code'] === T_OPEN_TAG && $token['content'] === '<?') {
56
+        if ( $token[ 'code' ] === T_OPEN_TAG && $token[ 'content' ] === '<?' ) {
57 57
             $error = 'Short PHP opening tag used; expected "<?php" but found "%s"';
58
-            $data  = [$token['content']];
59
-            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
60
-            if ($fix === true) {
58
+            $data  = [ $token[ 'content' ] ];
59
+            $fix   = $phpcsFile->addFixableError( $error, $stackPtr, 'Found', $data );
60
+            if ( $fix === true ) {
61 61
                 $correctOpening = '<?php';
62
-                if (isset($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
62
+                if ( isset( $tokens[ ( $stackPtr + 1 ) ] ) === true && $tokens[ ( $stackPtr + 1 ) ][ 'code' ] !== T_WHITESPACE ) {
63 63
                     // Avoid creation of invalid open tags like <?phpecho if the original was <?echo .
64 64
                     $correctOpening .= ' ';
65 65
                 }
66 66
 
67
-                $phpcsFile->fixer->replaceToken($stackPtr, $correctOpening);
67
+                $phpcsFile->fixer->replaceToken( $stackPtr, $correctOpening );
68 68
             }
69 69
 
70
-            $phpcsFile->recordMetric($stackPtr, 'PHP short open tag used', 'yes');
70
+            $phpcsFile->recordMetric( $stackPtr, 'PHP short open tag used', 'yes' );
71 71
         } else {
72
-            $phpcsFile->recordMetric($stackPtr, 'PHP short open tag used', 'no');
72
+            $phpcsFile->recordMetric( $stackPtr, 'PHP short open tag used', 'no' );
73 73
         }
74 74
 
75
-        if ($token['code'] === T_OPEN_TAG_WITH_ECHO) {
76
-            $nextVar = $tokens[$phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true)];
75
+        if ( $token[ 'code' ] === T_OPEN_TAG_WITH_ECHO ) {
76
+            $nextVar = $tokens[ $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true ) ];
77 77
             $error   = 'Short PHP opening tag used with echo; expected "<?php echo %s ..." but found "%s %s ..."';
78 78
             $data    = [
79
-                $nextVar['content'],
80
-                $token['content'],
81
-                $nextVar['content'],
79
+                $nextVar[ 'content' ],
80
+                $token[ 'content' ],
81
+                $nextVar[ 'content' ],
82 82
             ];
83
-            $fix     = $phpcsFile->addFixableError($error, $stackPtr, 'EchoFound', $data);
84
-            if ($fix === true) {
85
-                if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
86
-                    $phpcsFile->fixer->replaceToken($stackPtr, '<?php echo ');
83
+            $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'EchoFound', $data );
84
+            if ( $fix === true ) {
85
+                if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] !== T_WHITESPACE ) {
86
+                    $phpcsFile->fixer->replaceToken( $stackPtr, '<?php echo ' );
87 87
                 } else {
88
-                    $phpcsFile->fixer->replaceToken($stackPtr, '<?php echo');
88
+                    $phpcsFile->fixer->replaceToken( $stackPtr, '<?php echo' );
89 89
                 }
90 90
             }
91 91
         }
92 92
 
93
-        if ($token['code'] === T_INLINE_HTML) {
94
-            $content     = $token['content'];
95
-            $openerFound = strpos($content, '<?');
93
+        if ( $token[ 'code' ] === T_INLINE_HTML ) {
94
+            $content     = $token[ 'content' ];
95
+            $openerFound = strpos( $content, '<?' );
96 96
 
97
-            if ($openerFound === false) {
97
+            if ( $openerFound === false ) {
98 98
                 return;
99 99
             }
100 100
 
101 101
             $closerFound = false;
102 102
 
103 103
             // Inspect current token and subsequent inline HTML token to find a close tag.
104
-            for ($i = $stackPtr; $i < $phpcsFile->numTokens; $i++) {
105
-                if ($tokens[$i]['code'] !== T_INLINE_HTML) {
104
+            for ( $i = $stackPtr; $i < $phpcsFile->numTokens; $i++ ) {
105
+                if ( $tokens[ $i ][ 'code' ] !== T_INLINE_HTML ) {
106 106
                     break;
107 107
                 }
108 108
 
109
-                $closerFound = strrpos($tokens[$i]['content'], '?>');
110
-                if ($closerFound !== false) {
111
-                    if ($i !== $stackPtr) {
109
+                $closerFound = strrpos( $tokens[ $i ][ 'content' ], '?>' );
110
+                if ( $closerFound !== false ) {
111
+                    if ( $i !== $stackPtr ) {
112 112
                         break;
113
-                    } else if ($closerFound > $openerFound) {
113
+                    } else if ( $closerFound > $openerFound ) {
114 114
                         break;
115 115
                     } else {
116 116
                         $closerFound = false;
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
                 }
119 119
             }
120 120
 
121
-            if ($closerFound !== false) {
121
+            if ( $closerFound !== false ) {
122 122
                 $error   = 'Possible use of short open tags detected; found: %s';
123
-                $snippet = $this->getSnippet($content, '<?');
124
-                $data    = ['<?'.$snippet];
123
+                $snippet = $this->getSnippet( $content, '<?' );
124
+                $data    = [ '<?' . $snippet ];
125 125
 
126
-                $phpcsFile->addWarning($error, $stackPtr, 'PossibleFound', $data);
126
+                $phpcsFile->addWarning( $error, $stackPtr, 'PossibleFound', $data );
127 127
 
128 128
                 // Skip forward to the token containing the closer.
129
-                if (($i - 1) > $stackPtr) {
129
+                if ( ( $i - 1 ) > $stackPtr ) {
130 130
                     return $i;
131 131
                 }
132 132
             }
@@ -144,19 +144,19 @@  discard block
 block discarded – undo
144 144
      *
145 145
      * @return string
146 146
      */
147
-    protected function getSnippet($content, $start='', $length=40)
147
+    protected function getSnippet( $content, $start = '', $length = 40 )
148 148
     {
149 149
         $startPos = 0;
150 150
 
151
-        if ($start !== '') {
152
-            $startPos = strpos($content, $start);
153
-            if ($startPos !== false) {
154
-                $startPos += strlen($start);
151
+        if ( $start !== '' ) {
152
+            $startPos = strpos( $content, $start );
153
+            if ( $startPos !== false ) {
154
+                $startPos += strlen( $start );
155 155
             }
156 156
         }
157 157
 
158
-        $snippet = substr($content, $startPos, $length);
159
-        if ((strlen($content) - $startPos) > $length) {
158
+        $snippet = substr( $content, $startPos, $length );
159
+        if ( ( strlen( $content ) - $startPos ) > $length ) {
160 160
             $snippet .= '...';
161 161
         }
162 162
 
Please login to merge, or discard this patch.