Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
php_codesniffer/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php 1 patch
Spacing   +3 added lines, -3 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_BACKTICK];
26
+        return [ T_BACKTICK ];
27 27
 
28 28
     }//end register()
29 29
 
@@ -37,10 +37,10 @@  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 42
         $error = 'Use of the backtick operator is forbidden';
43
-        $phpcsFile->addError($error, $stackPtr, 'Found');
43
+        $phpcsFile->addError( $error, $stackPtr, 'Found' );
44 44
 
45 45
     }//end process()
46 46
 
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
     public function register()
26 26
     {
27 27
         $tokens   = Tokens::$castTokens;
28
-        $tokens[] = T_FUNCTION;
29
-        $tokens[] = T_CLOSURE;
28
+        $tokens[ ] = T_FUNCTION;
29
+        $tokens[ ] = T_CLOSURE;
30 30
         return $tokens;
31 31
 
32 32
     }//end register()
@@ -41,31 +41,31 @@  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 47
 
48
-        if (isset(Tokens::$castTokens[$tokens[$stackPtr]['code']]) === true) {
48
+        if ( isset( Tokens::$castTokens[ $tokens[ $stackPtr ][ 'code' ] ] ) === true ) {
49 49
             // A cast token.
50
-            if (strtolower($tokens[$stackPtr]['content']) !== $tokens[$stackPtr]['content']) {
51
-                if ($tokens[$stackPtr]['content'] === strtoupper($tokens[$stackPtr]['content'])) {
52
-                    $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'upper');
50
+            if ( strtolower( $tokens[ $stackPtr ][ 'content' ] ) !== $tokens[ $stackPtr ][ 'content' ] ) {
51
+                if ( $tokens[ $stackPtr ][ 'content' ] === strtoupper( $tokens[ $stackPtr ][ 'content' ] ) ) {
52
+                    $phpcsFile->recordMetric( $stackPtr, 'PHP type case', 'upper' );
53 53
                 } else {
54
-                    $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'mixed');
54
+                    $phpcsFile->recordMetric( $stackPtr, 'PHP type case', 'mixed' );
55 55
                 }
56 56
 
57 57
                 $error = 'PHP type casts must be lowercase; expected "%s" but found "%s"';
58 58
                 $data  = [
59
-                    strtolower($tokens[$stackPtr]['content']),
60
-                    $tokens[$stackPtr]['content'],
59
+                    strtolower( $tokens[ $stackPtr ][ 'content' ] ),
60
+                    $tokens[ $stackPtr ][ 'content' ],
61 61
                 ];
62 62
 
63
-                $fix = $phpcsFile->addFixableError($error, $stackPtr, 'TypeCastFound', $data);
64
-                if ($fix === true) {
65
-                    $phpcsFile->fixer->replaceToken($stackPtr, strtolower($tokens[$stackPtr]['content']));
63
+                $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'TypeCastFound', $data );
64
+                if ( $fix === true ) {
65
+                    $phpcsFile->fixer->replaceToken( $stackPtr, strtolower( $tokens[ $stackPtr ][ 'content' ] ) );
66 66
                 }
67 67
             } else {
68
-                $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'lower');
68
+                $phpcsFile->recordMetric( $stackPtr, 'PHP type case', 'lower' );
69 69
             }//end if
70 70
 
71 71
             return;
@@ -85,73 +85,73 @@  discard block
 block discarded – undo
85 85
             'object'   => true,
86 86
         ];
87 87
 
88
-        $props = $phpcsFile->getMethodProperties($stackPtr);
88
+        $props = $phpcsFile->getMethodProperties( $stackPtr );
89 89
 
90 90
         // Strip off potential nullable indication.
91
-        $returnType      = ltrim($props['return_type'], '?');
92
-        $returnTypeLower = strtolower($returnType);
91
+        $returnType      = ltrim( $props[ 'return_type' ], '?' );
92
+        $returnTypeLower = strtolower( $returnType );
93 93
 
94
-        if ($returnType !== ''
95
-            && isset($phpTypes[$returnTypeLower]) === true
94
+        if ( $returnType !== ''
95
+            && isset( $phpTypes[ $returnTypeLower ] ) === true
96 96
         ) {
97 97
             // A function return type.
98
-            if ($returnTypeLower !== $returnType) {
99
-                if ($returnType === strtoupper($returnType)) {
100
-                    $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'upper');
98
+            if ( $returnTypeLower !== $returnType ) {
99
+                if ( $returnType === strtoupper( $returnType ) ) {
100
+                    $phpcsFile->recordMetric( $stackPtr, 'PHP type case', 'upper' );
101 101
                 } else {
102
-                    $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'mixed');
102
+                    $phpcsFile->recordMetric( $stackPtr, 'PHP type case', 'mixed' );
103 103
                 }
104 104
 
105 105
                 $error = 'PHP return type declarations must be lowercase; expected "%s" but found "%s"';
106
-                $token = $props['return_type_token'];
106
+                $token = $props[ 'return_type_token' ];
107 107
                 $data  = [
108 108
                     $returnTypeLower,
109 109
                     $returnType,
110 110
                 ];
111 111
 
112
-                $fix = $phpcsFile->addFixableError($error, $token, 'ReturnTypeFound', $data);
113
-                if ($fix === true) {
114
-                    $phpcsFile->fixer->replaceToken($token, $returnTypeLower);
112
+                $fix = $phpcsFile->addFixableError( $error, $token, 'ReturnTypeFound', $data );
113
+                if ( $fix === true ) {
114
+                    $phpcsFile->fixer->replaceToken( $token, $returnTypeLower );
115 115
                 }
116 116
             } else {
117
-                $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'lower');
117
+                $phpcsFile->recordMetric( $stackPtr, 'PHP type case', 'lower' );
118 118
             }//end if
119 119
         }//end if
120 120
 
121
-        $params = $phpcsFile->getMethodParameters($stackPtr);
122
-        if (empty($params) === true) {
121
+        $params = $phpcsFile->getMethodParameters( $stackPtr );
122
+        if ( empty( $params ) === true ) {
123 123
             return;
124 124
         }
125 125
 
126
-        foreach ($params as $param) {
126
+        foreach ( $params as $param ) {
127 127
             // Strip off potential nullable indication.
128
-            $typeHint      = ltrim($param['type_hint'], '?');
129
-            $typeHintLower = strtolower($typeHint);
128
+            $typeHint      = ltrim( $param[ 'type_hint' ], '?' );
129
+            $typeHintLower = strtolower( $typeHint );
130 130
 
131
-            if ($typeHint !== ''
132
-                && isset($phpTypes[$typeHintLower]) === true
131
+            if ( $typeHint !== ''
132
+                && isset( $phpTypes[ $typeHintLower ] ) === true
133 133
             ) {
134 134
                 // A function return type.
135
-                if ($typeHintLower !== $typeHint) {
136
-                    if ($typeHint === strtoupper($typeHint)) {
137
-                        $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'upper');
135
+                if ( $typeHintLower !== $typeHint ) {
136
+                    if ( $typeHint === strtoupper( $typeHint ) ) {
137
+                        $phpcsFile->recordMetric( $stackPtr, 'PHP type case', 'upper' );
138 138
                     } else {
139
-                        $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'mixed');
139
+                        $phpcsFile->recordMetric( $stackPtr, 'PHP type case', 'mixed' );
140 140
                     }
141 141
 
142 142
                     $error = 'PHP parameter type declarations must be lowercase; expected "%s" but found "%s"';
143
-                    $token = $param['type_hint_token'];
143
+                    $token = $param[ 'type_hint_token' ];
144 144
                     $data  = [
145 145
                         $typeHintLower,
146 146
                         $typeHint,
147 147
                     ];
148 148
 
149
-                    $fix = $phpcsFile->addFixableError($error, $token, 'ParamTypeFound', $data);
150
-                    if ($fix === true) {
151
-                        $phpcsFile->fixer->replaceToken($token, $typeHintLower);
149
+                    $fix = $phpcsFile->addFixableError( $error, $token, 'ParamTypeFound', $data );
150
+                    if ( $fix === true ) {
151
+                        $phpcsFile->fixer->replaceToken( $token, $typeHintLower );
152 152
                     }
153 153
                 } else {
154
-                    $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'lower');
154
+                    $phpcsFile->recordMetric( $stackPtr, 'PHP type case', 'lower' );
155 155
                 }//end if
156 156
             }//end if
157 157
         }//end foreach
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function register()
42 42
     {
43
-        if ($this->phpVersion === null) {
44
-            $this->phpVersion = Config::getConfigData('php_version');
45
-            if ($this->phpVersion === null) {
43
+        if ( $this->phpVersion === null ) {
44
+            $this->phpVersion = Config::getConfigData( 'php_version' );
45
+            if ( $this->phpVersion === null ) {
46 46
                 $this->phpVersion = PHP_VERSION_ID;
47 47
             }
48 48
         }
49 49
 
50
-        if ($this->phpVersion < 70000) {
51
-            $this->aspTags = (bool) ini_get('asp_tags');
50
+        if ( $this->phpVersion < 70000 ) {
51
+            $this->aspTags = (bool)ini_get( 'asp_tags' );
52 52
         }
53 53
 
54 54
         return [
@@ -69,36 +69,36 @@  discard block
 block discarded – undo
69 69
      *
70 70
      * @return void
71 71
      */
72
-    public function process(File $phpcsFile, $stackPtr)
72
+    public function process( File $phpcsFile, $stackPtr )
73 73
     {
74 74
         $tokens  = $phpcsFile->getTokens();
75
-        $openTag = $tokens[$stackPtr];
76
-        $content = $openTag['content'];
75
+        $openTag = $tokens[ $stackPtr ];
76
+        $content = $openTag[ 'content' ];
77 77
 
78
-        if (trim($content) === '') {
78
+        if ( trim( $content ) === '' ) {
79 79
             return;
80 80
         }
81 81
 
82
-        if ($openTag['code'] === T_OPEN_TAG) {
83
-            if ($content === '<%') {
82
+        if ( $openTag[ 'code' ] === T_OPEN_TAG ) {
83
+            if ( $content === '<%' ) {
84 84
                 $error     = 'ASP style opening tag used; expected "<?php" but found "%s"';
85
-                $closer    = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '%>');
85
+                $closer    = $this->findClosingTag( $phpcsFile, $tokens, $stackPtr, '%>' );
86 86
                 $errorCode = 'ASPOpenTagFound';
87
-            } else if (strpos($content, '<script ') !== false) {
87
+            } else if ( strpos( $content, '<script ' ) !== false ) {
88 88
                 $error     = 'Script style opening tag used; expected "<?php" but found "%s"';
89
-                $closer    = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '</script>');
89
+                $closer    = $this->findClosingTag( $phpcsFile, $tokens, $stackPtr, '</script>' );
90 90
                 $errorCode = 'ScriptOpenTagFound';
91 91
             }
92 92
 
93
-            if (isset($error, $closer, $errorCode) === true) {
94
-                $data = [$content];
93
+            if ( isset( $error, $closer, $errorCode ) === true ) {
94
+                $data = [ $content ];
95 95
 
96
-                if ($closer === false) {
97
-                    $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
96
+                if ( $closer === false ) {
97
+                    $phpcsFile->addError( $error, $stackPtr, $errorCode, $data );
98 98
                 } else {
99
-                    $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode, $data);
100
-                    if ($fix === true) {
101
-                        $this->addChangeset($phpcsFile, $tokens, $stackPtr, $closer);
99
+                    $fix = $phpcsFile->addFixableError( $error, $stackPtr, $errorCode, $data );
100
+                    if ( $fix === true ) {
101
+                        $this->addChangeset( $phpcsFile, $tokens, $stackPtr, $closer );
102 102
                     }
103 103
                 }
104 104
             }
@@ -106,24 +106,24 @@  discard block
 block discarded – undo
106 106
             return;
107 107
         }//end if
108 108
 
109
-        if ($openTag['code'] === T_OPEN_TAG_WITH_ECHO && $content === '<%=') {
109
+        if ( $openTag[ 'code' ] === T_OPEN_TAG_WITH_ECHO && $content === '<%=' ) {
110 110
             $error   = 'ASP style opening tag used with echo; expected "<?php echo %s ..." but found "%s %s ..."';
111
-            $nextVar = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
112
-            $snippet = $this->getSnippet($tokens[$nextVar]['content']);
111
+            $nextVar = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
112
+            $snippet = $this->getSnippet( $tokens[ $nextVar ][ 'content' ] );
113 113
             $data    = [
114 114
                 $snippet,
115 115
                 $content,
116 116
                 $snippet,
117 117
             ];
118 118
 
119
-            $closer = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '%>');
119
+            $closer = $this->findClosingTag( $phpcsFile, $tokens, $stackPtr, '%>' );
120 120
 
121
-            if ($closer === false) {
122
-                $phpcsFile->addError($error, $stackPtr, 'ASPShortOpenTagFound', $data);
121
+            if ( $closer === false ) {
122
+                $phpcsFile->addError( $error, $stackPtr, 'ASPShortOpenTagFound', $data );
123 123
             } else {
124
-                $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ASPShortOpenTagFound', $data);
125
-                if ($fix === true) {
126
-                    $this->addChangeset($phpcsFile, $tokens, $stackPtr, $closer, true);
124
+                $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'ASPShortOpenTagFound', $data );
125
+                if ( $fix === true ) {
126
+                    $this->addChangeset( $phpcsFile, $tokens, $stackPtr, $closer, true );
127 127
                 }
128 128
             }
129 129
 
@@ -131,30 +131,30 @@  discard block
 block discarded – undo
131 131
         }//end if
132 132
 
133 133
         // Account for incorrect script open tags.
134
-        if ($openTag['code'] === T_INLINE_HTML
135
-            && preg_match('`(<script (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match) === 1
134
+        if ( $openTag[ 'code' ] === T_INLINE_HTML
135
+            && preg_match( '`(<script (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match ) === 1
136 136
         ) {
137 137
             $error   = 'Script style opening tag used; expected "<?php" but found "%s"';
138
-            $snippet = $this->getSnippet($content, $match[1]);
139
-            $data    = [$match[1].$snippet];
138
+            $snippet = $this->getSnippet( $content, $match[ 1 ] );
139
+            $data    = [ $match[ 1 ] . $snippet ];
140 140
 
141
-            $phpcsFile->addError($error, $stackPtr, 'ScriptOpenTagFound', $data);
141
+            $phpcsFile->addError( $error, $stackPtr, 'ScriptOpenTagFound', $data );
142 142
             return;
143 143
         }
144 144
 
145
-        if ($openTag['code'] === T_INLINE_HTML && $this->aspTags === false) {
146
-            if (strpos($content, '<%=') !== false) {
145
+        if ( $openTag[ 'code' ] === T_INLINE_HTML && $this->aspTags === false ) {
146
+            if ( strpos( $content, '<%=' ) !== false ) {
147 147
                 $error   = 'Possible use of ASP style short opening tags detected; found: %s';
148
-                $snippet = $this->getSnippet($content, '<%=');
149
-                $data    = ['<%='.$snippet];
148
+                $snippet = $this->getSnippet( $content, '<%=' );
149
+                $data    = [ '<%=' . $snippet ];
150 150
 
151
-                $phpcsFile->addWarning($error, $stackPtr, 'MaybeASPShortOpenTagFound', $data);
152
-            } else if (strpos($content, '<%') !== false) {
151
+                $phpcsFile->addWarning( $error, $stackPtr, 'MaybeASPShortOpenTagFound', $data );
152
+            } else if ( strpos( $content, '<%' ) !== false ) {
153 153
                 $error   = 'Possible use of ASP style opening tags detected; found: %s';
154
-                $snippet = $this->getSnippet($content, '<%');
155
-                $data    = ['<%'.$snippet];
154
+                $snippet = $this->getSnippet( $content, '<%' );
155
+                $data    = [ '<%' . $snippet ];
156 156
 
157
-                $phpcsFile->addWarning($error, $stackPtr, 'MaybeASPOpenTagFound', $data);
157
+                $phpcsFile->addWarning( $error, $stackPtr, 'MaybeASPOpenTagFound', $data );
158 158
             }
159 159
         }
160 160
 
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
      *
171 171
      * @return string
172 172
      */
173
-    protected function getSnippet($content, $start='', $length=40)
173
+    protected function getSnippet( $content, $start = '', $length = 40 )
174 174
     {
175 175
         $startPos = 0;
176 176
 
177
-        if ($start !== '') {
178
-            $startPos = strpos($content, $start);
179
-            if ($startPos !== false) {
180
-                $startPos += strlen($start);
177
+        if ( $start !== '' ) {
178
+            $startPos = strpos( $content, $start );
179
+            if ( $startPos !== false ) {
180
+                $startPos += strlen( $start );
181 181
             }
182 182
         }
183 183
 
184
-        $snippet = substr($content, $startPos, $length);
185
-        if ((strlen($content) - $startPos) > $length) {
184
+        $snippet = substr( $content, $startPos, $length );
185
+        if ( ( strlen( $content ) - $startPos ) > $length ) {
186 186
             $snippet .= '...';
187 187
         }
188 188
 
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
      *
203 203
      * @return int|false Pointer to the position in the stack for the closing tag or false if not found.
204 204
      */
205
-    protected function findClosingTag(File $phpcsFile, $tokens, $stackPtr, $content)
205
+    protected function findClosingTag( File $phpcsFile, $tokens, $stackPtr, $content )
206 206
     {
207
-        $closer = $phpcsFile->findNext(T_CLOSE_TAG, ($stackPtr + 1));
207
+        $closer = $phpcsFile->findNext( T_CLOSE_TAG, ( $stackPtr + 1 ) );
208 208
 
209
-        if ($closer !== false && $content === trim($tokens[$closer]['content'])) {
209
+        if ( $closer !== false && $content === trim( $tokens[ $closer ][ 'content' ] ) ) {
210 210
             return $closer;
211 211
         }
212 212
 
@@ -226,25 +226,25 @@  discard block
 block discarded – undo
226 226
      *
227 227
      * @return void
228 228
      */
229
-    protected function addChangeset(File $phpcsFile, $tokens, $openTagPointer, $closeTagPointer, $echo=false)
229
+    protected function addChangeset( File $phpcsFile, $tokens, $openTagPointer, $closeTagPointer, $echo = false )
230 230
     {
231 231
         // Build up the open tag replacement and make sure there's always whitespace behind it.
232 232
         $openReplacement = '<?php';
233
-        if ($echo === true) {
233
+        if ( $echo === true ) {
234 234
             $openReplacement .= ' echo';
235 235
         }
236 236
 
237
-        if ($tokens[($openTagPointer + 1)]['code'] !== T_WHITESPACE) {
237
+        if ( $tokens[ ( $openTagPointer + 1 ) ][ 'code' ] !== T_WHITESPACE ) {
238 238
             $openReplacement .= ' ';
239 239
         }
240 240
 
241 241
         // Make sure we don't remove any line breaks after the closing tag.
242
-        $regex            = '`'.preg_quote(trim($tokens[$closeTagPointer]['content'])).'`';
243
-        $closeReplacement = preg_replace($regex, '?>', $tokens[$closeTagPointer]['content']);
242
+        $regex            = '`' . preg_quote( trim( $tokens[ $closeTagPointer ][ 'content' ] ) ) . '`';
243
+        $closeReplacement = preg_replace( $regex, '?>', $tokens[ $closeTagPointer ][ 'content' ] );
244 244
 
245 245
         $phpcsFile->fixer->beginChangeset();
246
-        $phpcsFile->fixer->replaceToken($openTagPointer, $openReplacement);
247
-        $phpcsFile->fixer->replaceToken($closeTagPointer, $closeReplacement);
246
+        $phpcsFile->fixer->replaceToken( $openTagPointer, $openReplacement );
247
+        $phpcsFile->fixer->replaceToken( $closeTagPointer, $closeReplacement );
248 248
         $phpcsFile->fixer->endChangeset();
249 249
 
250 250
     }//end addChangeset()
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -51,16 +51,16 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @return void
53 53
      */
54
-    public function process(File $phpcsFile, $stackPtr)
54
+    public function process( File $phpcsFile, $stackPtr )
55 55
     {
56 56
         $tokens   = $phpcsFile->getTokens();
57
-        $keyword  = $tokens[$stackPtr]['content'];
58
-        $expected = strtolower($keyword);
59
-        if ($keyword !== $expected) {
60
-            if ($keyword === strtoupper($keyword)) {
61
-                $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'upper');
57
+        $keyword  = $tokens[ $stackPtr ][ 'content' ];
58
+        $expected = strtolower( $keyword );
59
+        if ( $keyword !== $expected ) {
60
+            if ( $keyword === strtoupper( $keyword ) ) {
61
+                $phpcsFile->recordMetric( $stackPtr, 'PHP constant case', 'upper' );
62 62
             } else {
63
-                $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'mixed');
63
+                $phpcsFile->recordMetric( $stackPtr, 'PHP constant case', 'mixed' );
64 64
             }
65 65
 
66 66
             $error = 'TRUE, FALSE and NULL must be lowercase; expected "%s" but found "%s"';
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
                 $keyword,
70 70
             ];
71 71
 
72
-            $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
73
-            if ($fix === true) {
74
-                $phpcsFile->fixer->replaceToken($stackPtr, $expected);
72
+            $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'Found', $data );
73
+            if ( $fix === true ) {
74
+                $phpcsFile->fixer->replaceToken( $stackPtr, $expected );
75 75
             }
76 76
         } else {
77
-            $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'lower');
77
+            $phpcsFile->recordMetric( $stackPtr, 'PHP constant case', 'lower' );
78 78
         }
79 79
 
80 80
     }//end process()
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @var string[]
38 38
      */
39
-    protected $forbiddenFunctionNames = [];
39
+    protected $forbiddenFunctionNames = [ ];
40 40
 
41 41
     /**
42 42
      * If true, forbidden functions will be considered regular expressions.
@@ -62,46 +62,46 @@  discard block
 block discarded – undo
62 62
     {
63 63
         // Everyone has had a chance to figure out what forbidden functions
64 64
         // they want to check for, so now we can cache out the list.
65
-        $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
65
+        $this->forbiddenFunctionNames = array_keys( $this->forbiddenFunctions );
66 66
 
67
-        if ($this->patternMatch === true) {
68
-            foreach ($this->forbiddenFunctionNames as $i => $name) {
69
-                $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
67
+        if ( $this->patternMatch === true ) {
68
+            foreach ( $this->forbiddenFunctionNames as $i => $name ) {
69
+                $this->forbiddenFunctionNames[ $i ] = '/' . $name . '/i';
70 70
             }
71 71
 
72
-            return [T_STRING];
72
+            return [ T_STRING ];
73 73
         }
74 74
 
75 75
         // If we are not pattern matching, we need to work out what
76 76
         // tokens to listen for.
77 77
         $hasHaltCompiler = false;
78 78
         $string          = '<?php ';
79
-        foreach ($this->forbiddenFunctionNames as $name) {
80
-            if ($name === '__halt_compiler') {
79
+        foreach ( $this->forbiddenFunctionNames as $name ) {
80
+            if ( $name === '__halt_compiler' ) {
81 81
                 $hasHaltCompiler = true;
82 82
             } else {
83
-                $string .= $name.'();';
83
+                $string .= $name . '();';
84 84
             }
85 85
         }
86 86
 
87
-        if ($hasHaltCompiler === true) {
87
+        if ( $hasHaltCompiler === true ) {
88 88
             $string .= '__halt_compiler();';
89 89
         }
90 90
 
91
-        $register = [];
91
+        $register = [ ];
92 92
 
93
-        $tokens = token_get_all($string);
94
-        array_shift($tokens);
95
-        foreach ($tokens as $token) {
96
-            if (is_array($token) === true) {
97
-                $register[] = $token[0];
93
+        $tokens = token_get_all( $string );
94
+        array_shift( $tokens );
95
+        foreach ( $tokens as $token ) {
96
+            if ( is_array( $token ) === true ) {
97
+                $register[ ] = $token[ 0 ];
98 98
             }
99 99
         }
100 100
 
101
-        $this->forbiddenFunctionNames = array_map('strtolower', $this->forbiddenFunctionNames);
102
-        $this->forbiddenFunctions     = array_combine($this->forbiddenFunctionNames, $this->forbiddenFunctions);
101
+        $this->forbiddenFunctionNames = array_map( 'strtolower', $this->forbiddenFunctionNames );
102
+        $this->forbiddenFunctions     = array_combine( $this->forbiddenFunctionNames, $this->forbiddenFunctions );
103 103
 
104
-        return array_unique($register);
104
+        return array_unique( $register );
105 105
 
106 106
     }//end register()
107 107
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      *
116 116
      * @return void
117 117
      */
118
-    public function process(File $phpcsFile, $stackPtr)
118
+    public function process( File $phpcsFile, $stackPtr )
119 119
     {
120 120
         $tokens = $phpcsFile->getTokens();
121 121
 
@@ -134,38 +134,38 @@  discard block
 block discarded – undo
134 134
             T_IMPLEMENTS      => true,
135 135
         ];
136 136
 
137
-        $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
137
+        $prevToken = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
138 138
 
139 139
         // If function call is directly preceded by a NS_SEPARATOR it points to the
140 140
         // global namespace, so we should still catch it.
141
-        if ($tokens[$prevToken]['code'] === T_NS_SEPARATOR) {
142
-            $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($prevToken - 1), null, true);
143
-            if ($tokens[$prevToken]['code'] === T_STRING) {
141
+        if ( $tokens[ $prevToken ][ 'code' ] === T_NS_SEPARATOR ) {
142
+            $prevToken = $phpcsFile->findPrevious( T_WHITESPACE, ( $prevToken - 1 ), null, true );
143
+            if ( $tokens[ $prevToken ][ 'code' ] === T_STRING ) {
144 144
                 // Not in the global namespace.
145 145
                 return;
146 146
             }
147 147
         }
148 148
 
149
-        if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
149
+        if ( isset( $ignore[ $tokens[ $prevToken ][ 'code' ] ] ) === true ) {
150 150
             // Not a call to a PHP function.
151 151
             return;
152 152
         }
153 153
 
154
-        $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
155
-        if (isset($ignore[$tokens[$nextToken]['code']]) === true) {
154
+        $nextToken = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
155
+        if ( isset( $ignore[ $tokens[ $nextToken ][ 'code' ] ] ) === true ) {
156 156
             // Not a call to a PHP function.
157 157
             return;
158 158
         }
159 159
 
160
-        if ($tokens[$stackPtr]['code'] === T_STRING && $tokens[$nextToken]['code'] !== T_OPEN_PARENTHESIS) {
160
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_STRING && $tokens[ $nextToken ][ 'code' ] !== T_OPEN_PARENTHESIS ) {
161 161
             // Not a call to a PHP function.
162 162
             return;
163 163
         }
164 164
 
165
-        $function = strtolower($tokens[$stackPtr]['content']);
165
+        $function = strtolower( $tokens[ $stackPtr ][ 'content' ] );
166 166
         $pattern  = null;
167 167
 
168
-        if ($this->patternMatch === true) {
168
+        if ( $this->patternMatch === true ) {
169 169
             $count   = 0;
170 170
             $pattern = preg_replace(
171 171
                 $this->forbiddenFunctionNames,
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
                 $count
176 176
             );
177 177
 
178
-            if ($count === 0) {
178
+            if ( $count === 0 ) {
179 179
                 return;
180 180
             }
181 181
 
182 182
             // Remove the pattern delimiters and modifier.
183
-            $pattern = substr($pattern, 1, -2);
183
+            $pattern = substr( $pattern, 1, -2 );
184 184
         } else {
185
-            if (in_array($function, $this->forbiddenFunctionNames, true) === false) {
185
+            if ( in_array( $function, $this->forbiddenFunctionNames, true ) === false ) {
186 186
                 return;
187 187
             }
188 188
         }//end if
189 189
 
190
-        $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['content'], $pattern);
190
+        $this->addError( $phpcsFile, $stackPtr, $tokens[ $stackPtr ][ 'content' ], $pattern );
191 191
 
192 192
     }//end process()
193 193
 
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
      *
204 204
      * @return void
205 205
      */
206
-    protected function addError($phpcsFile, $stackPtr, $function, $pattern=null)
206
+    protected function addError( $phpcsFile, $stackPtr, $function, $pattern = null )
207 207
     {
208
-        $data  = [$function];
208
+        $data  = [ $function ];
209 209
         $error = 'The use of function %s() is ';
210
-        if ($this->error === true) {
210
+        if ( $this->error === true ) {
211 211
             $type   = 'Found';
212 212
             $error .= 'forbidden';
213 213
         } else {
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
             $error .= 'discouraged';
216 216
         }
217 217
 
218
-        if ($pattern === null) {
219
-            $pattern = strtolower($function);
218
+        if ( $pattern === null ) {
219
+            $pattern = strtolower( $function );
220 220
         }
221 221
 
222
-        if ($this->forbiddenFunctions[$pattern] !== null
223
-            && $this->forbiddenFunctions[$pattern] !== 'null'
222
+        if ( $this->forbiddenFunctions[ $pattern ] !== null
223
+            && $this->forbiddenFunctions[ $pattern ] !== 'null'
224 224
         ) {
225 225
             $type  .= 'WithAlternative';
226
-            $data[] = $this->forbiddenFunctions[$pattern];
226
+            $data[ ] = $this->forbiddenFunctions[ $pattern ];
227 227
             $error .= '; use %s() instead';
228 228
         }
229 229
 
230
-        if ($this->error === true) {
231
-            $phpcsFile->addError($error, $stackPtr, $type, $data);
230
+        if ( $this->error === true ) {
231
+            $phpcsFile->addError( $error, $stackPtr, $type, $data );
232 232
         } else {
233
-            $phpcsFile->addWarning($error, $stackPtr, $type, $data);
233
+            $phpcsFile->addWarning( $error, $stackPtr, $type, $data );
234 234
         }
235 235
 
236 236
     }//end addError()
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @var array<string, string|null>
23 23
      */
24
-    public $forbiddenFunctions = [];
24
+    public $forbiddenFunctions = [ ];
25 25
 
26 26
 
27 27
     /**
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $functions = get_defined_functions();
35 35
 
36
-        foreach ($functions['internal'] as $functionName) {
37
-            $function = new \ReflectionFunction($functionName);
38
-            if (method_exists($function, 'isDeprecated') === false) {
36
+        foreach ( $functions[ 'internal' ] as $functionName ) {
37
+            $function = new \ReflectionFunction( $functionName );
38
+            if ( method_exists( $function, 'isDeprecated' ) === false ) {
39 39
                 break;
40 40
             }
41 41
 
42
-            if ($function->isDeprecated() === true) {
43
-                $this->forbiddenFunctions[$functionName] = null;
42
+            if ( $function->isDeprecated() === true ) {
43
+                $this->forbiddenFunctions[ $functionName ] = null;
44 44
             }
45 45
         }
46 46
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @return void
60 60
      */
61
-    protected function addError($phpcsFile, $stackPtr, $function, $pattern=null)
61
+    protected function addError( $phpcsFile, $stackPtr, $function, $pattern = null )
62 62
     {
63
-        $data  = [$function];
63
+        $data  = [ $function ];
64 64
         $error = 'Function %s() has been deprecated';
65 65
         $type  = 'Deprecated';
66 66
 
67
-        if ($this->error === true) {
68
-            $phpcsFile->addError($error, $stackPtr, $type, $data);
67
+        if ( $this->error === true ) {
68
+            $phpcsFile->addError( $error, $stackPtr, $type, $data );
69 69
         } else {
70
-            $phpcsFile->addWarning($error, $stackPtr, $type, $data);
70
+            $phpcsFile->addWarning( $error, $stackPtr, $type, $data );
71 71
         }
72 72
 
73 73
     }//end addError()
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function register()
39 39
     {
40
-        return [T_ASPERAND];
40
+        return [ T_ASPERAND ];
41 41
 
42 42
     }//end register()
43 43
 
@@ -51,24 +51,24 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @return void
53 53
      */
54
-    public function process(File $phpcsFile, $stackPtr)
54
+    public function process( File $phpcsFile, $stackPtr )
55 55
     {
56 56
         // Prepare the "Found" string to display.
57 57
         $contextLength  = 4;
58
-        $endOfStatement = $phpcsFile->findEndOfStatement($stackPtr, T_COMMA);
59
-        if (($endOfStatement - $stackPtr) < $contextLength) {
60
-            $contextLength = ($endOfStatement - $stackPtr);
58
+        $endOfStatement = $phpcsFile->findEndOfStatement( $stackPtr, T_COMMA );
59
+        if ( ( $endOfStatement - $stackPtr ) < $contextLength ) {
60
+            $contextLength = ( $endOfStatement - $stackPtr );
61 61
         }
62 62
 
63
-        $found = $phpcsFile->getTokensAsString($stackPtr, $contextLength);
64
-        $found = str_replace(["\t", "\n", "\r"], ' ', $found).'...';
63
+        $found = $phpcsFile->getTokensAsString( $stackPtr, $contextLength );
64
+        $found = str_replace( [ "\t", "\n", "\r" ], ' ', $found ) . '...';
65 65
 
66
-        if ($this->error === true) {
66
+        if ( $this->error === true ) {
67 67
             $error = 'Silencing errors is forbidden; found: %s';
68
-            $phpcsFile->addError($error, $stackPtr, 'Forbidden', [$found]);
68
+            $phpcsFile->addError( $error, $stackPtr, 'Forbidden', [ $found ] );
69 69
         } else {
70 70
             $error = 'Silencing errors is discouraged; found: %s';
71
-            $phpcsFile->addWarning($error, $stackPtr, 'Discouraged', [$found]);
71
+            $phpcsFile->addWarning( $error, $stackPtr, 'Discouraged', [ $found ] );
72 72
         }
73 73
 
74 74
     }//end process()
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@
 block discarded – undo
40 40
      *
41 41
      * @return void
42 42
      */
43
-    public function process(File $phpcsFile, $stackPtr)
43
+    public function process( File $phpcsFile, $stackPtr )
44 44
     {
45
-        $phpcsFile->addWarning('Use of the GOTO language construct is discouraged', $stackPtr, 'Found');
45
+        $phpcsFile->addWarning( 'Use of the GOTO language construct is discouraged', $stackPtr, 'Found' );
46 46
 
47 47
     }//end process()
48 48
 
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php 1 patch
Spacing   +64 added lines, -64 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 [T_OPEN_TAG];
37
+        return [ T_OPEN_TAG ];
38 38
 
39 39
     }//end register()
40 40
 
@@ -48,7 +48,7 @@  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 54
         $error  = 'Merge conflict boundary found; type: %s';
@@ -69,48 +69,48 @@  discard block
 block discarded – undo
69 69
             T_ZSR                     => true,
70 70
         ];
71 71
 
72
-        for ($i = 0; $i < $phpcsFile->numTokens; $i++) {
73
-            if ($tokens[$i]['column'] !== 1 || isset($checkTokens[$tokens[$i]['code']]) === false) {
72
+        for ( $i = 0; $i < $phpcsFile->numTokens; $i++ ) {
73
+            if ( $tokens[ $i ][ 'column' ] !== 1 || isset( $checkTokens[ $tokens[ $i ][ 'code' ] ] ) === false ) {
74 74
                 continue;
75 75
             }
76 76
 
77
-            if ($phpcsFile->tokenizerType !== 'JS') {
78
-                switch ($tokens[$i]['code']) {
77
+            if ( $phpcsFile->tokenizerType !== 'JS' ) {
78
+                switch ( $tokens[ $i ][ 'code' ] ) {
79 79
                 // Check for first non-comment, non-heredoc/nowdoc, non-inline HTML merge conflict opener.
80 80
                 case T_SL:
81
-                    if (isset($tokens[($i + 1)], $tokens[($i + 2)]) !== false
82
-                        && $tokens[($i + 1)]['code'] === T_SL
83
-                        && $tokens[($i + 2)]['code'] === T_STRING
84
-                        && trim($tokens[($i + 2)]['content']) === '<<< HEAD'
81
+                    if ( isset( $tokens[ ( $i + 1 ) ], $tokens[ ( $i + 2 ) ] ) !== false
82
+                        && $tokens[ ( $i + 1 ) ][ 'code' ] === T_SL
83
+                        && $tokens[ ( $i + 2 ) ][ 'code' ] === T_STRING
84
+                        && trim( $tokens[ ( $i + 2 ) ][ 'content' ] ) === '<<< HEAD'
85 85
                     ) {
86
-                        $phpcsFile->addError($error, $i, 'OpenerFound', ['opener']);
86
+                        $phpcsFile->addError( $error, $i, 'OpenerFound', [ 'opener' ] );
87 87
                         $i += 2;
88 88
                     }
89 89
                     break;
90 90
 
91 91
                 // Check for merge conflict closer which was opened in a heredoc/nowdoc.
92 92
                 case T_SR:
93
-                    if (isset($tokens[($i + 1)], $tokens[($i + 2)], $tokens[($i + 3)], $tokens[($i + 4)]) !== false
94
-                        && $tokens[($i + 1)]['code'] === T_SR
95
-                        && $tokens[($i + 2)]['code'] === T_SR
96
-                        && $tokens[($i + 3)]['code'] === T_GREATER_THAN
97
-                        && $tokens[($i + 4)]['code'] === T_WHITESPACE
98
-                        && $tokens[($i + 4)]['content'] === ' '
93
+                    if ( isset( $tokens[ ( $i + 1 ) ], $tokens[ ( $i + 2 ) ], $tokens[ ( $i + 3 ) ], $tokens[ ( $i + 4 ) ] ) !== false
94
+                        && $tokens[ ( $i + 1 ) ][ 'code' ] === T_SR
95
+                        && $tokens[ ( $i + 2 ) ][ 'code' ] === T_SR
96
+                        && $tokens[ ( $i + 3 ) ][ 'code' ] === T_GREATER_THAN
97
+                        && $tokens[ ( $i + 4 ) ][ 'code' ] === T_WHITESPACE
98
+                        && $tokens[ ( $i + 4 ) ][ 'content' ] === ' '
99 99
                     ) {
100
-                        $phpcsFile->addError($error, $i, 'CloserFound', ['closer']);
100
+                        $phpcsFile->addError( $error, $i, 'CloserFound', [ 'closer' ] );
101 101
                         $i += 4;
102 102
                     }
103 103
                     break;
104 104
 
105 105
                 // Check for merge conflict delimiter which opened in a CSS comment and closed outside.
106 106
                 case T_IS_IDENTICAL:
107
-                    if (isset($tokens[($i + 1)], $tokens[($i + 2)], $tokens[($i + 3)]) !== false
108
-                        && $tokens[($i + 1)]['code'] === T_IS_IDENTICAL
109
-                        && $tokens[($i + 2)]['code'] === T_EQUAL
110
-                        && $tokens[($i + 3)]['code'] === T_WHITESPACE
111
-                        && $tokens[($i + 3)]['content'] === "\n"
107
+                    if ( isset( $tokens[ ( $i + 1 ) ], $tokens[ ( $i + 2 ) ], $tokens[ ( $i + 3 ) ] ) !== false
108
+                        && $tokens[ ( $i + 1 ) ][ 'code' ] === T_IS_IDENTICAL
109
+                        && $tokens[ ( $i + 2 ) ][ 'code' ] === T_EQUAL
110
+                        && $tokens[ ( $i + 3 ) ][ 'code' ] === T_WHITESPACE
111
+                        && $tokens[ ( $i + 3 ) ][ 'content' ] === "\n"
112 112
                     ) {
113
-                        $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']);
113
+                        $phpcsFile->addError( $error, $i, 'DelimiterFound', [ 'delimiter' ] );
114 114
                         $i += 3;
115 115
                     }
116 116
                     break;
@@ -124,66 +124,66 @@  discard block
 block discarded – undo
124 124
                 case T_INLINE_HTML:
125 125
                 case T_HEREDOC:
126 126
                 case T_NOWDOC:
127
-                    if (substr($tokens[$i]['content'], 0, 12) === '<<<<<<< HEAD') {
128
-                        $phpcsFile->addError($error, $i, 'OpenerFound', ['opener']);
127
+                    if ( substr( $tokens[ $i ][ 'content' ], 0, 12 ) === '<<<<<<< HEAD' ) {
128
+                        $phpcsFile->addError( $error, $i, 'OpenerFound', [ 'opener' ] );
129 129
                         break;
130
-                    } else if (substr($tokens[$i]['content'], 0, 8) === '>>>>>>> ') {
131
-                        $phpcsFile->addError($error, $i, 'CloserFound', ['closer']);
130
+                    } else if ( substr( $tokens[ $i ][ 'content' ], 0, 8 ) === '>>>>>>> ' ) {
131
+                        $phpcsFile->addError( $error, $i, 'CloserFound', [ 'closer' ] );
132 132
                         break;
133 133
                     }
134 134
 
135
-                    if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) {
136
-                        if ($tokens[$i]['content'] === '======='
137
-                            && $tokens[($i + 1)]['code'] === T_DOC_COMMENT_WHITESPACE
135
+                    if ( $tokens[ $i ][ 'code' ] === T_DOC_COMMENT_STRING ) {
136
+                        if ( $tokens[ $i ][ 'content' ] === '======='
137
+                            && $tokens[ ( $i + 1 ) ][ 'code' ] === T_DOC_COMMENT_WHITESPACE
138 138
                         ) {
139
-                            $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']);
139
+                            $phpcsFile->addError( $error, $i, 'DelimiterFound', [ 'delimiter' ] );
140 140
                             break;
141 141
                         }
142 142
                     } else {
143
-                        if ($tokens[$i]['content'] === "=======\n") {
144
-                            $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']);
143
+                        if ( $tokens[ $i ][ 'content' ] === "=======\n" ) {
144
+                            $phpcsFile->addError( $error, $i, 'DelimiterFound', [ 'delimiter' ] );
145 145
                         }
146 146
                     }
147 147
                     break;
148 148
                 }//end switch
149 149
             } else {
150 150
                 // Javascript file.
151
-                switch ($tokens[$i]['code']) {
151
+                switch ( $tokens[ $i ][ 'code' ] ) {
152 152
                 // Merge conflict opener.
153 153
                 case T_SL:
154
-                    if (isset($tokens[($i + 1)], $tokens[($i + 2)], $tokens[($i + 3)], $tokens[($i + 4)], $tokens[($i + 5)]) !== false
155
-                        && $tokens[($i + 1)]['code'] === T_SL
156
-                        && $tokens[($i + 2)]['code'] === T_SL
157
-                        && $tokens[($i + 3)]['code'] === T_LESS_THAN
158
-                        && $tokens[($i + 4)]['code'] === T_WHITESPACE
159
-                        && trim($tokens[($i + 5)]['content']) === 'HEAD'
154
+                    if ( isset( $tokens[ ( $i + 1 ) ], $tokens[ ( $i + 2 ) ], $tokens[ ( $i + 3 ) ], $tokens[ ( $i + 4 ) ], $tokens[ ( $i + 5 ) ] ) !== false
155
+                        && $tokens[ ( $i + 1 ) ][ 'code' ] === T_SL
156
+                        && $tokens[ ( $i + 2 ) ][ 'code' ] === T_SL
157
+                        && $tokens[ ( $i + 3 ) ][ 'code' ] === T_LESS_THAN
158
+                        && $tokens[ ( $i + 4 ) ][ 'code' ] === T_WHITESPACE
159
+                        && trim( $tokens[ ( $i + 5 ) ][ 'content' ] ) === 'HEAD'
160 160
                     ) {
161
-                        $phpcsFile->addError($error, $i, 'OpenerFound', ['opener']);
161
+                        $phpcsFile->addError( $error, $i, 'OpenerFound', [ 'opener' ] );
162 162
                         $i += 5;
163 163
                     }
164 164
                     break;
165 165
 
166 166
                 // Check for merge conflict delimiter.
167 167
                 case T_IS_IDENTICAL:
168
-                    if (isset($tokens[($i + 1)], $tokens[($i + 2)], $tokens[($i + 3)]) !== false
169
-                        && $tokens[($i + 1)]['code'] === T_IS_IDENTICAL
170
-                        && $tokens[($i + 2)]['code'] === T_EQUAL
171
-                        && $tokens[($i + 3)]['code'] === T_WHITESPACE
172
-                        && $tokens[($i + 3)]['content'] === "\n"
168
+                    if ( isset( $tokens[ ( $i + 1 ) ], $tokens[ ( $i + 2 ) ], $tokens[ ( $i + 3 ) ] ) !== false
169
+                        && $tokens[ ( $i + 1 ) ][ 'code' ] === T_IS_IDENTICAL
170
+                        && $tokens[ ( $i + 2 ) ][ 'code' ] === T_EQUAL
171
+                        && $tokens[ ( $i + 3 ) ][ 'code' ] === T_WHITESPACE
172
+                        && $tokens[ ( $i + 3 ) ][ 'content' ] === "\n"
173 173
                     ) {
174
-                        $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']);
174
+                        $phpcsFile->addError( $error, $i, 'DelimiterFound', [ 'delimiter' ] );
175 175
                         $i += 3;
176 176
                     }
177 177
                     break;
178 178
 
179 179
                 // Merge conflict closer.
180 180
                 case T_ZSR:
181
-                    if ($tokens[$i]['code'] === T_ZSR
182
-                        && isset($tokens[($i + 1)], $tokens[($i + 2)]) === true
183
-                        && $tokens[($i + 1)]['code'] === T_ZSR
184
-                        && $tokens[($i + 2)]['code'] === T_GREATER_THAN
181
+                    if ( $tokens[ $i ][ 'code' ] === T_ZSR
182
+                        && isset( $tokens[ ( $i + 1 ) ], $tokens[ ( $i + 2 ) ] ) === true
183
+                        && $tokens[ ( $i + 1 ) ][ 'code' ] === T_ZSR
184
+                        && $tokens[ ( $i + 2 ) ][ 'code' ] === T_GREATER_THAN
185 185
                     ) {
186
-                        $phpcsFile->addError($error, $i, 'CloserFound', ['closer']);
186
+                        $phpcsFile->addError( $error, $i, 'CloserFound', [ 'closer' ] );
187 187
                         $i += 2;
188 188
                     }
189 189
                     break;
@@ -191,24 +191,24 @@  discard block
 block discarded – undo
191 191
                 // Check for merge conflicts in all comments.
192 192
                 case T_COMMENT:
193 193
                 case T_DOC_COMMENT_STRING:
194
-                    if (substr($tokens[$i]['content'], 0, 12) === '<<<<<<< HEAD') {
195
-                        $phpcsFile->addError($error, $i, 'OpenerFound');
194
+                    if ( substr( $tokens[ $i ][ 'content' ], 0, 12 ) === '<<<<<<< HEAD' ) {
195
+                        $phpcsFile->addError( $error, $i, 'OpenerFound' );
196 196
                         break;
197
-                    } else if (substr($tokens[$i]['content'], 0, 8) === '>>>>>>> ') {
198
-                        $phpcsFile->addError($error, $i, 'CloserFound', ['closer']);
197
+                    } else if ( substr( $tokens[ $i ][ 'content' ], 0, 8 ) === '>>>>>>> ' ) {
198
+                        $phpcsFile->addError( $error, $i, 'CloserFound', [ 'closer' ] );
199 199
                         break;
200 200
                     }
201 201
 
202
-                    if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) {
203
-                        if ($tokens[$i]['content'] === '======='
204
-                            && $tokens[($i + 1)]['code'] === T_DOC_COMMENT_WHITESPACE
202
+                    if ( $tokens[ $i ][ 'code' ] === T_DOC_COMMENT_STRING ) {
203
+                        if ( $tokens[ $i ][ 'content' ] === '======='
204
+                            && $tokens[ ( $i + 1 ) ][ 'code' ] === T_DOC_COMMENT_WHITESPACE
205 205
                         ) {
206
-                            $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']);
206
+                            $phpcsFile->addError( $error, $i, 'DelimiterFound', [ 'delimiter' ] );
207 207
                             break;
208 208
                         }
209 209
                     } else {
210
-                        if ($tokens[$i]['content'] === "=======\n") {
211
-                            $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']);
210
+                        if ( $tokens[ $i ][ 'content' ] === "=======\n" ) {
211
+                            $phpcsFile->addError( $error, $i, 'DelimiterFound', [ 'delimiter' ] );
212 212
                         }
213 213
                     }
214 214
                     break;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         }//end for
218 218
 
219 219
         // Ignore the rest of the file.
220
-        return ($phpcsFile->numTokens + 1);
220
+        return ( $phpcsFile->numTokens + 1 );
221 221
 
222 222
     }//end process()
223 223
 
Please login to merge, or discard this patch.