Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
squizlabs/php_codesniffer/scripts/ValidatePEAR/ValidatePEARPackageXML.php 3 patches
Indentation   +317 added lines, -317 removed lines patch added patch discarded remove patch
@@ -17,344 +17,344 @@
 block discarded – undo
17 17
 class ValidatePEARPackageXML
18 18
 {
19 19
 
20
-    /**
21
-     * The root directory of the project.
22
-     *
23
-     * @var string
24
-     */
25
-    protected $projectRoot = '';
26
-
27
-    /**
28
-     * The contents of the package.xml file.
29
-     *
30
-     * @var \SimpleXMLElement
31
-     */
32
-    protected $packageXML;
33
-
34
-    /**
35
-     * List of all files in the repo.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $allFiles = [];
40
-
41
-    /**
42
-     * Valid file roles.
43
-     *
44
-     * @var array
45
-     *
46
-     * @link https://pear.php.net/manual/en/developers.packagedef.intro.php#developers.packagedef.roles
47
-     */
48
-    private $validRoles = [
49
-        'data'   => true,
50
-        'doc'    => true,
51
-        'ext'    => true,
52
-        'extsrc' => true,
53
-        'php'    => true,
54
-        'script' => true,
55
-        'src'    => true,
56
-        'test'   => true,
57
-    ];
58
-
59
-    /**
60
-     * Files encountered in the package.xml <contents> tag.
61
-     *
62
-     * @var array
63
-     */
64
-    private $listedContents = [];
65
-
66
-
67
-    /**
68
-     * Constructor.
69
-     */
70
-    public function __construct()
71
-    {
72
-        $this->projectRoot = dirname(dirname(__DIR__)).'/';
73
-        $this->packageXML  = simplexml_load_file($this->projectRoot.'package.xml');
74
-
75
-        $allFiles       = (new FileList($this->projectRoot, $this->projectRoot))->getList();
76
-        $this->allFiles = array_flip($allFiles);
77
-
78
-    }//end __construct()
79
-
80
-
81
-    /**
82
-     * Validate the file listings in the package.xml file.
83
-     *
84
-     * @return void
85
-     */
86
-    public function validate()
87
-    {
88
-        $exitCode = 0;
89
-        if ($this->checkContents() !== true) {
90
-            $exitCode = 1;
91
-        }
92
-
93
-        if ($this->checkPHPRelease() !== true) {
94
-            $exitCode = 1;
95
-        }
96
-
97
-        exit($exitCode);
98
-
99
-    }//end validate()
100
-
101
-
102
-    /**
103
-     * Validate the file listings in the <contents> tag.
104
-     *
105
-     * @return bool
106
-     */
107
-    protected function checkContents()
108
-    {
109
-        echo PHP_EOL.'Checking Contents tag'.PHP_EOL;
110
-        echo '====================='.PHP_EOL;
111
-
112
-        $valid = true;
113
-
114
-        /*
20
+	/**
21
+	 * The root directory of the project.
22
+	 *
23
+	 * @var string
24
+	 */
25
+	protected $projectRoot = '';
26
+
27
+	/**
28
+	 * The contents of the package.xml file.
29
+	 *
30
+	 * @var \SimpleXMLElement
31
+	 */
32
+	protected $packageXML;
33
+
34
+	/**
35
+	 * List of all files in the repo.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $allFiles = [];
40
+
41
+	/**
42
+	 * Valid file roles.
43
+	 *
44
+	 * @var array
45
+	 *
46
+	 * @link https://pear.php.net/manual/en/developers.packagedef.intro.php#developers.packagedef.roles
47
+	 */
48
+	private $validRoles = [
49
+		'data'   => true,
50
+		'doc'    => true,
51
+		'ext'    => true,
52
+		'extsrc' => true,
53
+		'php'    => true,
54
+		'script' => true,
55
+		'src'    => true,
56
+		'test'   => true,
57
+	];
58
+
59
+	/**
60
+	 * Files encountered in the package.xml <contents> tag.
61
+	 *
62
+	 * @var array
63
+	 */
64
+	private $listedContents = [];
65
+
66
+
67
+	/**
68
+	 * Constructor.
69
+	 */
70
+	public function __construct()
71
+	{
72
+		$this->projectRoot = dirname(dirname(__DIR__)).'/';
73
+		$this->packageXML  = simplexml_load_file($this->projectRoot.'package.xml');
74
+
75
+		$allFiles       = (new FileList($this->projectRoot, $this->projectRoot))->getList();
76
+		$this->allFiles = array_flip($allFiles);
77
+
78
+	}//end __construct()
79
+
80
+
81
+	/**
82
+	 * Validate the file listings in the package.xml file.
83
+	 *
84
+	 * @return void
85
+	 */
86
+	public function validate()
87
+	{
88
+		$exitCode = 0;
89
+		if ($this->checkContents() !== true) {
90
+			$exitCode = 1;
91
+		}
92
+
93
+		if ($this->checkPHPRelease() !== true) {
94
+			$exitCode = 1;
95
+		}
96
+
97
+		exit($exitCode);
98
+
99
+	}//end validate()
100
+
101
+
102
+	/**
103
+	 * Validate the file listings in the <contents> tag.
104
+	 *
105
+	 * @return bool
106
+	 */
107
+	protected function checkContents()
108
+	{
109
+		echo PHP_EOL.'Checking Contents tag'.PHP_EOL;
110
+		echo '====================='.PHP_EOL;
111
+
112
+		$valid = true;
113
+
114
+		/*
115 115
          * - Check that every file that is mentioned in the `<content>` tag exists in the repo.
116 116
          * - Check that the "role" value is valid.
117 117
          * - Check that the "baseinstalldir" value is valid.
118 118
          */
119 119
 
120
-        $valid = $this->walkDirTag($this->packageXML->contents);
121
-        if ($valid === true) {
122
-            echo "Existing listings in the Contents tag are valid.".PHP_EOL;
123
-        }
120
+		$valid = $this->walkDirTag($this->packageXML->contents);
121
+		if ($valid === true) {
122
+			echo "Existing listings in the Contents tag are valid.".PHP_EOL;
123
+		}
124 124
 
125
-        /*
125
+		/*
126 126
          * Verify that all files in the `src` and the `tests` directories are listed in the `<contents>` tag.
127 127
          */
128 128
 
129
-        $srcFiles   = (new FileList(
130
-            $this->projectRoot.'src/',
131
-            $this->projectRoot,
132
-            '`\.(css|fixed|inc|js|php|xml)$`Di'
133
-        ))->getList();
134
-        $testsFiles = (new FileList(
135
-            $this->projectRoot.'tests/',
136
-            $this->projectRoot,
137
-            '`\.(css|inc|js|php|xml)$`Di'
138
-        ))->getList();
139
-        $files      = array_merge($srcFiles, $testsFiles);
140
-
141
-        foreach ($files as $file) {
142
-            if (isset($this->listedContents[$file]) === true) {
143
-                continue;
144
-            }
145
-
146
-            echo "- File '{$file}' is missing from Contents tag.".PHP_EOL;
147
-            $valid = false;
148
-        }
149
-
150
-        if ($valid === true) {
151
-            echo "No missing files in the Contents tag.".PHP_EOL;
152
-        }
153
-
154
-        return $valid;
155
-
156
-    }//end checkContents()
157
-
158
-
159
-    /**
160
-     * Validate all child tags within a <dir> tag.
161
-     *
162
-     * @param \SimpleXMLElement $tag              The current XML tag to examine.
163
-     * @param string            $currentDirectory The complete relative path to the
164
-     *                                            directory being examined.
165
-     *
166
-     * @return bool
167
-     */
168
-    protected function walkDirTag($tag, $currentDirectory='')
169
-    {
170
-        $valid = true;
171
-        $name  = (string) $tag['name'];
172
-        if ($name !== '/' && empty($name) === false) {
173
-            $currentDirectory .= $name.'/';
174
-        }
175
-
176
-        $children = $tag->children();
177
-        foreach ($children as $key => $value) {
178
-            if ($key === 'dir') {
179
-                if ($this->walkDirTag($value, $currentDirectory) === false) {
180
-                    $valid = false;
181
-                }
182
-            }
183
-
184
-            if ($key === 'file') {
185
-                if ($this->checkFileTag($value, $currentDirectory) === false) {
186
-                    $valid = false;
187
-                }
188
-            }
189
-        }
190
-
191
-        return $valid;
192
-
193
-    }//end walkDirTag()
194
-
195
-
196
-    /**
197
-     * Validate the information within a <file> tag.
198
-     *
199
-     * @param \SimpleXMLElement $tag              The current XML tag to examine.
200
-     * @param string            $currentDirectory The complete relative path to the
201
-     *                                            directory being examined.
202
-     *
203
-     * @return bool
204
-     */
205
-    protected function checkFileTag($tag, $currentDirectory='')
206
-    {
207
-        $valid          = true;
208
-        $attributes     = $tag->attributes();
209
-        $baseinstalldir = (string) $attributes['baseinstalldir'];
210
-        $name           = $currentDirectory.(string) $attributes['name'];
211
-        $role           = (string) $attributes['role'];
212
-
213
-        $this->listedContents[$name] = true;
214
-
215
-        if (empty($name) === true) {
216
-            echo "- Name attribute missing.".PHP_EOL;
217
-            $valid = false;
218
-        } else {
219
-            if (isset($this->allFiles[$name]) === false) {
220
-                echo "- File '{$name}' does not exist.".PHP_EOL;
221
-                $valid = false;
222
-            }
223
-
224
-            if (empty($role) === true) {
225
-                echo "- Role attribute missing for file '{$name}'.".PHP_EOL;
226
-                $valid = false;
227
-            } else {
228
-                if (isset($this->validRoles[$role]) === false) {
229
-                    echo "- Role for file '{$name}' is invalid.".PHP_EOL;
230
-                    $valid = false;
231
-                } else {
232
-                    // Limited validation of the "role" tags.
233
-                    if (strpos($name, 'Test.') !== false && $role !== 'test') {
234
-                        echo "- Test files should have the role 'test'. Found: '$role' for file '{$name}'.".PHP_EOL;
235
-                        $valid = false;
236
-                    } else if ((strpos($name, 'Standard.xml') !== false || strpos($name, 'Sniff.php') !== false)
237
-                        && $role !== 'php'
238
-                    ) {
239
-                        echo "- Sniff files, including sniff documentation files should have the role 'php'. Found: '$role' for file '{$name}'.".PHP_EOL;
240
-                        $valid = false;
241
-                    }
242
-                }
243
-
244
-                if (empty($baseinstalldir) === true) {
245
-                    if ($role !== 'script' && strpos($name, 'tests/') !== 0) {
246
-                        echo "- Baseinstalldir attribute missing for file '{$name}'.".PHP_EOL;
247
-                        $valid = false;
248
-                    }
249
-                } else {
250
-                    if ($role === 'script' ||  strpos($name, 'tests/') === 0) {
251
-                        echo "- Baseinstalldir for file '{$name}' should be empty.".PHP_EOL;
252
-                        $valid = false;
253
-                    }
254
-
255
-                    if ($role !== 'script' && $baseinstalldir !== 'PHP/CodeSniffer') {
256
-                        echo "- Baseinstalldir for file '{$name}' is invalid.".PHP_EOL;
257
-                        $valid = false;
258
-                    }
259
-                }
260
-            }//end if
261
-        }//end if
262
-
263
-        return $valid;
264
-
265
-    }//end checkFileTag()
266
-
267
-
268
-    /**
269
-     * Validate the file listings in the <phprelease> tags.
270
-     *
271
-     * @return bool True if the info in the "phprelease" tags is valid. False otherwise.
272
-     */
273
-    protected function checkPHPRelease()
274
-    {
275
-        echo PHP_EOL.'Checking PHPRelease tags'.PHP_EOL;
276
-        echo '========================'.PHP_EOL;
277
-
278
-        $valid       = true;
279
-        $listedFiles = [];
280
-        $releaseTags = 1;
281
-
282
-        /*
129
+		$srcFiles   = (new FileList(
130
+			$this->projectRoot.'src/',
131
+			$this->projectRoot,
132
+			'`\.(css|fixed|inc|js|php|xml)$`Di'
133
+		))->getList();
134
+		$testsFiles = (new FileList(
135
+			$this->projectRoot.'tests/',
136
+			$this->projectRoot,
137
+			'`\.(css|inc|js|php|xml)$`Di'
138
+		))->getList();
139
+		$files      = array_merge($srcFiles, $testsFiles);
140
+
141
+		foreach ($files as $file) {
142
+			if (isset($this->listedContents[$file]) === true) {
143
+				continue;
144
+			}
145
+
146
+			echo "- File '{$file}' is missing from Contents tag.".PHP_EOL;
147
+			$valid = false;
148
+		}
149
+
150
+		if ($valid === true) {
151
+			echo "No missing files in the Contents tag.".PHP_EOL;
152
+		}
153
+
154
+		return $valid;
155
+
156
+	}//end checkContents()
157
+
158
+
159
+	/**
160
+	 * Validate all child tags within a <dir> tag.
161
+	 *
162
+	 * @param \SimpleXMLElement $tag              The current XML tag to examine.
163
+	 * @param string            $currentDirectory The complete relative path to the
164
+	 *                                            directory being examined.
165
+	 *
166
+	 * @return bool
167
+	 */
168
+	protected function walkDirTag($tag, $currentDirectory='')
169
+	{
170
+		$valid = true;
171
+		$name  = (string) $tag['name'];
172
+		if ($name !== '/' && empty($name) === false) {
173
+			$currentDirectory .= $name.'/';
174
+		}
175
+
176
+		$children = $tag->children();
177
+		foreach ($children as $key => $value) {
178
+			if ($key === 'dir') {
179
+				if ($this->walkDirTag($value, $currentDirectory) === false) {
180
+					$valid = false;
181
+				}
182
+			}
183
+
184
+			if ($key === 'file') {
185
+				if ($this->checkFileTag($value, $currentDirectory) === false) {
186
+					$valid = false;
187
+				}
188
+			}
189
+		}
190
+
191
+		return $valid;
192
+
193
+	}//end walkDirTag()
194
+
195
+
196
+	/**
197
+	 * Validate the information within a <file> tag.
198
+	 *
199
+	 * @param \SimpleXMLElement $tag              The current XML tag to examine.
200
+	 * @param string            $currentDirectory The complete relative path to the
201
+	 *                                            directory being examined.
202
+	 *
203
+	 * @return bool
204
+	 */
205
+	protected function checkFileTag($tag, $currentDirectory='')
206
+	{
207
+		$valid          = true;
208
+		$attributes     = $tag->attributes();
209
+		$baseinstalldir = (string) $attributes['baseinstalldir'];
210
+		$name           = $currentDirectory.(string) $attributes['name'];
211
+		$role           = (string) $attributes['role'];
212
+
213
+		$this->listedContents[$name] = true;
214
+
215
+		if (empty($name) === true) {
216
+			echo "- Name attribute missing.".PHP_EOL;
217
+			$valid = false;
218
+		} else {
219
+			if (isset($this->allFiles[$name]) === false) {
220
+				echo "- File '{$name}' does not exist.".PHP_EOL;
221
+				$valid = false;
222
+			}
223
+
224
+			if (empty($role) === true) {
225
+				echo "- Role attribute missing for file '{$name}'.".PHP_EOL;
226
+				$valid = false;
227
+			} else {
228
+				if (isset($this->validRoles[$role]) === false) {
229
+					echo "- Role for file '{$name}' is invalid.".PHP_EOL;
230
+					$valid = false;
231
+				} else {
232
+					// Limited validation of the "role" tags.
233
+					if (strpos($name, 'Test.') !== false && $role !== 'test') {
234
+						echo "- Test files should have the role 'test'. Found: '$role' for file '{$name}'.".PHP_EOL;
235
+						$valid = false;
236
+					} else if ((strpos($name, 'Standard.xml') !== false || strpos($name, 'Sniff.php') !== false)
237
+						&& $role !== 'php'
238
+					) {
239
+						echo "- Sniff files, including sniff documentation files should have the role 'php'. Found: '$role' for file '{$name}'.".PHP_EOL;
240
+						$valid = false;
241
+					}
242
+				}
243
+
244
+				if (empty($baseinstalldir) === true) {
245
+					if ($role !== 'script' && strpos($name, 'tests/') !== 0) {
246
+						echo "- Baseinstalldir attribute missing for file '{$name}'.".PHP_EOL;
247
+						$valid = false;
248
+					}
249
+				} else {
250
+					if ($role === 'script' ||  strpos($name, 'tests/') === 0) {
251
+						echo "- Baseinstalldir for file '{$name}' should be empty.".PHP_EOL;
252
+						$valid = false;
253
+					}
254
+
255
+					if ($role !== 'script' && $baseinstalldir !== 'PHP/CodeSniffer') {
256
+						echo "- Baseinstalldir for file '{$name}' is invalid.".PHP_EOL;
257
+						$valid = false;
258
+					}
259
+				}
260
+			}//end if
261
+		}//end if
262
+
263
+		return $valid;
264
+
265
+	}//end checkFileTag()
266
+
267
+
268
+	/**
269
+	 * Validate the file listings in the <phprelease> tags.
270
+	 *
271
+	 * @return bool True if the info in the "phprelease" tags is valid. False otherwise.
272
+	 */
273
+	protected function checkPHPRelease()
274
+	{
275
+		echo PHP_EOL.'Checking PHPRelease tags'.PHP_EOL;
276
+		echo '========================'.PHP_EOL;
277
+
278
+		$valid       = true;
279
+		$listedFiles = [];
280
+		$releaseTags = 1;
281
+
282
+		/*
283 283
          * - Check that every file that is mentioned in the `<phprelease>` tags exists in the repo.
284 284
          * - Check that the "as" value is valid.
285 285
          */
286 286
 
287
-        foreach ($this->packageXML->phprelease as $release) {
288
-            foreach ($release->filelist->install as $install) {
289
-                $attributes = $install->attributes();
290
-                $name       = (string) $attributes['name'];
291
-                $as         = (string) $attributes['as'];
292
-
293
-                $listedFiles[$releaseTags][$name] = $as;
294
-
295
-                if (empty($as) === true || empty($name) === true) {
296
-                    continue;
297
-                }
298
-
299
-                if (isset($this->allFiles[$name]) === false) {
300
-                    echo "- File '{$name}' does not exist.".PHP_EOL;
301
-                    $valid = false;
302
-                }
303
-
304
-                // Rest of the checks only apply to the test files.
305
-                if (strpos($name, 'tests/') !== 0) {
306
-                    continue;
307
-                }
308
-
309
-                // Check validity of the tags for files in the tests root directory.
310
-                if (preg_match('`^tests/([^/]+\.php)$`', $name, $matches) === 1
311
-                    && ($as === $name || $as === $matches[1])
312
-                ) {
313
-                    continue;
314
-                }
315
-
316
-                // Check validity of the tags for files in the tests root subdirectories.
317
-                if (preg_match('`^tests/.+\.(php|inc|js|css|xml)$`', $name) === 1
318
-                    && $as === str_replace('tests/', 'CodeSniffer/', $name)
319
-                ) {
320
-                    continue;
321
-                }
322
-
323
-                echo "- Invalid 'as' attribute '{$as}' for test file '{$name}'.".PHP_EOL;
324
-                $valid = false;
325
-            }//end foreach
326
-
327
-            ++$releaseTags;
328
-        }//end foreach
329
-
330
-        if ($valid === true) {
331
-            echo "Existing PHPRelease tags are valid.".PHP_EOL;
332
-        }
333
-
334
-        /*
287
+		foreach ($this->packageXML->phprelease as $release) {
288
+			foreach ($release->filelist->install as $install) {
289
+				$attributes = $install->attributes();
290
+				$name       = (string) $attributes['name'];
291
+				$as         = (string) $attributes['as'];
292
+
293
+				$listedFiles[$releaseTags][$name] = $as;
294
+
295
+				if (empty($as) === true || empty($name) === true) {
296
+					continue;
297
+				}
298
+
299
+				if (isset($this->allFiles[$name]) === false) {
300
+					echo "- File '{$name}' does not exist.".PHP_EOL;
301
+					$valid = false;
302
+				}
303
+
304
+				// Rest of the checks only apply to the test files.
305
+				if (strpos($name, 'tests/') !== 0) {
306
+					continue;
307
+				}
308
+
309
+				// Check validity of the tags for files in the tests root directory.
310
+				if (preg_match('`^tests/([^/]+\.php)$`', $name, $matches) === 1
311
+					&& ($as === $name || $as === $matches[1])
312
+				) {
313
+					continue;
314
+				}
315
+
316
+				// Check validity of the tags for files in the tests root subdirectories.
317
+				if (preg_match('`^tests/.+\.(php|inc|js|css|xml)$`', $name) === 1
318
+					&& $as === str_replace('tests/', 'CodeSniffer/', $name)
319
+				) {
320
+					continue;
321
+				}
322
+
323
+				echo "- Invalid 'as' attribute '{$as}' for test file '{$name}'.".PHP_EOL;
324
+				$valid = false;
325
+			}//end foreach
326
+
327
+			++$releaseTags;
328
+		}//end foreach
329
+
330
+		if ($valid === true) {
331
+			echo "Existing PHPRelease tags are valid.".PHP_EOL;
332
+		}
333
+
334
+		/*
335 335
          * Verify that all files in the `tests` directory are listed in both `<phprelease>` tags.
336 336
          */
337 337
 
338
-        $testFiles = (new FileList($this->projectRoot.'tests/', $this->projectRoot, '`\.(inc|php|js|css|xml)$`Di'))->getList();
338
+		$testFiles = (new FileList($this->projectRoot.'tests/', $this->projectRoot, '`\.(inc|php|js|css|xml)$`Di'))->getList();
339 339
 
340
-        foreach ($testFiles as $file) {
341
-            foreach ($listedFiles as $key => $listed) {
342
-                if (isset($listed[$file]) === true) {
343
-                    continue;
344
-                }
340
+		foreach ($testFiles as $file) {
341
+			foreach ($listedFiles as $key => $listed) {
342
+				if (isset($listed[$file]) === true) {
343
+					continue;
344
+				}
345 345
 
346
-                echo "- File '{$file}' is missing from PHPRelease tag [{$key}] .".PHP_EOL;
347
-                $valid = false;
348
-            }
349
-        }
346
+				echo "- File '{$file}' is missing from PHPRelease tag [{$key}] .".PHP_EOL;
347
+				$valid = false;
348
+			}
349
+		}
350 350
 
351
-        if ($valid === true) {
352
-            echo "No missing PHPRelease tags.".PHP_EOL;
353
-        }
351
+		if ($valid === true) {
352
+			echo "No missing PHPRelease tags.".PHP_EOL;
353
+		}
354 354
 
355
-        return $valid;
355
+		return $valid;
356 356
 
357
-    }//end checkPHPRelease()
357
+	}//end checkPHPRelease()
358 358
 
359 359
 
360 360
 }//end class
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @var array
38 38
      */
39
-    protected $allFiles = [];
39
+    protected $allFiles = [ ];
40 40
 
41 41
     /**
42 42
      * Valid file roles.
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @var array
63 63
      */
64
-    private $listedContents = [];
64
+    private $listedContents = [ ];
65 65
 
66 66
 
67 67
     /**
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function __construct()
71 71
     {
72
-        $this->projectRoot = dirname(dirname(__DIR__)).'/';
73
-        $this->packageXML  = simplexml_load_file($this->projectRoot.'package.xml');
72
+        $this->projectRoot = dirname( dirname( __DIR__ ) ) . '/';
73
+        $this->packageXML  = simplexml_load_file( $this->projectRoot . 'package.xml' );
74 74
 
75
-        $allFiles       = (new FileList($this->projectRoot, $this->projectRoot))->getList();
76
-        $this->allFiles = array_flip($allFiles);
75
+        $allFiles       = ( new FileList( $this->projectRoot, $this->projectRoot ) )->getList();
76
+        $this->allFiles = array_flip( $allFiles );
77 77
 
78 78
     }//end __construct()
79 79
 
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
     public function validate()
87 87
     {
88 88
         $exitCode = 0;
89
-        if ($this->checkContents() !== true) {
89
+        if ( $this->checkContents() !== true ) {
90 90
             $exitCode = 1;
91 91
         }
92 92
 
93
-        if ($this->checkPHPRelease() !== true) {
93
+        if ( $this->checkPHPRelease() !== true ) {
94 94
             $exitCode = 1;
95 95
         }
96 96
 
97
-        exit($exitCode);
97
+        exit( $exitCode );
98 98
 
99 99
     }//end validate()
100 100
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
      */
107 107
     protected function checkContents()
108 108
     {
109
-        echo PHP_EOL.'Checking Contents tag'.PHP_EOL;
110
-        echo '====================='.PHP_EOL;
109
+        echo PHP_EOL . 'Checking Contents tag' . PHP_EOL;
110
+        echo '=====================' . PHP_EOL;
111 111
 
112 112
         $valid = true;
113 113
 
@@ -117,38 +117,38 @@  discard block
 block discarded – undo
117 117
          * - Check that the "baseinstalldir" value is valid.
118 118
          */
119 119
 
120
-        $valid = $this->walkDirTag($this->packageXML->contents);
121
-        if ($valid === true) {
122
-            echo "Existing listings in the Contents tag are valid.".PHP_EOL;
120
+        $valid = $this->walkDirTag( $this->packageXML->contents );
121
+        if ( $valid === true ) {
122
+            echo "Existing listings in the Contents tag are valid." . PHP_EOL;
123 123
         }
124 124
 
125 125
         /*
126 126
          * Verify that all files in the `src` and the `tests` directories are listed in the `<contents>` tag.
127 127
          */
128 128
 
129
-        $srcFiles   = (new FileList(
130
-            $this->projectRoot.'src/',
129
+        $srcFiles = ( new FileList(
130
+            $this->projectRoot . 'src/',
131 131
             $this->projectRoot,
132 132
             '`\.(css|fixed|inc|js|php|xml)$`Di'
133
-        ))->getList();
134
-        $testsFiles = (new FileList(
135
-            $this->projectRoot.'tests/',
133
+        ) )->getList();
134
+        $testsFiles = ( new FileList(
135
+            $this->projectRoot . 'tests/',
136 136
             $this->projectRoot,
137 137
             '`\.(css|inc|js|php|xml)$`Di'
138
-        ))->getList();
139
-        $files      = array_merge($srcFiles, $testsFiles);
138
+        ) )->getList();
139
+        $files = array_merge( $srcFiles, $testsFiles );
140 140
 
141
-        foreach ($files as $file) {
142
-            if (isset($this->listedContents[$file]) === true) {
141
+        foreach ( $files as $file ) {
142
+            if ( isset( $this->listedContents[ $file ] ) === true ) {
143 143
                 continue;
144 144
             }
145 145
 
146
-            echo "- File '{$file}' is missing from Contents tag.".PHP_EOL;
146
+            echo "- File '{$file}' is missing from Contents tag." . PHP_EOL;
147 147
             $valid = false;
148 148
         }
149 149
 
150
-        if ($valid === true) {
151
-            echo "No missing files in the Contents tag.".PHP_EOL;
150
+        if ( $valid === true ) {
151
+            echo "No missing files in the Contents tag." . PHP_EOL;
152 152
         }
153 153
 
154 154
         return $valid;
@@ -165,24 +165,24 @@  discard block
 block discarded – undo
165 165
      *
166 166
      * @return bool
167 167
      */
168
-    protected function walkDirTag($tag, $currentDirectory='')
168
+    protected function walkDirTag( $tag, $currentDirectory = '' )
169 169
     {
170 170
         $valid = true;
171
-        $name  = (string) $tag['name'];
172
-        if ($name !== '/' && empty($name) === false) {
173
-            $currentDirectory .= $name.'/';
171
+        $name  = (string)$tag[ 'name' ];
172
+        if ( $name !== '/' && empty( $name ) === false ) {
173
+            $currentDirectory .= $name . '/';
174 174
         }
175 175
 
176 176
         $children = $tag->children();
177
-        foreach ($children as $key => $value) {
178
-            if ($key === 'dir') {
179
-                if ($this->walkDirTag($value, $currentDirectory) === false) {
177
+        foreach ( $children as $key => $value ) {
178
+            if ( $key === 'dir' ) {
179
+                if ( $this->walkDirTag( $value, $currentDirectory ) === false ) {
180 180
                     $valid = false;
181 181
                 }
182 182
             }
183 183
 
184
-            if ($key === 'file') {
185
-                if ($this->checkFileTag($value, $currentDirectory) === false) {
184
+            if ( $key === 'file' ) {
185
+                if ( $this->checkFileTag( $value, $currentDirectory ) === false ) {
186 186
                     $valid = false;
187 187
                 }
188 188
             }
@@ -202,58 +202,58 @@  discard block
 block discarded – undo
202 202
      *
203 203
      * @return bool
204 204
      */
205
-    protected function checkFileTag($tag, $currentDirectory='')
205
+    protected function checkFileTag( $tag, $currentDirectory = '' )
206 206
     {
207 207
         $valid          = true;
208 208
         $attributes     = $tag->attributes();
209
-        $baseinstalldir = (string) $attributes['baseinstalldir'];
210
-        $name           = $currentDirectory.(string) $attributes['name'];
211
-        $role           = (string) $attributes['role'];
209
+        $baseinstalldir = (string)$attributes[ 'baseinstalldir' ];
210
+        $name           = $currentDirectory . (string)$attributes[ 'name' ];
211
+        $role           = (string)$attributes[ 'role' ];
212 212
 
213
-        $this->listedContents[$name] = true;
213
+        $this->listedContents[ $name ] = true;
214 214
 
215
-        if (empty($name) === true) {
216
-            echo "- Name attribute missing.".PHP_EOL;
215
+        if ( empty( $name ) === true ) {
216
+            echo "- Name attribute missing." . PHP_EOL;
217 217
             $valid = false;
218 218
         } else {
219
-            if (isset($this->allFiles[$name]) === false) {
220
-                echo "- File '{$name}' does not exist.".PHP_EOL;
219
+            if ( isset( $this->allFiles[ $name ] ) === false ) {
220
+                echo "- File '{$name}' does not exist." . PHP_EOL;
221 221
                 $valid = false;
222 222
             }
223 223
 
224
-            if (empty($role) === true) {
225
-                echo "- Role attribute missing for file '{$name}'.".PHP_EOL;
224
+            if ( empty( $role ) === true ) {
225
+                echo "- Role attribute missing for file '{$name}'." . PHP_EOL;
226 226
                 $valid = false;
227 227
             } else {
228
-                if (isset($this->validRoles[$role]) === false) {
229
-                    echo "- Role for file '{$name}' is invalid.".PHP_EOL;
228
+                if ( isset( $this->validRoles[ $role ] ) === false ) {
229
+                    echo "- Role for file '{$name}' is invalid." . PHP_EOL;
230 230
                     $valid = false;
231 231
                 } else {
232 232
                     // Limited validation of the "role" tags.
233
-                    if (strpos($name, 'Test.') !== false && $role !== 'test') {
234
-                        echo "- Test files should have the role 'test'. Found: '$role' for file '{$name}'.".PHP_EOL;
233
+                    if ( strpos( $name, 'Test.' ) !== false && $role !== 'test' ) {
234
+                        echo "- Test files should have the role 'test'. Found: '$role' for file '{$name}'." . PHP_EOL;
235 235
                         $valid = false;
236
-                    } else if ((strpos($name, 'Standard.xml') !== false || strpos($name, 'Sniff.php') !== false)
236
+                    } else if ( ( strpos( $name, 'Standard.xml' ) !== false || strpos( $name, 'Sniff.php' ) !== false )
237 237
                         && $role !== 'php'
238 238
                     ) {
239
-                        echo "- Sniff files, including sniff documentation files should have the role 'php'. Found: '$role' for file '{$name}'.".PHP_EOL;
239
+                        echo "- Sniff files, including sniff documentation files should have the role 'php'. Found: '$role' for file '{$name}'." . PHP_EOL;
240 240
                         $valid = false;
241 241
                     }
242 242
                 }
243 243
 
244
-                if (empty($baseinstalldir) === true) {
245
-                    if ($role !== 'script' && strpos($name, 'tests/') !== 0) {
246
-                        echo "- Baseinstalldir attribute missing for file '{$name}'.".PHP_EOL;
244
+                if ( empty( $baseinstalldir ) === true ) {
245
+                    if ( $role !== 'script' && strpos( $name, 'tests/' ) !== 0 ) {
246
+                        echo "- Baseinstalldir attribute missing for file '{$name}'." . PHP_EOL;
247 247
                         $valid = false;
248 248
                     }
249 249
                 } else {
250
-                    if ($role === 'script' ||  strpos($name, 'tests/') === 0) {
251
-                        echo "- Baseinstalldir for file '{$name}' should be empty.".PHP_EOL;
250
+                    if ( $role === 'script' || strpos( $name, 'tests/' ) === 0 ) {
251
+                        echo "- Baseinstalldir for file '{$name}' should be empty." . PHP_EOL;
252 252
                         $valid = false;
253 253
                     }
254 254
 
255
-                    if ($role !== 'script' && $baseinstalldir !== 'PHP/CodeSniffer') {
256
-                        echo "- Baseinstalldir for file '{$name}' is invalid.".PHP_EOL;
255
+                    if ( $role !== 'script' && $baseinstalldir !== 'PHP/CodeSniffer' ) {
256
+                        echo "- Baseinstalldir for file '{$name}' is invalid." . PHP_EOL;
257 257
                         $valid = false;
258 258
                     }
259 259
                 }
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
      */
273 273
     protected function checkPHPRelease()
274 274
     {
275
-        echo PHP_EOL.'Checking PHPRelease tags'.PHP_EOL;
276
-        echo '========================'.PHP_EOL;
275
+        echo PHP_EOL . 'Checking PHPRelease tags' . PHP_EOL;
276
+        echo '========================' . PHP_EOL;
277 277
 
278 278
         $valid       = true;
279
-        $listedFiles = [];
279
+        $listedFiles = [ ];
280 280
         $releaseTags = 1;
281 281
 
282 282
         /*
@@ -284,72 +284,72 @@  discard block
 block discarded – undo
284 284
          * - Check that the "as" value is valid.
285 285
          */
286 286
 
287
-        foreach ($this->packageXML->phprelease as $release) {
288
-            foreach ($release->filelist->install as $install) {
287
+        foreach ( $this->packageXML->phprelease as $release ) {
288
+            foreach ( $release->filelist->install as $install ) {
289 289
                 $attributes = $install->attributes();
290
-                $name       = (string) $attributes['name'];
291
-                $as         = (string) $attributes['as'];
290
+                $name       = (string)$attributes[ 'name' ];
291
+                $as         = (string)$attributes[ 'as' ];
292 292
 
293
-                $listedFiles[$releaseTags][$name] = $as;
293
+                $listedFiles[ $releaseTags ][ $name ] = $as;
294 294
 
295
-                if (empty($as) === true || empty($name) === true) {
295
+                if ( empty( $as ) === true || empty( $name ) === true ) {
296 296
                     continue;
297 297
                 }
298 298
 
299
-                if (isset($this->allFiles[$name]) === false) {
300
-                    echo "- File '{$name}' does not exist.".PHP_EOL;
299
+                if ( isset( $this->allFiles[ $name ] ) === false ) {
300
+                    echo "- File '{$name}' does not exist." . PHP_EOL;
301 301
                     $valid = false;
302 302
                 }
303 303
 
304 304
                 // Rest of the checks only apply to the test files.
305
-                if (strpos($name, 'tests/') !== 0) {
305
+                if ( strpos( $name, 'tests/' ) !== 0 ) {
306 306
                     continue;
307 307
                 }
308 308
 
309 309
                 // Check validity of the tags for files in the tests root directory.
310
-                if (preg_match('`^tests/([^/]+\.php)$`', $name, $matches) === 1
311
-                    && ($as === $name || $as === $matches[1])
310
+                if ( preg_match( '`^tests/([^/]+\.php)$`', $name, $matches ) === 1
311
+                    && ( $as === $name || $as === $matches[ 1 ] )
312 312
                 ) {
313 313
                     continue;
314 314
                 }
315 315
 
316 316
                 // Check validity of the tags for files in the tests root subdirectories.
317
-                if (preg_match('`^tests/.+\.(php|inc|js|css|xml)$`', $name) === 1
318
-                    && $as === str_replace('tests/', 'CodeSniffer/', $name)
317
+                if ( preg_match( '`^tests/.+\.(php|inc|js|css|xml)$`', $name ) === 1
318
+                    && $as === str_replace( 'tests/', 'CodeSniffer/', $name )
319 319
                 ) {
320 320
                     continue;
321 321
                 }
322 322
 
323
-                echo "- Invalid 'as' attribute '{$as}' for test file '{$name}'.".PHP_EOL;
323
+                echo "- Invalid 'as' attribute '{$as}' for test file '{$name}'." . PHP_EOL;
324 324
                 $valid = false;
325 325
             }//end foreach
326 326
 
327 327
             ++$releaseTags;
328 328
         }//end foreach
329 329
 
330
-        if ($valid === true) {
331
-            echo "Existing PHPRelease tags are valid.".PHP_EOL;
330
+        if ( $valid === true ) {
331
+            echo "Existing PHPRelease tags are valid." . PHP_EOL;
332 332
         }
333 333
 
334 334
         /*
335 335
          * Verify that all files in the `tests` directory are listed in both `<phprelease>` tags.
336 336
          */
337 337
 
338
-        $testFiles = (new FileList($this->projectRoot.'tests/', $this->projectRoot, '`\.(inc|php|js|css|xml)$`Di'))->getList();
338
+        $testFiles = ( new FileList( $this->projectRoot . 'tests/', $this->projectRoot, '`\.(inc|php|js|css|xml)$`Di' ) )->getList();
339 339
 
340
-        foreach ($testFiles as $file) {
341
-            foreach ($listedFiles as $key => $listed) {
342
-                if (isset($listed[$file]) === true) {
340
+        foreach ( $testFiles as $file ) {
341
+            foreach ( $listedFiles as $key => $listed ) {
342
+                if ( isset( $listed[ $file ] ) === true ) {
343 343
                     continue;
344 344
                 }
345 345
 
346
-                echo "- File '{$file}' is missing from PHPRelease tag [{$key}] .".PHP_EOL;
346
+                echo "- File '{$file}' is missing from PHPRelease tag [{$key}] ." . PHP_EOL;
347 347
                 $valid = false;
348 348
             }
349 349
         }
350 350
 
351
-        if ($valid === true) {
352
-            echo "No missing PHPRelease tags.".PHP_EOL;
351
+        if ( $valid === true ) {
352
+            echo "No missing PHPRelease tags." . PHP_EOL;
353 353
         }
354 354
 
355 355
         return $valid;
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -14,8 +14,7 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * Validate the PHP_CodeSniffer PEAR package.xml file.
16 16
  */
17
-class ValidatePEARPackageXML
18
-{
17
+class ValidatePEARPackageXML {
19 18
 
20 19
     /**
21 20
      * The root directory of the project.
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
     /**
68 67
      * Constructor.
69 68
      */
70
-    public function __construct()
71
-    {
69
+    public function __construct() {
72 70
         $this->projectRoot = dirname(dirname(__DIR__)).'/';
73 71
         $this->packageXML  = simplexml_load_file($this->projectRoot.'package.xml');
74 72
 
@@ -83,8 +81,7 @@  discard block
 block discarded – undo
83 81
      *
84 82
      * @return void
85 83
      */
86
-    public function validate()
87
-    {
84
+    public function validate() {
88 85
         $exitCode = 0;
89 86
         if ($this->checkContents() !== true) {
90 87
             $exitCode = 1;
@@ -104,8 +101,7 @@  discard block
 block discarded – undo
104 101
      *
105 102
      * @return bool
106 103
      */
107
-    protected function checkContents()
108
-    {
104
+    protected function checkContents() {
109 105
         echo PHP_EOL.'Checking Contents tag'.PHP_EOL;
110 106
         echo '====================='.PHP_EOL;
111 107
 
@@ -165,8 +161,7 @@  discard block
 block discarded – undo
165 161
      *
166 162
      * @return bool
167 163
      */
168
-    protected function walkDirTag($tag, $currentDirectory='')
169
-    {
164
+    protected function walkDirTag($tag, $currentDirectory='') {
170 165
         $valid = true;
171 166
         $name  = (string) $tag['name'];
172 167
         if ($name !== '/' && empty($name) === false) {
@@ -202,8 +197,7 @@  discard block
 block discarded – undo
202 197
      *
203 198
      * @return bool
204 199
      */
205
-    protected function checkFileTag($tag, $currentDirectory='')
206
-    {
200
+    protected function checkFileTag($tag, $currentDirectory='') {
207 201
         $valid          = true;
208 202
         $attributes     = $tag->attributes();
209 203
         $baseinstalldir = (string) $attributes['baseinstalldir'];
@@ -270,8 +264,7 @@  discard block
 block discarded – undo
270 264
      *
271 265
      * @return bool True if the info in the "phprelease" tags is valid. False otherwise.
272 266
      */
273
-    protected function checkPHPRelease()
274
-    {
267
+    protected function checkPHPRelease() {
275 268
         echo PHP_EOL.'Checking PHPRelease tags'.PHP_EOL;
276 269
         echo '========================'.PHP_EOL;
277 270
 
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/scripts/ValidatePEAR/FileList.php 3 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -17,83 +17,83 @@
 block discarded – undo
17 17
 class FileList
18 18
 {
19 19
 
20
-    /**
21
-     * The path to the project root directory.
22
-     *
23
-     * @var string
24
-     */
25
-    protected $rootPath;
26
-
27
-    /**
28
-     * Recursive directory iterator.
29
-     *
30
-     * @var \DirectoryIterator
31
-     */
32
-    protected $fileIterator;
33
-
34
-    /**
35
-     * Base regex to use if no filter regex is provided.
36
-     *
37
-     * Matches based on:
38
-     * - File path starts with the project root (replacement done in constructor).
39
-     * - Don't match .git/ files.
40
-     * - Don't match dot files, i.e. "." or "..".
41
-     * - Don't match backup files.
42
-     * - Match everything else in a case-insensitive manner.
43
-     *
44
-     * @var string
45
-     */
46
-    private $baseRegex = '`^%s(?!\.git/)(?!(.*/)?\.+$)(?!.*\.(bak|orig)).*$`Dix';
47
-
48
-
49
-    /**
50
-     * Constructor.
51
-     *
52
-     * @param string $directory The directory to examine.
53
-     * @param string $rootPath  Path to the project root.
54
-     * @param string $filter    PCRE regular expression to filter the file list with.
55
-     */
56
-    public function __construct($directory, $rootPath='', $filter='')
57
-    {
58
-        $this->rootPath = $rootPath;
59
-
60
-        $directory = new \RecursiveDirectoryIterator(
61
-            $directory,
62
-            \RecursiveDirectoryIterator::UNIX_PATHS
63
-        );
64
-        $flattened = new \RecursiveIteratorIterator(
65
-            $directory,
66
-            \RecursiveIteratorIterator::LEAVES_ONLY,
67
-            \RecursiveIteratorIterator::CATCH_GET_CHILD
68
-        );
69
-
70
-        if ($filter === '') {
71
-            $filter = sprintf($this->baseRegex, preg_quote($this->rootPath));
72
-        }
73
-
74
-        $this->fileIterator = new \RegexIterator($flattened, $filter);
75
-
76
-        return $this;
77
-
78
-    }//end __construct()
79
-
80
-
81
-    /**
82
-     * Retrieve the filtered file list as an array.
83
-     *
84
-     * @return array
85
-     */
86
-    public function getList()
87
-    {
88
-        $fileList = [];
89
-
90
-        foreach ($this->fileIterator as $file) {
91
-            $fileList[] = str_replace($this->rootPath, '', $file);
92
-        }
93
-
94
-        return $fileList;
95
-
96
-    }//end getList()
20
+	/**
21
+	 * The path to the project root directory.
22
+	 *
23
+	 * @var string
24
+	 */
25
+	protected $rootPath;
26
+
27
+	/**
28
+	 * Recursive directory iterator.
29
+	 *
30
+	 * @var \DirectoryIterator
31
+	 */
32
+	protected $fileIterator;
33
+
34
+	/**
35
+	 * Base regex to use if no filter regex is provided.
36
+	 *
37
+	 * Matches based on:
38
+	 * - File path starts with the project root (replacement done in constructor).
39
+	 * - Don't match .git/ files.
40
+	 * - Don't match dot files, i.e. "." or "..".
41
+	 * - Don't match backup files.
42
+	 * - Match everything else in a case-insensitive manner.
43
+	 *
44
+	 * @var string
45
+	 */
46
+	private $baseRegex = '`^%s(?!\.git/)(?!(.*/)?\.+$)(?!.*\.(bak|orig)).*$`Dix';
47
+
48
+
49
+	/**
50
+	 * Constructor.
51
+	 *
52
+	 * @param string $directory The directory to examine.
53
+	 * @param string $rootPath  Path to the project root.
54
+	 * @param string $filter    PCRE regular expression to filter the file list with.
55
+	 */
56
+	public function __construct($directory, $rootPath='', $filter='')
57
+	{
58
+		$this->rootPath = $rootPath;
59
+
60
+		$directory = new \RecursiveDirectoryIterator(
61
+			$directory,
62
+			\RecursiveDirectoryIterator::UNIX_PATHS
63
+		);
64
+		$flattened = new \RecursiveIteratorIterator(
65
+			$directory,
66
+			\RecursiveIteratorIterator::LEAVES_ONLY,
67
+			\RecursiveIteratorIterator::CATCH_GET_CHILD
68
+		);
69
+
70
+		if ($filter === '') {
71
+			$filter = sprintf($this->baseRegex, preg_quote($this->rootPath));
72
+		}
73
+
74
+		$this->fileIterator = new \RegexIterator($flattened, $filter);
75
+
76
+		return $this;
77
+
78
+	}//end __construct()
79
+
80
+
81
+	/**
82
+	 * Retrieve the filtered file list as an array.
83
+	 *
84
+	 * @return array
85
+	 */
86
+	public function getList()
87
+	{
88
+		$fileList = [];
89
+
90
+		foreach ($this->fileIterator as $file) {
91
+			$fileList[] = str_replace($this->rootPath, '', $file);
92
+		}
93
+
94
+		return $fileList;
95
+
96
+	}//end getList()
97 97
 
98 98
 
99 99
 }//end class
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param string $rootPath  Path to the project root.
54 54
      * @param string $filter    PCRE regular expression to filter the file list with.
55 55
      */
56
-    public function __construct($directory, $rootPath='', $filter='')
56
+    public function __construct( $directory, $rootPath = '', $filter = '' )
57 57
     {
58 58
         $this->rootPath = $rootPath;
59 59
 
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
             \RecursiveIteratorIterator::CATCH_GET_CHILD
68 68
         );
69 69
 
70
-        if ($filter === '') {
71
-            $filter = sprintf($this->baseRegex, preg_quote($this->rootPath));
70
+        if ( $filter === '' ) {
71
+            $filter = sprintf( $this->baseRegex, preg_quote( $this->rootPath ) );
72 72
         }
73 73
 
74
-        $this->fileIterator = new \RegexIterator($flattened, $filter);
74
+        $this->fileIterator = new \RegexIterator( $flattened, $filter );
75 75
 
76 76
         return $this;
77 77
 
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function getList()
87 87
     {
88
-        $fileList = [];
88
+        $fileList = [ ];
89 89
 
90
-        foreach ($this->fileIterator as $file) {
91
-            $fileList[] = str_replace($this->rootPath, '', $file);
90
+        foreach ( $this->fileIterator as $file ) {
91
+            $fileList[ ] = str_replace( $this->rootPath, '', $file );
92 92
         }
93 93
 
94 94
         return $fileList;
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,8 +14,7 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * Class to create a file list with filtering.
16 16
  */
17
-class FileList
18
-{
17
+class FileList {
19 18
 
20 19
     /**
21 20
      * The path to the project root directory.
@@ -53,8 +52,7 @@  discard block
 block discarded – undo
53 52
      * @param string $rootPath  Path to the project root.
54 53
      * @param string $filter    PCRE regular expression to filter the file list with.
55 54
      */
56
-    public function __construct($directory, $rootPath='', $filter='')
57
-    {
55
+    public function __construct($directory, $rootPath='', $filter='') {
58 56
         $this->rootPath = $rootPath;
59 57
 
60 58
         $directory = new \RecursiveDirectoryIterator(
@@ -83,8 +81,7 @@  discard block
 block discarded – undo
83 81
      *
84 82
      * @return array
85 83
      */
86
-    public function getList()
87
-    {
84
+    public function getList() {
88 85
         $fileList = [];
89 86
 
90 87
         foreach ($this->fileIterator as $file) {
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/scripts/build-phar.php 3 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -17,80 +17,80 @@
 block discarded – undo
17 17
 error_reporting(E_ALL | E_STRICT);
18 18
 
19 19
 if (ini_get('phar.readonly') === '1') {
20
-    echo 'Unable to build, phar.readonly in php.ini is set to read only.'.PHP_EOL;
21
-    exit(1);
20
+	echo 'Unable to build, phar.readonly in php.ini is set to read only.'.PHP_EOL;
21
+	exit(1);
22 22
 }
23 23
 
24 24
 $scripts = [
25
-    'phpcs',
26
-    'phpcbf',
25
+	'phpcs',
26
+	'phpcbf',
27 27
 ];
28 28
 
29 29
 foreach ($scripts as $script) {
30
-    echo "Building $script phar".PHP_EOL;
30
+	echo "Building $script phar".PHP_EOL;
31 31
 
32
-    $pharName = $script.'.phar';
33
-    $pharFile = getcwd().'/'.$pharName;
34
-    echo "\t=> $pharFile".PHP_EOL;
35
-    if (file_exists($pharFile) === true) {
36
-        echo "\t** file exists, removing **".PHP_EOL;
37
-        unlink($pharFile);
38
-    }
32
+	$pharName = $script.'.phar';
33
+	$pharFile = getcwd().'/'.$pharName;
34
+	echo "\t=> $pharFile".PHP_EOL;
35
+	if (file_exists($pharFile) === true) {
36
+		echo "\t** file exists, removing **".PHP_EOL;
37
+		unlink($pharFile);
38
+	}
39 39
 
40
-    $phar = new Phar($pharFile, 0, $pharName);
40
+	$phar = new Phar($pharFile, 0, $pharName);
41 41
 
42
-    /*
42
+	/*
43 43
         Add the files.
44 44
     */
45 45
 
46
-    echo "\t=> adding files... ";
46
+	echo "\t=> adding files... ";
47 47
 
48
-    $srcDir    = realpath(__DIR__.'/../src');
49
-    $srcDirLen = strlen($srcDir);
48
+	$srcDir    = realpath(__DIR__.'/../src');
49
+	$srcDirLen = strlen($srcDir);
50 50
 
51
-    $rdi = new \RecursiveDirectoryIterator($srcDir, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
52
-    $di  = new \RecursiveIteratorIterator($rdi, 0, \RecursiveIteratorIterator::CATCH_GET_CHILD);
51
+	$rdi = new \RecursiveDirectoryIterator($srcDir, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
52
+	$di  = new \RecursiveIteratorIterator($rdi, 0, \RecursiveIteratorIterator::CATCH_GET_CHILD);
53 53
 
54
-    foreach ($di as $file) {
55
-        $filename = $file->getFilename();
54
+	foreach ($di as $file) {
55
+		$filename = $file->getFilename();
56 56
 
57
-        // Skip hidden files.
58
-        if (substr($filename, 0, 1) === '.') {
59
-            continue;
60
-        }
57
+		// Skip hidden files.
58
+		if (substr($filename, 0, 1) === '.') {
59
+			continue;
60
+		}
61 61
 
62
-        $fullpath = $file->getPathname();
63
-        if (strpos($fullpath, '/Tests/') !== false) {
64
-            continue;
65
-        }
62
+		$fullpath = $file->getPathname();
63
+		if (strpos($fullpath, '/Tests/') !== false) {
64
+			continue;
65
+		}
66 66
 
67
-        $path = 'src'.substr($fullpath, $srcDirLen);
67
+		$path = 'src'.substr($fullpath, $srcDirLen);
68 68
 
69
-        $phar->addFromString($path, php_strip_whitespace($fullpath));
70
-    }
69
+		$phar->addFromString($path, php_strip_whitespace($fullpath));
70
+	}
71 71
 
72
-    // Add autoloader.
73
-    $phar->addFromString('autoload.php', php_strip_whitespace(realpath(__DIR__.'/../autoload.php')));
72
+	// Add autoloader.
73
+	$phar->addFromString('autoload.php', php_strip_whitespace(realpath(__DIR__.'/../autoload.php')));
74 74
 
75
-    // Add licence file.
76
-    $phar->addFromString('licence.txt', php_strip_whitespace(realpath(__DIR__.'/../licence.txt')));
75
+	// Add licence file.
76
+	$phar->addFromString('licence.txt', php_strip_whitespace(realpath(__DIR__.'/../licence.txt')));
77 77
 
78
-    echo 'done'.PHP_EOL;
78
+	echo 'done'.PHP_EOL;
79 79
 
80
-    /*
80
+	/*
81 81
         Add the stub.
82 82
     */
83 83
 
84
-    echo "\t=> adding stub... ";
85
-    $stub  = '#!/usr/bin/env php'."\n";
86
-    $stub .= '<?php'."\n";
87
-    $stub .= 'Phar::mapPhar(\''.$pharName.'\');'."\n";
88
-    $stub .= 'require_once "phar://'.$pharName.'/autoload.php";'."\n";
89
-    $stub .= '$runner = new PHP_CodeSniffer\Runner();'."\n";
90
-    $stub .= '$exitCode = $runner->run'.$script.'();'."\n";
91
-    $stub .= 'exit($exitCode);'."\n";
92
-    $stub .= '__HALT_COMPILER();';
93
-    $phar->setStub($stub);
94
-
95
-    echo 'done'.PHP_EOL;
84
+	echo "\t=> adding stub... ";
85
+	$stub  = '#!/usr/bin/env php'."\n";
86
+	$stub .= '<?php'."\n";
87
+	$stub .= 'Phar::mapPhar(\''.$pharName.'\');'."\n";
88
+	$stub .= 'require_once "phar://'.$pharName.'/autoload.php";'."\n";
89
+	$stub .= '$runner = new PHP_CodeSniffer\Runner();'."\n";
90
+	$stub .= '$exitCode = $runner->run'.$script.'();'."\n";
91
+	$stub .= 'exit($exitCode);'."\n";
92
+	$stub .= '__HALT_COMPILER();';
93
+	$phar->setStub($stub);
94
+
95
+	echo 'done'.PHP_EOL;
96 96
 }//end foreach
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
  * @link      http://pear.php.net/package/PHP_CodeSniffer
15 15
  */
16 16
 
17
-error_reporting(E_ALL | E_STRICT);
17
+error_reporting( E_ALL | E_STRICT );
18 18
 
19
-if (ini_get('phar.readonly') === '1') {
20
-    echo 'Unable to build, phar.readonly in php.ini is set to read only.'.PHP_EOL;
21
-    exit(1);
19
+if ( ini_get( 'phar.readonly' ) === '1' ) {
20
+    echo 'Unable to build, phar.readonly in php.ini is set to read only.' . PHP_EOL;
21
+    exit( 1 );
22 22
 }
23 23
 
24 24
 $scripts = [
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
     'phpcbf',
27 27
 ];
28 28
 
29
-foreach ($scripts as $script) {
30
-    echo "Building $script phar".PHP_EOL;
29
+foreach ( $scripts as $script ) {
30
+    echo "Building $script phar" . PHP_EOL;
31 31
 
32
-    $pharName = $script.'.phar';
33
-    $pharFile = getcwd().'/'.$pharName;
34
-    echo "\t=> $pharFile".PHP_EOL;
35
-    if (file_exists($pharFile) === true) {
36
-        echo "\t** file exists, removing **".PHP_EOL;
37
-        unlink($pharFile);
32
+    $pharName = $script . '.phar';
33
+    $pharFile = getcwd() . '/' . $pharName;
34
+    echo "\t=> $pharFile" . PHP_EOL;
35
+    if ( file_exists( $pharFile ) === true ) {
36
+        echo "\t** file exists, removing **" . PHP_EOL;
37
+        unlink( $pharFile );
38 38
     }
39 39
 
40
-    $phar = new Phar($pharFile, 0, $pharName);
40
+    $phar = new Phar( $pharFile, 0, $pharName );
41 41
 
42 42
     /*
43 43
         Add the files.
@@ -45,52 +45,52 @@  discard block
 block discarded – undo
45 45
 
46 46
     echo "\t=> adding files... ";
47 47
 
48
-    $srcDir    = realpath(__DIR__.'/../src');
49
-    $srcDirLen = strlen($srcDir);
48
+    $srcDir    = realpath( __DIR__ . '/../src' );
49
+    $srcDirLen = strlen( $srcDir );
50 50
 
51
-    $rdi = new \RecursiveDirectoryIterator($srcDir, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
52
-    $di  = new \RecursiveIteratorIterator($rdi, 0, \RecursiveIteratorIterator::CATCH_GET_CHILD);
51
+    $rdi = new \RecursiveDirectoryIterator( $srcDir, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS );
52
+    $di  = new \RecursiveIteratorIterator( $rdi, 0, \RecursiveIteratorIterator::CATCH_GET_CHILD );
53 53
 
54
-    foreach ($di as $file) {
54
+    foreach ( $di as $file ) {
55 55
         $filename = $file->getFilename();
56 56
 
57 57
         // Skip hidden files.
58
-        if (substr($filename, 0, 1) === '.') {
58
+        if ( substr( $filename, 0, 1 ) === '.' ) {
59 59
             continue;
60 60
         }
61 61
 
62 62
         $fullpath = $file->getPathname();
63
-        if (strpos($fullpath, '/Tests/') !== false) {
63
+        if ( strpos( $fullpath, '/Tests/' ) !== false ) {
64 64
             continue;
65 65
         }
66 66
 
67
-        $path = 'src'.substr($fullpath, $srcDirLen);
67
+        $path = 'src' . substr( $fullpath, $srcDirLen );
68 68
 
69
-        $phar->addFromString($path, php_strip_whitespace($fullpath));
69
+        $phar->addFromString( $path, php_strip_whitespace( $fullpath ) );
70 70
     }
71 71
 
72 72
     // Add autoloader.
73
-    $phar->addFromString('autoload.php', php_strip_whitespace(realpath(__DIR__.'/../autoload.php')));
73
+    $phar->addFromString( 'autoload.php', php_strip_whitespace( realpath( __DIR__ . '/../autoload.php' ) ) );
74 74
 
75 75
     // Add licence file.
76
-    $phar->addFromString('licence.txt', php_strip_whitespace(realpath(__DIR__.'/../licence.txt')));
76
+    $phar->addFromString( 'licence.txt', php_strip_whitespace( realpath( __DIR__ . '/../licence.txt' ) ) );
77 77
 
78
-    echo 'done'.PHP_EOL;
78
+    echo 'done' . PHP_EOL;
79 79
 
80 80
     /*
81 81
         Add the stub.
82 82
     */
83 83
 
84 84
     echo "\t=> adding stub... ";
85
-    $stub  = '#!/usr/bin/env php'."\n";
86
-    $stub .= '<?php'."\n";
87
-    $stub .= 'Phar::mapPhar(\''.$pharName.'\');'."\n";
88
-    $stub .= 'require_once "phar://'.$pharName.'/autoload.php";'."\n";
89
-    $stub .= '$runner = new PHP_CodeSniffer\Runner();'."\n";
90
-    $stub .= '$exitCode = $runner->run'.$script.'();'."\n";
91
-    $stub .= 'exit($exitCode);'."\n";
85
+    $stub  = '#!/usr/bin/env php' . "\n";
86
+    $stub .= '<?php' . "\n";
87
+    $stub .= 'Phar::mapPhar(\'' . $pharName . '\');' . "\n";
88
+    $stub .= 'require_once "phar://' . $pharName . '/autoload.php";' . "\n";
89
+    $stub .= '$runner = new PHP_CodeSniffer\Runner();' . "\n";
90
+    $stub .= '$exitCode = $runner->run' . $script . '();' . "\n";
91
+    $stub .= 'exit($exitCode);' . "\n";
92 92
     $stub .= '__HALT_COMPILER();';
93
-    $phar->setStub($stub);
93
+    $phar->setStub( $stub );
94 94
 
95
-    echo 'done'.PHP_EOL;
95
+    echo 'done' . PHP_EOL;
96 96
 }//end foreach
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 ];
28 28
 
29 29
 foreach ($scripts as $script) {
30
-    echo "Building $script phar".PHP_EOL;
30
+    echo "building $script phar".PHP_EOL;
31 31
 
32 32
     $pharName = $script.'.phar';
33 33
     $pharFile = getcwd().'/'.$pharName;
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/scripts/validate-pear-package.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
  * @license   https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13 13
  */
14 14
 
15
-require_once __DIR__.'/ValidatePEAR/FileList.php';
16
-require_once __DIR__.'/ValidatePEAR/ValidatePEARPackageXML.php';
15
+require_once __DIR__ . '/ValidatePEAR/FileList.php';
16
+require_once __DIR__ . '/ValidatePEAR/ValidatePEARPackageXML.php';
17 17
 
18 18
 $validate = new ValidatePEARPackageXML();
19 19
 $validate->validate();
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Filters/Filter.php 3 patches
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -15,256 +15,256 @@
 block discarded – undo
15 15
 
16 16
 class Filter extends \RecursiveFilterIterator
17 17
 {
18
-    /**
19
-     * The top-level path we are filtering.
20
-     *
21
-     * @var string
22
-     */
23
-    protected $basedir = null;
24
-
25
-    /**
26
-     * The config data for the run.
27
-     *
28
-     * @var \PHP_CodeSniffer\Config
29
-     */
30
-    protected $config = null;
31
-
32
-    /**
33
-     * The ruleset used for the run.
34
-     *
35
-     * @var \PHP_CodeSniffer\Ruleset
36
-     */
37
-    protected $ruleset = null;
38
-
39
-    /**
40
-     * A list of ignore patterns that apply to directories only.
41
-     *
42
-     * @var array
43
-     */
44
-    protected $ignoreDirPatterns = null;
45
-
46
-    /**
47
-     * A list of ignore patterns that apply to files only.
48
-     *
49
-     * @var array
50
-     */
51
-    protected $ignoreFilePatterns = null;
52
-
53
-    /**
54
-     * A list of file paths we've already accepted.
55
-     *
56
-     * Used to ensure we aren't following circular symlinks.
57
-     *
58
-     * @var array
59
-     */
60
-    protected $acceptedPaths = [];
61
-
62
-
63
-    /**
64
-     * Constructs a filter.
65
-     *
66
-     * @param \RecursiveIterator       $iterator The iterator we are using to get file paths.
67
-     * @param string                   $basedir  The top-level path we are filtering.
68
-     * @param \PHP_CodeSniffer\Config  $config   The config data for the run.
69
-     * @param \PHP_CodeSniffer\Ruleset $ruleset  The ruleset used for the run.
70
-     *
71
-     * @return void
72
-     */
73
-    public function __construct($iterator, $basedir, Config $config, Ruleset $ruleset)
74
-    {
75
-        parent::__construct($iterator);
76
-        $this->basedir = $basedir;
77
-        $this->config  = $config;
78
-        $this->ruleset = $ruleset;
79
-
80
-    }//end __construct()
81
-
82
-
83
-    /**
84
-     * Check whether the current element of the iterator is acceptable.
85
-     *
86
-     * Files are checked for allowed extensions and ignore patterns.
87
-     * Directories are checked for ignore patterns only.
88
-     *
89
-     * @return bool
90
-     */
91
-    public function accept()
92
-    {
93
-        $filePath = $this->current();
94
-        $realPath = Util\Common::realpath($filePath);
95
-
96
-        if ($realPath !== false) {
97
-            // It's a real path somewhere, so record it
98
-            // to check for circular symlinks.
99
-            if (isset($this->acceptedPaths[$realPath]) === true) {
100
-                // We've been here before.
101
-                return false;
102
-            }
103
-        }
104
-
105
-        $filePath = $this->current();
106
-        if (is_dir($filePath) === true) {
107
-            if ($this->config->local === true) {
108
-                return false;
109
-            }
110
-        } else if ($this->shouldProcessFile($filePath) === false) {
111
-            return false;
112
-        }
113
-
114
-        if ($this->shouldIgnorePath($filePath) === true) {
115
-            return false;
116
-        }
117
-
118
-        $this->acceptedPaths[$realPath] = true;
119
-        return true;
120
-
121
-    }//end accept()
122
-
123
-
124
-    /**
125
-     * Returns an iterator for the current entry.
126
-     *
127
-     * Ensures that the ignore patterns are preserved so they don't have
128
-     * to be generated each time.
129
-     *
130
-     * @return \RecursiveIterator
131
-     */
132
-    public function getChildren()
133
-    {
134
-        $children = new static(
135
-            new \RecursiveDirectoryIterator($this->current(), (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)),
136
-            $this->basedir,
137
-            $this->config,
138
-            $this->ruleset
139
-        );
140
-
141
-        // Set the ignore patterns so we don't have to generate them again.
142
-        $children->ignoreDirPatterns  = $this->ignoreDirPatterns;
143
-        $children->ignoreFilePatterns = $this->ignoreFilePatterns;
144
-        $children->acceptedPaths      = $this->acceptedPaths;
145
-        return $children;
146
-
147
-    }//end getChildren()
148
-
149
-
150
-    /**
151
-     * Checks filtering rules to see if a file should be checked.
152
-     *
153
-     * Checks both file extension filters and path ignore filters.
154
-     *
155
-     * @param string $path The path to the file being checked.
156
-     *
157
-     * @return bool
158
-     */
159
-    protected function shouldProcessFile($path)
160
-    {
161
-        // Check that the file's extension is one we are checking.
162
-        // We are strict about checking the extension and we don't
163
-        // let files through with no extension or that start with a dot.
164
-        $fileName  = basename($path);
165
-        $fileParts = explode('.', $fileName);
166
-        if ($fileParts[0] === $fileName || $fileParts[0] === '') {
167
-            return false;
168
-        }
169
-
170
-        // Checking multi-part file extensions, so need to create a
171
-        // complete extension list and make sure one is allowed.
172
-        $extensions = [];
173
-        array_shift($fileParts);
174
-        foreach ($fileParts as $part) {
175
-            $extensions[implode('.', $fileParts)] = 1;
176
-            array_shift($fileParts);
177
-        }
178
-
179
-        $matches = array_intersect_key($extensions, $this->config->extensions);
180
-        if (empty($matches) === true) {
181
-            return false;
182
-        }
183
-
184
-        return true;
185
-
186
-    }//end shouldProcessFile()
187
-
188
-
189
-    /**
190
-     * Checks filtering rules to see if a path should be ignored.
191
-     *
192
-     * @param string $path The path to the file or directory being checked.
193
-     *
194
-     * @return bool
195
-     */
196
-    protected function shouldIgnorePath($path)
197
-    {
198
-        if ($this->ignoreFilePatterns === null) {
199
-            $this->ignoreDirPatterns  = [];
200
-            $this->ignoreFilePatterns = [];
201
-
202
-            $ignorePatterns = array_merge($this->config->ignored, $this->ruleset->getIgnorePatterns());
203
-            foreach ($ignorePatterns as $pattern => $type) {
204
-                // If the ignore pattern ends with /* then it is ignoring an entire directory.
205
-                if (substr($pattern, -2) === '/*') {
206
-                    // Need to check this pattern for dirs as well as individual file paths.
207
-                    $this->ignoreFilePatterns[$pattern] = $type;
208
-
209
-                    $pattern = substr($pattern, 0, -2);
210
-                    $this->ignoreDirPatterns[$pattern] = $type;
211
-                } else {
212
-                    // This is a file-specific pattern, so only need to check this
213
-                    // for individual file paths.
214
-                    $this->ignoreFilePatterns[$pattern] = $type;
215
-                }
216
-            }
217
-        }
218
-
219
-        $relativePath = $path;
220
-        if (strpos($path, $this->basedir) === 0) {
221
-            // The +1 cuts off the directory separator as well.
222
-            $relativePath = substr($path, (strlen($this->basedir) + 1));
223
-        }
224
-
225
-        if (is_dir($path) === true) {
226
-            $ignorePatterns = $this->ignoreDirPatterns;
227
-        } else {
228
-            $ignorePatterns = $this->ignoreFilePatterns;
229
-        }
230
-
231
-        foreach ($ignorePatterns as $pattern => $type) {
232
-            // Maintains backwards compatibility in case the ignore pattern does
233
-            // not have a relative/absolute value.
234
-            if (is_int($pattern) === true) {
235
-                $pattern = $type;
236
-                $type    = 'absolute';
237
-            }
238
-
239
-            $replacements = [
240
-                '\\,' => ',',
241
-                '*'   => '.*',
242
-            ];
243
-
244
-            // We assume a / directory separator, as do the exclude rules
245
-            // most developers write, so we need a special case for any system
246
-            // that is different.
247
-            if (DIRECTORY_SEPARATOR === '\\') {
248
-                $replacements['/'] = '\\\\';
249
-            }
250
-
251
-            $pattern = strtr($pattern, $replacements);
252
-
253
-            if ($type === 'relative') {
254
-                $testPath = $relativePath;
255
-            } else {
256
-                $testPath = $path;
257
-            }
258
-
259
-            $pattern = '`'.$pattern.'`i';
260
-            if (preg_match($pattern, $testPath) === 1) {
261
-                return true;
262
-            }
263
-        }//end foreach
264
-
265
-        return false;
266
-
267
-    }//end shouldIgnorePath()
18
+	/**
19
+	 * The top-level path we are filtering.
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $basedir = null;
24
+
25
+	/**
26
+	 * The config data for the run.
27
+	 *
28
+	 * @var \PHP_CodeSniffer\Config
29
+	 */
30
+	protected $config = null;
31
+
32
+	/**
33
+	 * The ruleset used for the run.
34
+	 *
35
+	 * @var \PHP_CodeSniffer\Ruleset
36
+	 */
37
+	protected $ruleset = null;
38
+
39
+	/**
40
+	 * A list of ignore patterns that apply to directories only.
41
+	 *
42
+	 * @var array
43
+	 */
44
+	protected $ignoreDirPatterns = null;
45
+
46
+	/**
47
+	 * A list of ignore patterns that apply to files only.
48
+	 *
49
+	 * @var array
50
+	 */
51
+	protected $ignoreFilePatterns = null;
52
+
53
+	/**
54
+	 * A list of file paths we've already accepted.
55
+	 *
56
+	 * Used to ensure we aren't following circular symlinks.
57
+	 *
58
+	 * @var array
59
+	 */
60
+	protected $acceptedPaths = [];
61
+
62
+
63
+	/**
64
+	 * Constructs a filter.
65
+	 *
66
+	 * @param \RecursiveIterator       $iterator The iterator we are using to get file paths.
67
+	 * @param string                   $basedir  The top-level path we are filtering.
68
+	 * @param \PHP_CodeSniffer\Config  $config   The config data for the run.
69
+	 * @param \PHP_CodeSniffer\Ruleset $ruleset  The ruleset used for the run.
70
+	 *
71
+	 * @return void
72
+	 */
73
+	public function __construct($iterator, $basedir, Config $config, Ruleset $ruleset)
74
+	{
75
+		parent::__construct($iterator);
76
+		$this->basedir = $basedir;
77
+		$this->config  = $config;
78
+		$this->ruleset = $ruleset;
79
+
80
+	}//end __construct()
81
+
82
+
83
+	/**
84
+	 * Check whether the current element of the iterator is acceptable.
85
+	 *
86
+	 * Files are checked for allowed extensions and ignore patterns.
87
+	 * Directories are checked for ignore patterns only.
88
+	 *
89
+	 * @return bool
90
+	 */
91
+	public function accept()
92
+	{
93
+		$filePath = $this->current();
94
+		$realPath = Util\Common::realpath($filePath);
95
+
96
+		if ($realPath !== false) {
97
+			// It's a real path somewhere, so record it
98
+			// to check for circular symlinks.
99
+			if (isset($this->acceptedPaths[$realPath]) === true) {
100
+				// We've been here before.
101
+				return false;
102
+			}
103
+		}
104
+
105
+		$filePath = $this->current();
106
+		if (is_dir($filePath) === true) {
107
+			if ($this->config->local === true) {
108
+				return false;
109
+			}
110
+		} else if ($this->shouldProcessFile($filePath) === false) {
111
+			return false;
112
+		}
113
+
114
+		if ($this->shouldIgnorePath($filePath) === true) {
115
+			return false;
116
+		}
117
+
118
+		$this->acceptedPaths[$realPath] = true;
119
+		return true;
120
+
121
+	}//end accept()
122
+
123
+
124
+	/**
125
+	 * Returns an iterator for the current entry.
126
+	 *
127
+	 * Ensures that the ignore patterns are preserved so they don't have
128
+	 * to be generated each time.
129
+	 *
130
+	 * @return \RecursiveIterator
131
+	 */
132
+	public function getChildren()
133
+	{
134
+		$children = new static(
135
+			new \RecursiveDirectoryIterator($this->current(), (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)),
136
+			$this->basedir,
137
+			$this->config,
138
+			$this->ruleset
139
+		);
140
+
141
+		// Set the ignore patterns so we don't have to generate them again.
142
+		$children->ignoreDirPatterns  = $this->ignoreDirPatterns;
143
+		$children->ignoreFilePatterns = $this->ignoreFilePatterns;
144
+		$children->acceptedPaths      = $this->acceptedPaths;
145
+		return $children;
146
+
147
+	}//end getChildren()
148
+
149
+
150
+	/**
151
+	 * Checks filtering rules to see if a file should be checked.
152
+	 *
153
+	 * Checks both file extension filters and path ignore filters.
154
+	 *
155
+	 * @param string $path The path to the file being checked.
156
+	 *
157
+	 * @return bool
158
+	 */
159
+	protected function shouldProcessFile($path)
160
+	{
161
+		// Check that the file's extension is one we are checking.
162
+		// We are strict about checking the extension and we don't
163
+		// let files through with no extension or that start with a dot.
164
+		$fileName  = basename($path);
165
+		$fileParts = explode('.', $fileName);
166
+		if ($fileParts[0] === $fileName || $fileParts[0] === '') {
167
+			return false;
168
+		}
169
+
170
+		// Checking multi-part file extensions, so need to create a
171
+		// complete extension list and make sure one is allowed.
172
+		$extensions = [];
173
+		array_shift($fileParts);
174
+		foreach ($fileParts as $part) {
175
+			$extensions[implode('.', $fileParts)] = 1;
176
+			array_shift($fileParts);
177
+		}
178
+
179
+		$matches = array_intersect_key($extensions, $this->config->extensions);
180
+		if (empty($matches) === true) {
181
+			return false;
182
+		}
183
+
184
+		return true;
185
+
186
+	}//end shouldProcessFile()
187
+
188
+
189
+	/**
190
+	 * Checks filtering rules to see if a path should be ignored.
191
+	 *
192
+	 * @param string $path The path to the file or directory being checked.
193
+	 *
194
+	 * @return bool
195
+	 */
196
+	protected function shouldIgnorePath($path)
197
+	{
198
+		if ($this->ignoreFilePatterns === null) {
199
+			$this->ignoreDirPatterns  = [];
200
+			$this->ignoreFilePatterns = [];
201
+
202
+			$ignorePatterns = array_merge($this->config->ignored, $this->ruleset->getIgnorePatterns());
203
+			foreach ($ignorePatterns as $pattern => $type) {
204
+				// If the ignore pattern ends with /* then it is ignoring an entire directory.
205
+				if (substr($pattern, -2) === '/*') {
206
+					// Need to check this pattern for dirs as well as individual file paths.
207
+					$this->ignoreFilePatterns[$pattern] = $type;
208
+
209
+					$pattern = substr($pattern, 0, -2);
210
+					$this->ignoreDirPatterns[$pattern] = $type;
211
+				} else {
212
+					// This is a file-specific pattern, so only need to check this
213
+					// for individual file paths.
214
+					$this->ignoreFilePatterns[$pattern] = $type;
215
+				}
216
+			}
217
+		}
218
+
219
+		$relativePath = $path;
220
+		if (strpos($path, $this->basedir) === 0) {
221
+			// The +1 cuts off the directory separator as well.
222
+			$relativePath = substr($path, (strlen($this->basedir) + 1));
223
+		}
224
+
225
+		if (is_dir($path) === true) {
226
+			$ignorePatterns = $this->ignoreDirPatterns;
227
+		} else {
228
+			$ignorePatterns = $this->ignoreFilePatterns;
229
+		}
230
+
231
+		foreach ($ignorePatterns as $pattern => $type) {
232
+			// Maintains backwards compatibility in case the ignore pattern does
233
+			// not have a relative/absolute value.
234
+			if (is_int($pattern) === true) {
235
+				$pattern = $type;
236
+				$type    = 'absolute';
237
+			}
238
+
239
+			$replacements = [
240
+				'\\,' => ',',
241
+				'*'   => '.*',
242
+			];
243
+
244
+			// We assume a / directory separator, as do the exclude rules
245
+			// most developers write, so we need a special case for any system
246
+			// that is different.
247
+			if (DIRECTORY_SEPARATOR === '\\') {
248
+				$replacements['/'] = '\\\\';
249
+			}
250
+
251
+			$pattern = strtr($pattern, $replacements);
252
+
253
+			if ($type === 'relative') {
254
+				$testPath = $relativePath;
255
+			} else {
256
+				$testPath = $path;
257
+			}
258
+
259
+			$pattern = '`'.$pattern.'`i';
260
+			if (preg_match($pattern, $testPath) === 1) {
261
+				return true;
262
+			}
263
+		}//end foreach
264
+
265
+		return false;
266
+
267
+	}//end shouldIgnorePath()
268 268
 
269 269
 
270 270
 }//end class
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @var array
59 59
      */
60
-    protected $acceptedPaths = [];
60
+    protected $acceptedPaths = [ ];
61 61
 
62 62
 
63 63
     /**
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
      *
71 71
      * @return void
72 72
      */
73
-    public function __construct($iterator, $basedir, Config $config, Ruleset $ruleset)
73
+    public function __construct( $iterator, $basedir, Config $config, Ruleset $ruleset )
74 74
     {
75
-        parent::__construct($iterator);
75
+        parent::__construct( $iterator );
76 76
         $this->basedir = $basedir;
77 77
         $this->config  = $config;
78 78
         $this->ruleset = $ruleset;
@@ -91,31 +91,31 @@  discard block
 block discarded – undo
91 91
     public function accept()
92 92
     {
93 93
         $filePath = $this->current();
94
-        $realPath = Util\Common::realpath($filePath);
94
+        $realPath = Util\Common::realpath( $filePath );
95 95
 
96
-        if ($realPath !== false) {
96
+        if ( $realPath !== false ) {
97 97
             // It's a real path somewhere, so record it
98 98
             // to check for circular symlinks.
99
-            if (isset($this->acceptedPaths[$realPath]) === true) {
99
+            if ( isset( $this->acceptedPaths[ $realPath ] ) === true ) {
100 100
                 // We've been here before.
101 101
                 return false;
102 102
             }
103 103
         }
104 104
 
105 105
         $filePath = $this->current();
106
-        if (is_dir($filePath) === true) {
107
-            if ($this->config->local === true) {
106
+        if ( is_dir( $filePath ) === true ) {
107
+            if ( $this->config->local === true ) {
108 108
                 return false;
109 109
             }
110
-        } else if ($this->shouldProcessFile($filePath) === false) {
110
+        } else if ( $this->shouldProcessFile( $filePath ) === false ) {
111 111
             return false;
112 112
         }
113 113
 
114
-        if ($this->shouldIgnorePath($filePath) === true) {
114
+        if ( $this->shouldIgnorePath( $filePath ) === true ) {
115 115
             return false;
116 116
         }
117 117
 
118
-        $this->acceptedPaths[$realPath] = true;
118
+        $this->acceptedPaths[ $realPath ] = true;
119 119
         return true;
120 120
 
121 121
     }//end accept()
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     public function getChildren()
133 133
     {
134 134
         $children = new static(
135
-            new \RecursiveDirectoryIterator($this->current(), (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)),
135
+            new \RecursiveDirectoryIterator( $this->current(), ( \RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS ) ),
136 136
             $this->basedir,
137 137
             $this->config,
138 138
             $this->ruleset
@@ -156,28 +156,28 @@  discard block
 block discarded – undo
156 156
      *
157 157
      * @return bool
158 158
      */
159
-    protected function shouldProcessFile($path)
159
+    protected function shouldProcessFile( $path )
160 160
     {
161 161
         // Check that the file's extension is one we are checking.
162 162
         // We are strict about checking the extension and we don't
163 163
         // let files through with no extension or that start with a dot.
164
-        $fileName  = basename($path);
165
-        $fileParts = explode('.', $fileName);
166
-        if ($fileParts[0] === $fileName || $fileParts[0] === '') {
164
+        $fileName  = basename( $path );
165
+        $fileParts = explode( '.', $fileName );
166
+        if ( $fileParts[ 0 ] === $fileName || $fileParts[ 0 ] === '' ) {
167 167
             return false;
168 168
         }
169 169
 
170 170
         // Checking multi-part file extensions, so need to create a
171 171
         // complete extension list and make sure one is allowed.
172
-        $extensions = [];
173
-        array_shift($fileParts);
174
-        foreach ($fileParts as $part) {
175
-            $extensions[implode('.', $fileParts)] = 1;
176
-            array_shift($fileParts);
172
+        $extensions = [ ];
173
+        array_shift( $fileParts );
174
+        foreach ( $fileParts as $part ) {
175
+            $extensions[ implode( '.', $fileParts ) ] = 1;
176
+            array_shift( $fileParts );
177 177
         }
178 178
 
179
-        $matches = array_intersect_key($extensions, $this->config->extensions);
180
-        if (empty($matches) === true) {
179
+        $matches = array_intersect_key( $extensions, $this->config->extensions );
180
+        if ( empty( $matches ) === true ) {
181 181
             return false;
182 182
         }
183 183
 
@@ -193,45 +193,45 @@  discard block
 block discarded – undo
193 193
      *
194 194
      * @return bool
195 195
      */
196
-    protected function shouldIgnorePath($path)
196
+    protected function shouldIgnorePath( $path )
197 197
     {
198
-        if ($this->ignoreFilePatterns === null) {
199
-            $this->ignoreDirPatterns  = [];
200
-            $this->ignoreFilePatterns = [];
198
+        if ( $this->ignoreFilePatterns === null ) {
199
+            $this->ignoreDirPatterns  = [ ];
200
+            $this->ignoreFilePatterns = [ ];
201 201
 
202
-            $ignorePatterns = array_merge($this->config->ignored, $this->ruleset->getIgnorePatterns());
203
-            foreach ($ignorePatterns as $pattern => $type) {
202
+            $ignorePatterns = array_merge( $this->config->ignored, $this->ruleset->getIgnorePatterns() );
203
+            foreach ( $ignorePatterns as $pattern => $type ) {
204 204
                 // If the ignore pattern ends with /* then it is ignoring an entire directory.
205
-                if (substr($pattern, -2) === '/*') {
205
+                if ( substr( $pattern, -2 ) === '/*' ) {
206 206
                     // Need to check this pattern for dirs as well as individual file paths.
207
-                    $this->ignoreFilePatterns[$pattern] = $type;
207
+                    $this->ignoreFilePatterns[ $pattern ] = $type;
208 208
 
209
-                    $pattern = substr($pattern, 0, -2);
210
-                    $this->ignoreDirPatterns[$pattern] = $type;
209
+                    $pattern = substr( $pattern, 0, -2 );
210
+                    $this->ignoreDirPatterns[ $pattern ] = $type;
211 211
                 } else {
212 212
                     // This is a file-specific pattern, so only need to check this
213 213
                     // for individual file paths.
214
-                    $this->ignoreFilePatterns[$pattern] = $type;
214
+                    $this->ignoreFilePatterns[ $pattern ] = $type;
215 215
                 }
216 216
             }
217 217
         }
218 218
 
219 219
         $relativePath = $path;
220
-        if (strpos($path, $this->basedir) === 0) {
220
+        if ( strpos( $path, $this->basedir ) === 0 ) {
221 221
             // The +1 cuts off the directory separator as well.
222
-            $relativePath = substr($path, (strlen($this->basedir) + 1));
222
+            $relativePath = substr( $path, ( strlen( $this->basedir ) + 1 ) );
223 223
         }
224 224
 
225
-        if (is_dir($path) === true) {
225
+        if ( is_dir( $path ) === true ) {
226 226
             $ignorePatterns = $this->ignoreDirPatterns;
227 227
         } else {
228 228
             $ignorePatterns = $this->ignoreFilePatterns;
229 229
         }
230 230
 
231
-        foreach ($ignorePatterns as $pattern => $type) {
231
+        foreach ( $ignorePatterns as $pattern => $type ) {
232 232
             // Maintains backwards compatibility in case the ignore pattern does
233 233
             // not have a relative/absolute value.
234
-            if (is_int($pattern) === true) {
234
+            if ( is_int( $pattern ) === true ) {
235 235
                 $pattern = $type;
236 236
                 $type    = 'absolute';
237 237
             }
@@ -244,20 +244,20 @@  discard block
 block discarded – undo
244 244
             // We assume a / directory separator, as do the exclude rules
245 245
             // most developers write, so we need a special case for any system
246 246
             // that is different.
247
-            if (DIRECTORY_SEPARATOR === '\\') {
248
-                $replacements['/'] = '\\\\';
247
+            if ( DIRECTORY_SEPARATOR === '\\' ) {
248
+                $replacements[ '/' ] = '\\\\';
249 249
             }
250 250
 
251
-            $pattern = strtr($pattern, $replacements);
251
+            $pattern = strtr( $pattern, $replacements );
252 252
 
253
-            if ($type === 'relative') {
253
+            if ( $type === 'relative' ) {
254 254
                 $testPath = $relativePath;
255 255
             } else {
256 256
                 $testPath = $path;
257 257
             }
258 258
 
259
-            $pattern = '`'.$pattern.'`i';
260
-            if (preg_match($pattern, $testPath) === 1) {
259
+            $pattern = '`' . $pattern . '`i';
260
+            if ( preg_match( $pattern, $testPath ) === 1 ) {
261 261
                 return true;
262 262
             }
263 263
         }//end foreach
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@  discard block
 block discarded – undo
13 13
 use PHP_CodeSniffer\Ruleset;
14 14
 use PHP_CodeSniffer\Config;
15 15
 
16
-class Filter extends \RecursiveFilterIterator
17
-{
16
+class Filter extends \RecursiveFilterIterator {
18 17
     /**
19 18
      * The top-level path we are filtering.
20 19
      *
@@ -70,8 +69,7 @@  discard block
 block discarded – undo
70 69
      *
71 70
      * @return void
72 71
      */
73
-    public function __construct($iterator, $basedir, Config $config, Ruleset $ruleset)
74
-    {
72
+    public function __construct($iterator, $basedir, Config $config, Ruleset $ruleset) {
75 73
         parent::__construct($iterator);
76 74
         $this->basedir = $basedir;
77 75
         $this->config  = $config;
@@ -88,8 +86,7 @@  discard block
 block discarded – undo
88 86
      *
89 87
      * @return bool
90 88
      */
91
-    public function accept()
92
-    {
89
+    public function accept() {
93 90
         $filePath = $this->current();
94 91
         $realPath = Util\Common::realpath($filePath);
95 92
 
@@ -129,8 +126,7 @@  discard block
 block discarded – undo
129 126
      *
130 127
      * @return \RecursiveIterator
131 128
      */
132
-    public function getChildren()
133
-    {
129
+    public function getChildren() {
134 130
         $children = new static(
135 131
             new \RecursiveDirectoryIterator($this->current(), (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)),
136 132
             $this->basedir,
@@ -156,8 +152,7 @@  discard block
 block discarded – undo
156 152
      *
157 153
      * @return bool
158 154
      */
159
-    protected function shouldProcessFile($path)
160
-    {
155
+    protected function shouldProcessFile($path) {
161 156
         // Check that the file's extension is one we are checking.
162 157
         // We are strict about checking the extension and we don't
163 158
         // let files through with no extension or that start with a dot.
@@ -193,8 +188,7 @@  discard block
 block discarded – undo
193 188
      *
194 189
      * @return bool
195 190
      */
196
-    protected function shouldIgnorePath($path)
197
-    {
191
+    protected function shouldIgnorePath($path) {
198 192
         if ($this->ignoreFilePatterns === null) {
199 193
             $this->ignoreDirPatterns  = [];
200 194
             $this->ignoreFilePatterns = [];
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Filters/ExactMatch.php 3 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -16,93 +16,93 @@
 block discarded – undo
16 16
 abstract class ExactMatch extends Filter
17 17
 {
18 18
 
19
-    /**
20
-     * A list of files to exclude.
21
-     *
22
-     * @var array
23
-     */
24
-    private $blacklist = null;
25
-
26
-    /**
27
-     * A list of files to include.
28
-     *
29
-     * If the whitelist is empty, only files in the blacklist will be excluded.
30
-     *
31
-     * @var array
32
-     */
33
-    private $whitelist = null;
34
-
35
-
36
-    /**
37
-     * Check whether the current element of the iterator is acceptable.
38
-     *
39
-     * If a file is both blacklisted and whitelisted, it will be deemed unacceptable.
40
-     *
41
-     * @return bool
42
-     */
43
-    public function accept()
44
-    {
45
-        if (parent::accept() === false) {
46
-            return false;
47
-        }
48
-
49
-        if ($this->blacklist === null) {
50
-            $this->blacklist = $this->getblacklist();
51
-        }
52
-
53
-        if ($this->whitelist === null) {
54
-            $this->whitelist = $this->getwhitelist();
55
-        }
56
-
57
-        $filePath = Util\Common::realpath($this->current());
58
-
59
-        // If file is both blacklisted and whitelisted, the blacklist takes precedence.
60
-        if (isset($this->blacklist[$filePath]) === true) {
61
-            return false;
62
-        }
63
-
64
-        if (empty($this->whitelist) === true && empty($this->blacklist) === false) {
65
-            // We are only checking a blacklist, so everything else should be whitelisted.
66
-            return true;
67
-        }
68
-
69
-        return isset($this->whitelist[$filePath]);
70
-
71
-    }//end accept()
72
-
73
-
74
-    /**
75
-     * Returns an iterator for the current entry.
76
-     *
77
-     * Ensures that the blacklist and whitelist are preserved so they don't have
78
-     * to be generated each time.
79
-     *
80
-     * @return \RecursiveIterator
81
-     */
82
-    public function getChildren()
83
-    {
84
-        $children            = parent::getChildren();
85
-        $children->blacklist = $this->blacklist;
86
-        $children->whitelist = $this->whitelist;
87
-        return $children;
88
-
89
-    }//end getChildren()
90
-
91
-
92
-    /**
93
-     * Get a list of blacklisted file paths.
94
-     *
95
-     * @return array
96
-     */
97
-    abstract protected function getBlacklist();
98
-
99
-
100
-    /**
101
-     * Get a list of whitelisted file paths.
102
-     *
103
-     * @return array
104
-     */
105
-    abstract protected function getWhitelist();
19
+	/**
20
+	 * A list of files to exclude.
21
+	 *
22
+	 * @var array
23
+	 */
24
+	private $blacklist = null;
25
+
26
+	/**
27
+	 * A list of files to include.
28
+	 *
29
+	 * If the whitelist is empty, only files in the blacklist will be excluded.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	private $whitelist = null;
34
+
35
+
36
+	/**
37
+	 * Check whether the current element of the iterator is acceptable.
38
+	 *
39
+	 * If a file is both blacklisted and whitelisted, it will be deemed unacceptable.
40
+	 *
41
+	 * @return bool
42
+	 */
43
+	public function accept()
44
+	{
45
+		if (parent::accept() === false) {
46
+			return false;
47
+		}
48
+
49
+		if ($this->blacklist === null) {
50
+			$this->blacklist = $this->getblacklist();
51
+		}
52
+
53
+		if ($this->whitelist === null) {
54
+			$this->whitelist = $this->getwhitelist();
55
+		}
56
+
57
+		$filePath = Util\Common::realpath($this->current());
58
+
59
+		// If file is both blacklisted and whitelisted, the blacklist takes precedence.
60
+		if (isset($this->blacklist[$filePath]) === true) {
61
+			return false;
62
+		}
63
+
64
+		if (empty($this->whitelist) === true && empty($this->blacklist) === false) {
65
+			// We are only checking a blacklist, so everything else should be whitelisted.
66
+			return true;
67
+		}
68
+
69
+		return isset($this->whitelist[$filePath]);
70
+
71
+	}//end accept()
72
+
73
+
74
+	/**
75
+	 * Returns an iterator for the current entry.
76
+	 *
77
+	 * Ensures that the blacklist and whitelist are preserved so they don't have
78
+	 * to be generated each time.
79
+	 *
80
+	 * @return \RecursiveIterator
81
+	 */
82
+	public function getChildren()
83
+	{
84
+		$children            = parent::getChildren();
85
+		$children->blacklist = $this->blacklist;
86
+		$children->whitelist = $this->whitelist;
87
+		return $children;
88
+
89
+	}//end getChildren()
90
+
91
+
92
+	/**
93
+	 * Get a list of blacklisted file paths.
94
+	 *
95
+	 * @return array
96
+	 */
97
+	abstract protected function getBlacklist();
98
+
99
+
100
+	/**
101
+	 * Get a list of whitelisted file paths.
102
+	 *
103
+	 * @return array
104
+	 */
105
+	abstract protected function getWhitelist();
106 106
 
107 107
 
108 108
 }//end class
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,31 +42,31 @@
 block discarded – undo
42 42
      */
43 43
     public function accept()
44 44
     {
45
-        if (parent::accept() === false) {
45
+        if ( parent::accept() === false ) {
46 46
             return false;
47 47
         }
48 48
 
49
-        if ($this->blacklist === null) {
49
+        if ( $this->blacklist === null ) {
50 50
             $this->blacklist = $this->getblacklist();
51 51
         }
52 52
 
53
-        if ($this->whitelist === null) {
53
+        if ( $this->whitelist === null ) {
54 54
             $this->whitelist = $this->getwhitelist();
55 55
         }
56 56
 
57
-        $filePath = Util\Common::realpath($this->current());
57
+        $filePath = Util\Common::realpath( $this->current() );
58 58
 
59 59
         // If file is both blacklisted and whitelisted, the blacklist takes precedence.
60
-        if (isset($this->blacklist[$filePath]) === true) {
60
+        if ( isset( $this->blacklist[ $filePath ] ) === true ) {
61 61
             return false;
62 62
         }
63 63
 
64
-        if (empty($this->whitelist) === true && empty($this->blacklist) === false) {
64
+        if ( empty( $this->whitelist ) === true && empty( $this->blacklist ) === false ) {
65 65
             // We are only checking a blacklist, so everything else should be whitelisted.
66 66
             return true;
67 67
         }
68 68
 
69
-        return isset($this->whitelist[$filePath]);
69
+        return isset( $this->whitelist[ $filePath ] );
70 70
 
71 71
     }//end accept()
72 72
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 use PHP_CodeSniffer\Util;
15 15
 
16
-abstract class ExactMatch extends Filter
17
-{
16
+abstract class ExactMatch extends Filter {
18 17
 
19 18
     /**
20 19
      * A list of files to exclude.
@@ -40,8 +39,7 @@  discard block
 block discarded – undo
40 39
      *
41 40
      * @return bool
42 41
      */
43
-    public function accept()
44
-    {
42
+    public function accept() {
45 43
         if (parent::accept() === false) {
46 44
             return false;
47 45
         }
@@ -79,8 +77,7 @@  discard block
 block discarded – undo
79 77
      *
80 78
      * @return \RecursiveIterator
81 79
      */
82
-    public function getChildren()
83
-    {
80
+    public function getChildren() {
84 81
         $children            = parent::getChildren();
85 82
         $children->blacklist = $this->blacklist;
86 83
         $children->whitelist = $this->whitelist;
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Filters/GitModified.php 3 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -15,52 +15,52 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Get a list of blacklisted file paths.
20
-     *
21
-     * @return array
22
-     */
23
-    protected function getBlacklist()
24
-    {
25
-        return [];
26
-
27
-    }//end getBlacklist()
28
-
29
-
30
-    /**
31
-     * Get a list of whitelisted file paths.
32
-     *
33
-     * @return array
34
-     */
35
-    protected function getWhitelist()
36
-    {
37
-        $modified = [];
38
-
39
-        $cmd    = 'git ls-files -o -m --exclude-standard -- '.escapeshellarg($this->basedir);
40
-        $output = [];
41
-        exec($cmd, $output);
42
-
43
-        $basedir = $this->basedir;
44
-        if (is_dir($basedir) === false) {
45
-            $basedir = dirname($basedir);
46
-        }
47
-
48
-        foreach ($output as $path) {
49
-            $path = Util\Common::realpath($path);
50
-
51
-            if ($path === false) {
52
-                continue;
53
-            }
54
-
55
-            do {
56
-                $modified[$path] = true;
57
-                $path            = dirname($path);
58
-            } while ($path !== $basedir);
59
-        }
60
-
61
-        return $modified;
62
-
63
-    }//end getWhitelist()
18
+	/**
19
+	 * Get a list of blacklisted file paths.
20
+	 *
21
+	 * @return array
22
+	 */
23
+	protected function getBlacklist()
24
+	{
25
+		return [];
26
+
27
+	}//end getBlacklist()
28
+
29
+
30
+	/**
31
+	 * Get a list of whitelisted file paths.
32
+	 *
33
+	 * @return array
34
+	 */
35
+	protected function getWhitelist()
36
+	{
37
+		$modified = [];
38
+
39
+		$cmd    = 'git ls-files -o -m --exclude-standard -- '.escapeshellarg($this->basedir);
40
+		$output = [];
41
+		exec($cmd, $output);
42
+
43
+		$basedir = $this->basedir;
44
+		if (is_dir($basedir) === false) {
45
+			$basedir = dirname($basedir);
46
+		}
47
+
48
+		foreach ($output as $path) {
49
+			$path = Util\Common::realpath($path);
50
+
51
+			if ($path === false) {
52
+				continue;
53
+			}
54
+
55
+			do {
56
+				$modified[$path] = true;
57
+				$path            = dirname($path);
58
+			} while ($path !== $basedir);
59
+		}
60
+
61
+		return $modified;
62
+
63
+	}//end getWhitelist()
64 64
 
65 65
 
66 66
 }//end class
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     protected function getBlacklist()
24 24
     {
25
-        return [];
25
+        return [ ];
26 26
 
27 27
     }//end getBlacklist()
28 28
 
@@ -34,28 +34,28 @@  discard block
 block discarded – undo
34 34
      */
35 35
     protected function getWhitelist()
36 36
     {
37
-        $modified = [];
37
+        $modified = [ ];
38 38
 
39
-        $cmd    = 'git ls-files -o -m --exclude-standard -- '.escapeshellarg($this->basedir);
40
-        $output = [];
41
-        exec($cmd, $output);
39
+        $cmd    = 'git ls-files -o -m --exclude-standard -- ' . escapeshellarg( $this->basedir );
40
+        $output = [ ];
41
+        exec( $cmd, $output );
42 42
 
43 43
         $basedir = $this->basedir;
44
-        if (is_dir($basedir) === false) {
45
-            $basedir = dirname($basedir);
44
+        if ( is_dir( $basedir ) === false ) {
45
+            $basedir = dirname( $basedir );
46 46
         }
47 47
 
48
-        foreach ($output as $path) {
49
-            $path = Util\Common::realpath($path);
48
+        foreach ( $output as $path ) {
49
+            $path = Util\Common::realpath( $path );
50 50
 
51
-            if ($path === false) {
51
+            if ( $path === false ) {
52 52
                 continue;
53 53
             }
54 54
 
55 55
             do {
56
-                $modified[$path] = true;
57
-                $path            = dirname($path);
58
-            } while ($path !== $basedir);
56
+                $modified[ $path ] = true;
57
+                $path            = dirname( $path );
58
+            } while ( $path !== $basedir );
59 59
         }
60 60
 
61 61
         return $modified;
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 use PHP_CodeSniffer\Util;
13 13
 
14
-class GitModified extends ExactMatch
15
-{
14
+class GitModified extends ExactMatch {
16 15
 
17 16
 
18 17
     /**
@@ -20,8 +19,7 @@  discard block
 block discarded – undo
20 19
      *
21 20
      * @return array
22 21
      */
23
-    protected function getBlacklist()
24
-    {
22
+    protected function getBlacklist() {
25 23
         return [];
26 24
 
27 25
     }//end getBlacklist()
@@ -32,8 +30,7 @@  discard block
 block discarded – undo
32 30
      *
33 31
      * @return array
34 32
      */
35
-    protected function getWhitelist()
36
-    {
33
+    protected function getWhitelist() {
37 34
         $modified = [];
38 35
 
39 36
         $cmd    = 'git ls-files -o -m --exclude-standard -- '.escapeshellarg($this->basedir);
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Reporter.php 3 patches
Indentation   +399 added lines, -399 removed lines patch added patch discarded remove patch
@@ -18,405 +18,405 @@
 block discarded – undo
18 18
 class Reporter
19 19
 {
20 20
 
21
-    /**
22
-     * The config data for the run.
23
-     *
24
-     * @var \PHP_CodeSniffer\Config
25
-     */
26
-    public $config = null;
27
-
28
-    /**
29
-     * Total number of files that contain errors or warnings.
30
-     *
31
-     * @var integer
32
-     */
33
-    public $totalFiles = 0;
34
-
35
-    /**
36
-     * Total number of errors found during the run.
37
-     *
38
-     * @var integer
39
-     */
40
-    public $totalErrors = 0;
41
-
42
-    /**
43
-     * Total number of warnings found during the run.
44
-     *
45
-     * @var integer
46
-     */
47
-    public $totalWarnings = 0;
48
-
49
-    /**
50
-     * Total number of errors/warnings that can be fixed.
51
-     *
52
-     * @var integer
53
-     */
54
-    public $totalFixable = 0;
55
-
56
-    /**
57
-     * Total number of errors/warnings that were fixed.
58
-     *
59
-     * @var integer
60
-     */
61
-    public $totalFixed = 0;
62
-
63
-    /**
64
-     * When the PHPCS run started.
65
-     *
66
-     * @var float
67
-     */
68
-    public static $startTime = 0;
69
-
70
-    /**
71
-     * A cache of report objects.
72
-     *
73
-     * @var array
74
-     */
75
-    private $reports = [];
76
-
77
-    /**
78
-     * A cache of opened temporary files.
79
-     *
80
-     * @var array
81
-     */
82
-    private $tmpFiles = [];
83
-
84
-
85
-    /**
86
-     * Initialise the reporter.
87
-     *
88
-     * All reports specified in the config will be created and their
89
-     * output file (or a temp file if none is specified) initialised by
90
-     * clearing the current contents.
91
-     *
92
-     * @param \PHP_CodeSniffer\Config $config The config data for the run.
93
-     *
94
-     * @return void
95
-     * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If a report is not available.
96
-     */
97
-    public function __construct(Config $config)
98
-    {
99
-        $this->config = $config;
100
-
101
-        foreach ($config->reports as $type => $output) {
102
-            if ($output === null) {
103
-                $output = $config->reportFile;
104
-            }
105
-
106
-            $reportClassName = '';
107
-            if (strpos($type, '.') !== false) {
108
-                // This is a path to a custom report class.
109
-                $filename = realpath($type);
110
-                if ($filename === false) {
111
-                    $error = "ERROR: Custom report \"$type\" not found".PHP_EOL;
112
-                    throw new DeepExitException($error, 3);
113
-                }
114
-
115
-                $reportClassName = Autoload::loadFile($filename);
116
-            } else if (class_exists('PHP_CodeSniffer\Reports\\'.ucfirst($type)) === true) {
117
-                // PHPCS native report.
118
-                $reportClassName = 'PHP_CodeSniffer\Reports\\'.ucfirst($type);
119
-            } else if (class_exists($type) === true) {
120
-                // FQN of a custom report.
121
-                $reportClassName = $type;
122
-            } else {
123
-                // OK, so not a FQN, try and find the report using the registered namespaces.
124
-                $registeredNamespaces = Autoload::getSearchPaths();
125
-                $trimmedType          = ltrim($type, '\\');
126
-
127
-                foreach ($registeredNamespaces as $nsPrefix) {
128
-                    if ($nsPrefix === '') {
129
-                        continue;
130
-                    }
131
-
132
-                    if (class_exists($nsPrefix.'\\'.$trimmedType) === true) {
133
-                        $reportClassName = $nsPrefix.'\\'.$trimmedType;
134
-                        break;
135
-                    }
136
-                }
137
-            }//end if
138
-
139
-            if ($reportClassName === '') {
140
-                $error = "ERROR: Class file for report \"$type\" not found".PHP_EOL;
141
-                throw new DeepExitException($error, 3);
142
-            }
143
-
144
-            $reportClass = new $reportClassName();
145
-            if (false === ($reportClass instanceof Report)) {
146
-                throw new RuntimeException('Class "'.$reportClassName.'" must implement the "PHP_CodeSniffer\Report" interface.');
147
-            }
148
-
149
-            $this->reports[$type] = [
150
-                'output' => $output,
151
-                'class'  => $reportClass,
152
-            ];
153
-
154
-            if ($output === null) {
155
-                // Using a temp file.
156
-                // This needs to be set in the constructor so that all
157
-                // child procs use the same report file when running in parallel.
158
-                $this->tmpFiles[$type] = tempnam(sys_get_temp_dir(), 'phpcs');
159
-                file_put_contents($this->tmpFiles[$type], '');
160
-            } else {
161
-                file_put_contents($output, '');
162
-            }
163
-        }//end foreach
164
-
165
-    }//end __construct()
166
-
167
-
168
-    /**
169
-     * Generates and prints final versions of all reports.
170
-     *
171
-     * Returns TRUE if any of the reports output content to the screen
172
-     * or FALSE if all reports were silently printed to a file.
173
-     *
174
-     * @return bool
175
-     */
176
-    public function printReports()
177
-    {
178
-        $toScreen = false;
179
-        foreach ($this->reports as $type => $report) {
180
-            if ($report['output'] === null) {
181
-                $toScreen = true;
182
-            }
183
-
184
-            $this->printReport($type);
185
-        }
186
-
187
-        return $toScreen;
188
-
189
-    }//end printReports()
190
-
191
-
192
-    /**
193
-     * Generates and prints a single final report.
194
-     *
195
-     * @param string $report The report type to print.
196
-     *
197
-     * @return void
198
-     */
199
-    public function printReport($report)
200
-    {
201
-        $reportClass = $this->reports[$report]['class'];
202
-        $reportFile  = $this->reports[$report]['output'];
203
-
204
-        if ($reportFile !== null) {
205
-            $filename = $reportFile;
206
-            $toScreen = false;
207
-        } else {
208
-            if (isset($this->tmpFiles[$report]) === true) {
209
-                $filename = $this->tmpFiles[$report];
210
-            } else {
211
-                $filename = null;
212
-            }
213
-
214
-            $toScreen = true;
215
-        }
216
-
217
-        $reportCache = '';
218
-        if ($filename !== null) {
219
-            $reportCache = file_get_contents($filename);
220
-        }
221
-
222
-        ob_start();
223
-        $reportClass->generate(
224
-            $reportCache,
225
-            $this->totalFiles,
226
-            $this->totalErrors,
227
-            $this->totalWarnings,
228
-            $this->totalFixable,
229
-            $this->config->showSources,
230
-            $this->config->reportWidth,
231
-            $this->config->interactive,
232
-            $toScreen
233
-        );
234
-        $generatedReport = ob_get_contents();
235
-        ob_end_clean();
236
-
237
-        if ($this->config->colors !== true || $reportFile !== null) {
238
-            $generatedReport = preg_replace('`\033\[[0-9;]+m`', '', $generatedReport);
239
-        }
240
-
241
-        if ($reportFile !== null) {
242
-            if (PHP_CODESNIFFER_VERBOSITY > 0) {
243
-                echo $generatedReport;
244
-            }
245
-
246
-            file_put_contents($reportFile, $generatedReport.PHP_EOL);
247
-        } else {
248
-            echo $generatedReport;
249
-            if ($filename !== null && file_exists($filename) === true) {
250
-                unlink($filename);
251
-                unset($this->tmpFiles[$report]);
252
-            }
253
-        }
254
-
255
-    }//end printReport()
256
-
257
-
258
-    /**
259
-     * Caches the result of a single processed file for all reports.
260
-     *
261
-     * The report content that is generated is appended to the output file
262
-     * assigned to each report. This content may be an intermediate report format
263
-     * and not reflect the final report output.
264
-     *
265
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file that has been processed.
266
-     *
267
-     * @return void
268
-     */
269
-    public function cacheFileReport(File $phpcsFile)
270
-    {
271
-        if (isset($this->config->reports) === false) {
272
-            // This happens during unit testing, or any time someone just wants
273
-            // the error data and not the printed report.
274
-            return;
275
-        }
276
-
277
-        $reportData  = $this->prepareFileReport($phpcsFile);
278
-        $errorsShown = false;
279
-
280
-        foreach ($this->reports as $type => $report) {
281
-            $reportClass = $report['class'];
282
-
283
-            ob_start();
284
-            $result = $reportClass->generateFileReport($reportData, $phpcsFile, $this->config->showSources, $this->config->reportWidth);
285
-            if ($result === true) {
286
-                $errorsShown = true;
287
-            }
288
-
289
-            $generatedReport = ob_get_contents();
290
-            ob_end_clean();
291
-
292
-            if ($report['output'] === null) {
293
-                // Using a temp file.
294
-                if (isset($this->tmpFiles[$type]) === false) {
295
-                    // When running in interactive mode, the reporter prints the full
296
-                    // report many times, which will unlink the temp file. So we need
297
-                    // to create a new one if it doesn't exist.
298
-                    $this->tmpFiles[$type] = tempnam(sys_get_temp_dir(), 'phpcs');
299
-                    file_put_contents($this->tmpFiles[$type], '');
300
-                }
301
-
302
-                file_put_contents($this->tmpFiles[$type], $generatedReport, (FILE_APPEND | LOCK_EX));
303
-            } else {
304
-                file_put_contents($report['output'], $generatedReport, (FILE_APPEND | LOCK_EX));
305
-            }//end if
306
-        }//end foreach
307
-
308
-        if ($errorsShown === true || PHP_CODESNIFFER_CBF === true) {
309
-            $this->totalFiles++;
310
-            $this->totalErrors   += $reportData['errors'];
311
-            $this->totalWarnings += $reportData['warnings'];
312
-
313
-            // When PHPCBF is running, we need to use the fixable error values
314
-            // after the report has run and fixed what it can.
315
-            if (PHP_CODESNIFFER_CBF === true) {
316
-                $this->totalFixable += $phpcsFile->getFixableCount();
317
-                $this->totalFixed   += $phpcsFile->getFixedCount();
318
-            } else {
319
-                $this->totalFixable += $reportData['fixable'];
320
-            }
321
-        }
322
-
323
-    }//end cacheFileReport()
324
-
325
-
326
-    /**
327
-     * Generate summary information to be used during report generation.
328
-     *
329
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file that has been processed.
330
-     *
331
-     * @return array
332
-     */
333
-    public function prepareFileReport(File $phpcsFile)
334
-    {
335
-        $report = [
336
-            'filename' => Common::stripBasepath($phpcsFile->getFilename(), $this->config->basepath),
337
-            'errors'   => $phpcsFile->getErrorCount(),
338
-            'warnings' => $phpcsFile->getWarningCount(),
339
-            'fixable'  => $phpcsFile->getFixableCount(),
340
-            'messages' => [],
341
-        ];
342
-
343
-        if ($report['errors'] === 0 && $report['warnings'] === 0) {
344
-            // Prefect score!
345
-            return $report;
346
-        }
347
-
348
-        if ($this->config->recordErrors === false) {
349
-            $message  = 'Errors are not being recorded but this report requires error messages. ';
350
-            $message .= 'This report will not show the correct information.';
351
-            $report['messages'][1][1] = [
352
-                [
353
-                    'message'  => $message,
354
-                    'source'   => 'Internal.RecordErrors',
355
-                    'severity' => 5,
356
-                    'fixable'  => false,
357
-                    'type'     => 'ERROR',
358
-                ],
359
-            ];
360
-            return $report;
361
-        }
362
-
363
-        $errors = [];
364
-
365
-        // Merge errors and warnings.
366
-        foreach ($phpcsFile->getErrors() as $line => $lineErrors) {
367
-            foreach ($lineErrors as $column => $colErrors) {
368
-                $newErrors = [];
369
-                foreach ($colErrors as $data) {
370
-                    $newErrors[] = [
371
-                        'message'  => $data['message'],
372
-                        'source'   => $data['source'],
373
-                        'severity' => $data['severity'],
374
-                        'fixable'  => $data['fixable'],
375
-                        'type'     => 'ERROR',
376
-                    ];
377
-                }
378
-
379
-                $errors[$line][$column] = $newErrors;
380
-            }
381
-
382
-            ksort($errors[$line]);
383
-        }//end foreach
384
-
385
-        foreach ($phpcsFile->getWarnings() as $line => $lineWarnings) {
386
-            foreach ($lineWarnings as $column => $colWarnings) {
387
-                $newWarnings = [];
388
-                foreach ($colWarnings as $data) {
389
-                    $newWarnings[] = [
390
-                        'message'  => $data['message'],
391
-                        'source'   => $data['source'],
392
-                        'severity' => $data['severity'],
393
-                        'fixable'  => $data['fixable'],
394
-                        'type'     => 'WARNING',
395
-                    ];
396
-                }
397
-
398
-                if (isset($errors[$line]) === false) {
399
-                    $errors[$line] = [];
400
-                }
401
-
402
-                if (isset($errors[$line][$column]) === true) {
403
-                    $errors[$line][$column] = array_merge(
404
-                        $newWarnings,
405
-                        $errors[$line][$column]
406
-                    );
407
-                } else {
408
-                    $errors[$line][$column] = $newWarnings;
409
-                }
410
-            }//end foreach
411
-
412
-            ksort($errors[$line]);
413
-        }//end foreach
414
-
415
-        ksort($errors);
416
-        $report['messages'] = $errors;
417
-        return $report;
418
-
419
-    }//end prepareFileReport()
21
+	/**
22
+	 * The config data for the run.
23
+	 *
24
+	 * @var \PHP_CodeSniffer\Config
25
+	 */
26
+	public $config = null;
27
+
28
+	/**
29
+	 * Total number of files that contain errors or warnings.
30
+	 *
31
+	 * @var integer
32
+	 */
33
+	public $totalFiles = 0;
34
+
35
+	/**
36
+	 * Total number of errors found during the run.
37
+	 *
38
+	 * @var integer
39
+	 */
40
+	public $totalErrors = 0;
41
+
42
+	/**
43
+	 * Total number of warnings found during the run.
44
+	 *
45
+	 * @var integer
46
+	 */
47
+	public $totalWarnings = 0;
48
+
49
+	/**
50
+	 * Total number of errors/warnings that can be fixed.
51
+	 *
52
+	 * @var integer
53
+	 */
54
+	public $totalFixable = 0;
55
+
56
+	/**
57
+	 * Total number of errors/warnings that were fixed.
58
+	 *
59
+	 * @var integer
60
+	 */
61
+	public $totalFixed = 0;
62
+
63
+	/**
64
+	 * When the PHPCS run started.
65
+	 *
66
+	 * @var float
67
+	 */
68
+	public static $startTime = 0;
69
+
70
+	/**
71
+	 * A cache of report objects.
72
+	 *
73
+	 * @var array
74
+	 */
75
+	private $reports = [];
76
+
77
+	/**
78
+	 * A cache of opened temporary files.
79
+	 *
80
+	 * @var array
81
+	 */
82
+	private $tmpFiles = [];
83
+
84
+
85
+	/**
86
+	 * Initialise the reporter.
87
+	 *
88
+	 * All reports specified in the config will be created and their
89
+	 * output file (or a temp file if none is specified) initialised by
90
+	 * clearing the current contents.
91
+	 *
92
+	 * @param \PHP_CodeSniffer\Config $config The config data for the run.
93
+	 *
94
+	 * @return void
95
+	 * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If a report is not available.
96
+	 */
97
+	public function __construct(Config $config)
98
+	{
99
+		$this->config = $config;
100
+
101
+		foreach ($config->reports as $type => $output) {
102
+			if ($output === null) {
103
+				$output = $config->reportFile;
104
+			}
105
+
106
+			$reportClassName = '';
107
+			if (strpos($type, '.') !== false) {
108
+				// This is a path to a custom report class.
109
+				$filename = realpath($type);
110
+				if ($filename === false) {
111
+					$error = "ERROR: Custom report \"$type\" not found".PHP_EOL;
112
+					throw new DeepExitException($error, 3);
113
+				}
114
+
115
+				$reportClassName = Autoload::loadFile($filename);
116
+			} else if (class_exists('PHP_CodeSniffer\Reports\\'.ucfirst($type)) === true) {
117
+				// PHPCS native report.
118
+				$reportClassName = 'PHP_CodeSniffer\Reports\\'.ucfirst($type);
119
+			} else if (class_exists($type) === true) {
120
+				// FQN of a custom report.
121
+				$reportClassName = $type;
122
+			} else {
123
+				// OK, so not a FQN, try and find the report using the registered namespaces.
124
+				$registeredNamespaces = Autoload::getSearchPaths();
125
+				$trimmedType          = ltrim($type, '\\');
126
+
127
+				foreach ($registeredNamespaces as $nsPrefix) {
128
+					if ($nsPrefix === '') {
129
+						continue;
130
+					}
131
+
132
+					if (class_exists($nsPrefix.'\\'.$trimmedType) === true) {
133
+						$reportClassName = $nsPrefix.'\\'.$trimmedType;
134
+						break;
135
+					}
136
+				}
137
+			}//end if
138
+
139
+			if ($reportClassName === '') {
140
+				$error = "ERROR: Class file for report \"$type\" not found".PHP_EOL;
141
+				throw new DeepExitException($error, 3);
142
+			}
143
+
144
+			$reportClass = new $reportClassName();
145
+			if (false === ($reportClass instanceof Report)) {
146
+				throw new RuntimeException('Class "'.$reportClassName.'" must implement the "PHP_CodeSniffer\Report" interface.');
147
+			}
148
+
149
+			$this->reports[$type] = [
150
+				'output' => $output,
151
+				'class'  => $reportClass,
152
+			];
153
+
154
+			if ($output === null) {
155
+				// Using a temp file.
156
+				// This needs to be set in the constructor so that all
157
+				// child procs use the same report file when running in parallel.
158
+				$this->tmpFiles[$type] = tempnam(sys_get_temp_dir(), 'phpcs');
159
+				file_put_contents($this->tmpFiles[$type], '');
160
+			} else {
161
+				file_put_contents($output, '');
162
+			}
163
+		}//end foreach
164
+
165
+	}//end __construct()
166
+
167
+
168
+	/**
169
+	 * Generates and prints final versions of all reports.
170
+	 *
171
+	 * Returns TRUE if any of the reports output content to the screen
172
+	 * or FALSE if all reports were silently printed to a file.
173
+	 *
174
+	 * @return bool
175
+	 */
176
+	public function printReports()
177
+	{
178
+		$toScreen = false;
179
+		foreach ($this->reports as $type => $report) {
180
+			if ($report['output'] === null) {
181
+				$toScreen = true;
182
+			}
183
+
184
+			$this->printReport($type);
185
+		}
186
+
187
+		return $toScreen;
188
+
189
+	}//end printReports()
190
+
191
+
192
+	/**
193
+	 * Generates and prints a single final report.
194
+	 *
195
+	 * @param string $report The report type to print.
196
+	 *
197
+	 * @return void
198
+	 */
199
+	public function printReport($report)
200
+	{
201
+		$reportClass = $this->reports[$report]['class'];
202
+		$reportFile  = $this->reports[$report]['output'];
203
+
204
+		if ($reportFile !== null) {
205
+			$filename = $reportFile;
206
+			$toScreen = false;
207
+		} else {
208
+			if (isset($this->tmpFiles[$report]) === true) {
209
+				$filename = $this->tmpFiles[$report];
210
+			} else {
211
+				$filename = null;
212
+			}
213
+
214
+			$toScreen = true;
215
+		}
216
+
217
+		$reportCache = '';
218
+		if ($filename !== null) {
219
+			$reportCache = file_get_contents($filename);
220
+		}
221
+
222
+		ob_start();
223
+		$reportClass->generate(
224
+			$reportCache,
225
+			$this->totalFiles,
226
+			$this->totalErrors,
227
+			$this->totalWarnings,
228
+			$this->totalFixable,
229
+			$this->config->showSources,
230
+			$this->config->reportWidth,
231
+			$this->config->interactive,
232
+			$toScreen
233
+		);
234
+		$generatedReport = ob_get_contents();
235
+		ob_end_clean();
236
+
237
+		if ($this->config->colors !== true || $reportFile !== null) {
238
+			$generatedReport = preg_replace('`\033\[[0-9;]+m`', '', $generatedReport);
239
+		}
240
+
241
+		if ($reportFile !== null) {
242
+			if (PHP_CODESNIFFER_VERBOSITY > 0) {
243
+				echo $generatedReport;
244
+			}
245
+
246
+			file_put_contents($reportFile, $generatedReport.PHP_EOL);
247
+		} else {
248
+			echo $generatedReport;
249
+			if ($filename !== null && file_exists($filename) === true) {
250
+				unlink($filename);
251
+				unset($this->tmpFiles[$report]);
252
+			}
253
+		}
254
+
255
+	}//end printReport()
256
+
257
+
258
+	/**
259
+	 * Caches the result of a single processed file for all reports.
260
+	 *
261
+	 * The report content that is generated is appended to the output file
262
+	 * assigned to each report. This content may be an intermediate report format
263
+	 * and not reflect the final report output.
264
+	 *
265
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file that has been processed.
266
+	 *
267
+	 * @return void
268
+	 */
269
+	public function cacheFileReport(File $phpcsFile)
270
+	{
271
+		if (isset($this->config->reports) === false) {
272
+			// This happens during unit testing, or any time someone just wants
273
+			// the error data and not the printed report.
274
+			return;
275
+		}
276
+
277
+		$reportData  = $this->prepareFileReport($phpcsFile);
278
+		$errorsShown = false;
279
+
280
+		foreach ($this->reports as $type => $report) {
281
+			$reportClass = $report['class'];
282
+
283
+			ob_start();
284
+			$result = $reportClass->generateFileReport($reportData, $phpcsFile, $this->config->showSources, $this->config->reportWidth);
285
+			if ($result === true) {
286
+				$errorsShown = true;
287
+			}
288
+
289
+			$generatedReport = ob_get_contents();
290
+			ob_end_clean();
291
+
292
+			if ($report['output'] === null) {
293
+				// Using a temp file.
294
+				if (isset($this->tmpFiles[$type]) === false) {
295
+					// When running in interactive mode, the reporter prints the full
296
+					// report many times, which will unlink the temp file. So we need
297
+					// to create a new one if it doesn't exist.
298
+					$this->tmpFiles[$type] = tempnam(sys_get_temp_dir(), 'phpcs');
299
+					file_put_contents($this->tmpFiles[$type], '');
300
+				}
301
+
302
+				file_put_contents($this->tmpFiles[$type], $generatedReport, (FILE_APPEND | LOCK_EX));
303
+			} else {
304
+				file_put_contents($report['output'], $generatedReport, (FILE_APPEND | LOCK_EX));
305
+			}//end if
306
+		}//end foreach
307
+
308
+		if ($errorsShown === true || PHP_CODESNIFFER_CBF === true) {
309
+			$this->totalFiles++;
310
+			$this->totalErrors   += $reportData['errors'];
311
+			$this->totalWarnings += $reportData['warnings'];
312
+
313
+			// When PHPCBF is running, we need to use the fixable error values
314
+			// after the report has run and fixed what it can.
315
+			if (PHP_CODESNIFFER_CBF === true) {
316
+				$this->totalFixable += $phpcsFile->getFixableCount();
317
+				$this->totalFixed   += $phpcsFile->getFixedCount();
318
+			} else {
319
+				$this->totalFixable += $reportData['fixable'];
320
+			}
321
+		}
322
+
323
+	}//end cacheFileReport()
324
+
325
+
326
+	/**
327
+	 * Generate summary information to be used during report generation.
328
+	 *
329
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file that has been processed.
330
+	 *
331
+	 * @return array
332
+	 */
333
+	public function prepareFileReport(File $phpcsFile)
334
+	{
335
+		$report = [
336
+			'filename' => Common::stripBasepath($phpcsFile->getFilename(), $this->config->basepath),
337
+			'errors'   => $phpcsFile->getErrorCount(),
338
+			'warnings' => $phpcsFile->getWarningCount(),
339
+			'fixable'  => $phpcsFile->getFixableCount(),
340
+			'messages' => [],
341
+		];
342
+
343
+		if ($report['errors'] === 0 && $report['warnings'] === 0) {
344
+			// Prefect score!
345
+			return $report;
346
+		}
347
+
348
+		if ($this->config->recordErrors === false) {
349
+			$message  = 'Errors are not being recorded but this report requires error messages. ';
350
+			$message .= 'This report will not show the correct information.';
351
+			$report['messages'][1][1] = [
352
+				[
353
+					'message'  => $message,
354
+					'source'   => 'Internal.RecordErrors',
355
+					'severity' => 5,
356
+					'fixable'  => false,
357
+					'type'     => 'ERROR',
358
+				],
359
+			];
360
+			return $report;
361
+		}
362
+
363
+		$errors = [];
364
+
365
+		// Merge errors and warnings.
366
+		foreach ($phpcsFile->getErrors() as $line => $lineErrors) {
367
+			foreach ($lineErrors as $column => $colErrors) {
368
+				$newErrors = [];
369
+				foreach ($colErrors as $data) {
370
+					$newErrors[] = [
371
+						'message'  => $data['message'],
372
+						'source'   => $data['source'],
373
+						'severity' => $data['severity'],
374
+						'fixable'  => $data['fixable'],
375
+						'type'     => 'ERROR',
376
+					];
377
+				}
378
+
379
+				$errors[$line][$column] = $newErrors;
380
+			}
381
+
382
+			ksort($errors[$line]);
383
+		}//end foreach
384
+
385
+		foreach ($phpcsFile->getWarnings() as $line => $lineWarnings) {
386
+			foreach ($lineWarnings as $column => $colWarnings) {
387
+				$newWarnings = [];
388
+				foreach ($colWarnings as $data) {
389
+					$newWarnings[] = [
390
+						'message'  => $data['message'],
391
+						'source'   => $data['source'],
392
+						'severity' => $data['severity'],
393
+						'fixable'  => $data['fixable'],
394
+						'type'     => 'WARNING',
395
+					];
396
+				}
397
+
398
+				if (isset($errors[$line]) === false) {
399
+					$errors[$line] = [];
400
+				}
401
+
402
+				if (isset($errors[$line][$column]) === true) {
403
+					$errors[$line][$column] = array_merge(
404
+						$newWarnings,
405
+						$errors[$line][$column]
406
+					);
407
+				} else {
408
+					$errors[$line][$column] = $newWarnings;
409
+				}
410
+			}//end foreach
411
+
412
+			ksort($errors[$line]);
413
+		}//end foreach
414
+
415
+		ksort($errors);
416
+		$report['messages'] = $errors;
417
+		return $report;
418
+
419
+	}//end prepareFileReport()
420 420
 
421 421
 
422 422
 }//end class
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @var array
74 74
      */
75
-    private $reports = [];
75
+    private $reports = [ ];
76 76
 
77 77
     /**
78 78
      * A cache of opened temporary files.
79 79
      *
80 80
      * @var array
81 81
      */
82
-    private $tmpFiles = [];
82
+    private $tmpFiles = [ ];
83 83
 
84 84
 
85 85
     /**
@@ -94,71 +94,71 @@  discard block
 block discarded – undo
94 94
      * @return void
95 95
      * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If a report is not available.
96 96
      */
97
-    public function __construct(Config $config)
97
+    public function __construct( Config $config )
98 98
     {
99 99
         $this->config = $config;
100 100
 
101
-        foreach ($config->reports as $type => $output) {
102
-            if ($output === null) {
101
+        foreach ( $config->reports as $type => $output ) {
102
+            if ( $output === null ) {
103 103
                 $output = $config->reportFile;
104 104
             }
105 105
 
106 106
             $reportClassName = '';
107
-            if (strpos($type, '.') !== false) {
107
+            if ( strpos( $type, '.' ) !== false ) {
108 108
                 // This is a path to a custom report class.
109
-                $filename = realpath($type);
110
-                if ($filename === false) {
111
-                    $error = "ERROR: Custom report \"$type\" not found".PHP_EOL;
112
-                    throw new DeepExitException($error, 3);
109
+                $filename = realpath( $type );
110
+                if ( $filename === false ) {
111
+                    $error = "ERROR: Custom report \"$type\" not found" . PHP_EOL;
112
+                    throw new DeepExitException( $error, 3 );
113 113
                 }
114 114
 
115
-                $reportClassName = Autoload::loadFile($filename);
116
-            } else if (class_exists('PHP_CodeSniffer\Reports\\'.ucfirst($type)) === true) {
115
+                $reportClassName = Autoload::loadFile( $filename );
116
+            } else if ( class_exists( 'PHP_CodeSniffer\Reports\\' . ucfirst( $type ) ) === true ) {
117 117
                 // PHPCS native report.
118
-                $reportClassName = 'PHP_CodeSniffer\Reports\\'.ucfirst($type);
119
-            } else if (class_exists($type) === true) {
118
+                $reportClassName = 'PHP_CodeSniffer\Reports\\' . ucfirst( $type );
119
+            } else if ( class_exists( $type ) === true ) {
120 120
                 // FQN of a custom report.
121 121
                 $reportClassName = $type;
122 122
             } else {
123 123
                 // OK, so not a FQN, try and find the report using the registered namespaces.
124 124
                 $registeredNamespaces = Autoload::getSearchPaths();
125
-                $trimmedType          = ltrim($type, '\\');
125
+                $trimmedType          = ltrim( $type, '\\' );
126 126
 
127
-                foreach ($registeredNamespaces as $nsPrefix) {
128
-                    if ($nsPrefix === '') {
127
+                foreach ( $registeredNamespaces as $nsPrefix ) {
128
+                    if ( $nsPrefix === '' ) {
129 129
                         continue;
130 130
                     }
131 131
 
132
-                    if (class_exists($nsPrefix.'\\'.$trimmedType) === true) {
133
-                        $reportClassName = $nsPrefix.'\\'.$trimmedType;
132
+                    if ( class_exists( $nsPrefix . '\\' . $trimmedType ) === true ) {
133
+                        $reportClassName = $nsPrefix . '\\' . $trimmedType;
134 134
                         break;
135 135
                     }
136 136
                 }
137 137
             }//end if
138 138
 
139
-            if ($reportClassName === '') {
140
-                $error = "ERROR: Class file for report \"$type\" not found".PHP_EOL;
141
-                throw new DeepExitException($error, 3);
139
+            if ( $reportClassName === '' ) {
140
+                $error = "ERROR: Class file for report \"$type\" not found" . PHP_EOL;
141
+                throw new DeepExitException( $error, 3 );
142 142
             }
143 143
 
144 144
             $reportClass = new $reportClassName();
145
-            if (false === ($reportClass instanceof Report)) {
146
-                throw new RuntimeException('Class "'.$reportClassName.'" must implement the "PHP_CodeSniffer\Report" interface.');
145
+            if ( false === ( $reportClass instanceof Report ) ) {
146
+                throw new RuntimeException( 'Class "' . $reportClassName . '" must implement the "PHP_CodeSniffer\Report" interface.' );
147 147
             }
148 148
 
149
-            $this->reports[$type] = [
149
+            $this->reports[ $type ] = [
150 150
                 'output' => $output,
151 151
                 'class'  => $reportClass,
152 152
             ];
153 153
 
154
-            if ($output === null) {
154
+            if ( $output === null ) {
155 155
                 // Using a temp file.
156 156
                 // This needs to be set in the constructor so that all
157 157
                 // child procs use the same report file when running in parallel.
158
-                $this->tmpFiles[$type] = tempnam(sys_get_temp_dir(), 'phpcs');
159
-                file_put_contents($this->tmpFiles[$type], '');
158
+                $this->tmpFiles[ $type ] = tempnam( sys_get_temp_dir(), 'phpcs' );
159
+                file_put_contents( $this->tmpFiles[ $type ], '' );
160 160
             } else {
161
-                file_put_contents($output, '');
161
+                file_put_contents( $output, '' );
162 162
             }
163 163
         }//end foreach
164 164
 
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
     public function printReports()
177 177
     {
178 178
         $toScreen = false;
179
-        foreach ($this->reports as $type => $report) {
180
-            if ($report['output'] === null) {
179
+        foreach ( $this->reports as $type => $report ) {
180
+            if ( $report[ 'output' ] === null ) {
181 181
                 $toScreen = true;
182 182
             }
183 183
 
184
-            $this->printReport($type);
184
+            $this->printReport( $type );
185 185
         }
186 186
 
187 187
         return $toScreen;
@@ -196,17 +196,17 @@  discard block
 block discarded – undo
196 196
      *
197 197
      * @return void
198 198
      */
199
-    public function printReport($report)
199
+    public function printReport( $report )
200 200
     {
201
-        $reportClass = $this->reports[$report]['class'];
202
-        $reportFile  = $this->reports[$report]['output'];
201
+        $reportClass = $this->reports[ $report ][ 'class' ];
202
+        $reportFile  = $this->reports[ $report ][ 'output' ];
203 203
 
204
-        if ($reportFile !== null) {
204
+        if ( $reportFile !== null ) {
205 205
             $filename = $reportFile;
206 206
             $toScreen = false;
207 207
         } else {
208
-            if (isset($this->tmpFiles[$report]) === true) {
209
-                $filename = $this->tmpFiles[$report];
208
+            if ( isset( $this->tmpFiles[ $report ] ) === true ) {
209
+                $filename = $this->tmpFiles[ $report ];
210 210
             } else {
211 211
                 $filename = null;
212 212
             }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
         }
216 216
 
217 217
         $reportCache = '';
218
-        if ($filename !== null) {
219
-            $reportCache = file_get_contents($filename);
218
+        if ( $filename !== null ) {
219
+            $reportCache = file_get_contents( $filename );
220 220
         }
221 221
 
222 222
         ob_start();
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
         $generatedReport = ob_get_contents();
235 235
         ob_end_clean();
236 236
 
237
-        if ($this->config->colors !== true || $reportFile !== null) {
238
-            $generatedReport = preg_replace('`\033\[[0-9;]+m`', '', $generatedReport);
237
+        if ( $this->config->colors !== true || $reportFile !== null ) {
238
+            $generatedReport = preg_replace( '`\033\[[0-9;]+m`', '', $generatedReport );
239 239
         }
240 240
 
241
-        if ($reportFile !== null) {
242
-            if (PHP_CODESNIFFER_VERBOSITY > 0) {
241
+        if ( $reportFile !== null ) {
242
+            if ( PHP_CODESNIFFER_VERBOSITY > 0 ) {
243 243
                 echo $generatedReport;
244 244
             }
245 245
 
246
-            file_put_contents($reportFile, $generatedReport.PHP_EOL);
246
+            file_put_contents( $reportFile, $generatedReport . PHP_EOL );
247 247
         } else {
248 248
             echo $generatedReport;
249
-            if ($filename !== null && file_exists($filename) === true) {
250
-                unlink($filename);
251
-                unset($this->tmpFiles[$report]);
249
+            if ( $filename !== null && file_exists( $filename ) === true ) {
250
+                unlink( $filename );
251
+                unset( $this->tmpFiles[ $report ] );
252 252
             }
253 253
         }
254 254
 
@@ -266,57 +266,57 @@  discard block
 block discarded – undo
266 266
      *
267 267
      * @return void
268 268
      */
269
-    public function cacheFileReport(File $phpcsFile)
269
+    public function cacheFileReport( File $phpcsFile )
270 270
     {
271
-        if (isset($this->config->reports) === false) {
271
+        if ( isset( $this->config->reports ) === false ) {
272 272
             // This happens during unit testing, or any time someone just wants
273 273
             // the error data and not the printed report.
274 274
             return;
275 275
         }
276 276
 
277
-        $reportData  = $this->prepareFileReport($phpcsFile);
277
+        $reportData  = $this->prepareFileReport( $phpcsFile );
278 278
         $errorsShown = false;
279 279
 
280
-        foreach ($this->reports as $type => $report) {
281
-            $reportClass = $report['class'];
280
+        foreach ( $this->reports as $type => $report ) {
281
+            $reportClass = $report[ 'class' ];
282 282
 
283 283
             ob_start();
284
-            $result = $reportClass->generateFileReport($reportData, $phpcsFile, $this->config->showSources, $this->config->reportWidth);
285
-            if ($result === true) {
284
+            $result = $reportClass->generateFileReport( $reportData, $phpcsFile, $this->config->showSources, $this->config->reportWidth );
285
+            if ( $result === true ) {
286 286
                 $errorsShown = true;
287 287
             }
288 288
 
289 289
             $generatedReport = ob_get_contents();
290 290
             ob_end_clean();
291 291
 
292
-            if ($report['output'] === null) {
292
+            if ( $report[ 'output' ] === null ) {
293 293
                 // Using a temp file.
294
-                if (isset($this->tmpFiles[$type]) === false) {
294
+                if ( isset( $this->tmpFiles[ $type ] ) === false ) {
295 295
                     // When running in interactive mode, the reporter prints the full
296 296
                     // report many times, which will unlink the temp file. So we need
297 297
                     // to create a new one if it doesn't exist.
298
-                    $this->tmpFiles[$type] = tempnam(sys_get_temp_dir(), 'phpcs');
299
-                    file_put_contents($this->tmpFiles[$type], '');
298
+                    $this->tmpFiles[ $type ] = tempnam( sys_get_temp_dir(), 'phpcs' );
299
+                    file_put_contents( $this->tmpFiles[ $type ], '' );
300 300
                 }
301 301
 
302
-                file_put_contents($this->tmpFiles[$type], $generatedReport, (FILE_APPEND | LOCK_EX));
302
+                file_put_contents( $this->tmpFiles[ $type ], $generatedReport, ( FILE_APPEND | LOCK_EX ) );
303 303
             } else {
304
-                file_put_contents($report['output'], $generatedReport, (FILE_APPEND | LOCK_EX));
304
+                file_put_contents( $report[ 'output' ], $generatedReport, ( FILE_APPEND | LOCK_EX ) );
305 305
             }//end if
306 306
         }//end foreach
307 307
 
308
-        if ($errorsShown === true || PHP_CODESNIFFER_CBF === true) {
308
+        if ( $errorsShown === true || PHP_CODESNIFFER_CBF === true ) {
309 309
             $this->totalFiles++;
310
-            $this->totalErrors   += $reportData['errors'];
311
-            $this->totalWarnings += $reportData['warnings'];
310
+            $this->totalErrors   += $reportData[ 'errors' ];
311
+            $this->totalWarnings += $reportData[ 'warnings' ];
312 312
 
313 313
             // When PHPCBF is running, we need to use the fixable error values
314 314
             // after the report has run and fixed what it can.
315
-            if (PHP_CODESNIFFER_CBF === true) {
315
+            if ( PHP_CODESNIFFER_CBF === true ) {
316 316
                 $this->totalFixable += $phpcsFile->getFixableCount();
317 317
                 $this->totalFixed   += $phpcsFile->getFixedCount();
318 318
             } else {
319
-                $this->totalFixable += $reportData['fixable'];
319
+                $this->totalFixable += $reportData[ 'fixable' ];
320 320
             }
321 321
         }
322 322
 
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
      *
331 331
      * @return array
332 332
      */
333
-    public function prepareFileReport(File $phpcsFile)
333
+    public function prepareFileReport( File $phpcsFile )
334 334
     {
335 335
         $report = [
336
-            'filename' => Common::stripBasepath($phpcsFile->getFilename(), $this->config->basepath),
336
+            'filename' => Common::stripBasepath( $phpcsFile->getFilename(), $this->config->basepath ),
337 337
             'errors'   => $phpcsFile->getErrorCount(),
338 338
             'warnings' => $phpcsFile->getWarningCount(),
339 339
             'fixable'  => $phpcsFile->getFixableCount(),
340
-            'messages' => [],
340
+            'messages' => [ ],
341 341
         ];
342 342
 
343
-        if ($report['errors'] === 0 && $report['warnings'] === 0) {
343
+        if ( $report[ 'errors' ] === 0 && $report[ 'warnings' ] === 0 ) {
344 344
             // Prefect score!
345 345
             return $report;
346 346
         }
347 347
 
348
-        if ($this->config->recordErrors === false) {
348
+        if ( $this->config->recordErrors === false ) {
349 349
             $message  = 'Errors are not being recorded but this report requires error messages. ';
350 350
             $message .= 'This report will not show the correct information.';
351
-            $report['messages'][1][1] = [
351
+            $report[ 'messages' ][ 1 ][ 1 ] = [
352 352
                 [
353 353
                     'message'  => $message,
354 354
                     'source'   => 'Internal.RecordErrors',
@@ -360,60 +360,60 @@  discard block
 block discarded – undo
360 360
             return $report;
361 361
         }
362 362
 
363
-        $errors = [];
363
+        $errors = [ ];
364 364
 
365 365
         // Merge errors and warnings.
366
-        foreach ($phpcsFile->getErrors() as $line => $lineErrors) {
367
-            foreach ($lineErrors as $column => $colErrors) {
368
-                $newErrors = [];
369
-                foreach ($colErrors as $data) {
370
-                    $newErrors[] = [
371
-                        'message'  => $data['message'],
372
-                        'source'   => $data['source'],
373
-                        'severity' => $data['severity'],
374
-                        'fixable'  => $data['fixable'],
366
+        foreach ( $phpcsFile->getErrors() as $line => $lineErrors ) {
367
+            foreach ( $lineErrors as $column => $colErrors ) {
368
+                $newErrors = [ ];
369
+                foreach ( $colErrors as $data ) {
370
+                    $newErrors[ ] = [
371
+                        'message'  => $data[ 'message' ],
372
+                        'source'   => $data[ 'source' ],
373
+                        'severity' => $data[ 'severity' ],
374
+                        'fixable'  => $data[ 'fixable' ],
375 375
                         'type'     => 'ERROR',
376 376
                     ];
377 377
                 }
378 378
 
379
-                $errors[$line][$column] = $newErrors;
379
+                $errors[ $line ][ $column ] = $newErrors;
380 380
             }
381 381
 
382
-            ksort($errors[$line]);
382
+            ksort( $errors[ $line ] );
383 383
         }//end foreach
384 384
 
385
-        foreach ($phpcsFile->getWarnings() as $line => $lineWarnings) {
386
-            foreach ($lineWarnings as $column => $colWarnings) {
387
-                $newWarnings = [];
388
-                foreach ($colWarnings as $data) {
389
-                    $newWarnings[] = [
390
-                        'message'  => $data['message'],
391
-                        'source'   => $data['source'],
392
-                        'severity' => $data['severity'],
393
-                        'fixable'  => $data['fixable'],
385
+        foreach ( $phpcsFile->getWarnings() as $line => $lineWarnings ) {
386
+            foreach ( $lineWarnings as $column => $colWarnings ) {
387
+                $newWarnings = [ ];
388
+                foreach ( $colWarnings as $data ) {
389
+                    $newWarnings[ ] = [
390
+                        'message'  => $data[ 'message' ],
391
+                        'source'   => $data[ 'source' ],
392
+                        'severity' => $data[ 'severity' ],
393
+                        'fixable'  => $data[ 'fixable' ],
394 394
                         'type'     => 'WARNING',
395 395
                     ];
396 396
                 }
397 397
 
398
-                if (isset($errors[$line]) === false) {
399
-                    $errors[$line] = [];
398
+                if ( isset( $errors[ $line ] ) === false ) {
399
+                    $errors[ $line ] = [ ];
400 400
                 }
401 401
 
402
-                if (isset($errors[$line][$column]) === true) {
403
-                    $errors[$line][$column] = array_merge(
402
+                if ( isset( $errors[ $line ][ $column ] ) === true ) {
403
+                    $errors[ $line ][ $column ] = array_merge(
404 404
                         $newWarnings,
405
-                        $errors[$line][$column]
405
+                        $errors[ $line ][ $column ]
406 406
                     );
407 407
                 } else {
408
-                    $errors[$line][$column] = $newWarnings;
408
+                    $errors[ $line ][ $column ] = $newWarnings;
409 409
                 }
410 410
             }//end foreach
411 411
 
412
-            ksort($errors[$line]);
412
+            ksort( $errors[ $line ] );
413 413
         }//end foreach
414 414
 
415
-        ksort($errors);
416
-        $report['messages'] = $errors;
415
+        ksort( $errors );
416
+        $report[ 'messages' ] = $errors;
417 417
         return $report;
418 418
 
419 419
     }//end prepareFileReport()
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,8 +15,7 @@  discard block
 block discarded – undo
15 15
 use PHP_CodeSniffer\Exceptions\DeepExitException;
16 16
 use PHP_CodeSniffer\Util\Common;
17 17
 
18
-class Reporter
19
-{
18
+class Reporter {
20 19
 
21 20
     /**
22 21
      * The config data for the run.
@@ -94,8 +93,7 @@  discard block
 block discarded – undo
94 93
      * @return void
95 94
      * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If a report is not available.
96 95
      */
97
-    public function __construct(Config $config)
98
-    {
96
+    public function __construct(Config $config) {
99 97
         $this->config = $config;
100 98
 
101 99
         foreach ($config->reports as $type => $output) {
@@ -173,8 +171,7 @@  discard block
 block discarded – undo
173 171
      *
174 172
      * @return bool
175 173
      */
176
-    public function printReports()
177
-    {
174
+    public function printReports() {
178 175
         $toScreen = false;
179 176
         foreach ($this->reports as $type => $report) {
180 177
             if ($report['output'] === null) {
@@ -196,8 +193,7 @@  discard block
 block discarded – undo
196 193
      *
197 194
      * @return void
198 195
      */
199
-    public function printReport($report)
200
-    {
196
+    public function printReport($report) {
201 197
         $reportClass = $this->reports[$report]['class'];
202 198
         $reportFile  = $this->reports[$report]['output'];
203 199
 
@@ -266,8 +262,7 @@  discard block
 block discarded – undo
266 262
      *
267 263
      * @return void
268 264
      */
269
-    public function cacheFileReport(File $phpcsFile)
270
-    {
265
+    public function cacheFileReport(File $phpcsFile) {
271 266
         if (isset($this->config->reports) === false) {
272 267
             // This happens during unit testing, or any time someone just wants
273 268
             // the error data and not the printed report.
@@ -330,8 +325,7 @@  discard block
 block discarded – undo
330 325
      *
331 326
      * @return array
332 327
      */
333
-    public function prepareFileReport(File $phpcsFile)
334
-    {
328
+    public function prepareFileReport(File $phpcsFile) {
335 329
         $report = [
336 330
             'filename' => Common::stripBasepath($phpcsFile->getFilename(), $this->config->basepath),
337 331
             'errors'   => $phpcsFile->getErrorCount(),
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php 4 patches
Indentation   +1888 added lines, -1888 removed lines patch added patch discarded remove patch
@@ -15,660 +15,660 @@  discard block
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * A list of tokens that are allowed to open a scope.
20
-     *
21
-     * This array also contains information about what kind of token the scope
22
-     * opener uses to open and close the scope, if the token strictly requires
23
-     * an opener, if the token can share a scope closer, and who it can be shared
24
-     * with. An example of a token that shares a scope closer is a CASE scope.
25
-     *
26
-     * @var array
27
-     */
28
-    public $scopeOpeners = [
29
-        T_IF            => [
30
-            'start'  => [
31
-                T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
32
-                T_COLON              => T_COLON,
33
-            ],
34
-            'end'    => [
35
-                T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
36
-                T_ENDIF               => T_ENDIF,
37
-                T_ELSE                => T_ELSE,
38
-                T_ELSEIF              => T_ELSEIF,
39
-            ],
40
-            'strict' => false,
41
-            'shared' => false,
42
-            'with'   => [
43
-                T_ELSE   => T_ELSE,
44
-                T_ELSEIF => T_ELSEIF,
45
-            ],
46
-        ],
47
-        T_TRY           => [
48
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
49
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
50
-            'strict' => true,
51
-            'shared' => false,
52
-            'with'   => [],
53
-        ],
54
-        T_CATCH         => [
55
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
56
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
57
-            'strict' => true,
58
-            'shared' => false,
59
-            'with'   => [],
60
-        ],
61
-        T_FINALLY       => [
62
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
63
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
64
-            'strict' => true,
65
-            'shared' => false,
66
-            'with'   => [],
67
-        ],
68
-        T_ELSE          => [
69
-            'start'  => [
70
-                T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
71
-                T_COLON              => T_COLON,
72
-            ],
73
-            'end'    => [
74
-                T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
75
-                T_ENDIF               => T_ENDIF,
76
-            ],
77
-            'strict' => false,
78
-            'shared' => false,
79
-            'with'   => [
80
-                T_IF     => T_IF,
81
-                T_ELSEIF => T_ELSEIF,
82
-            ],
83
-        ],
84
-        T_ELSEIF        => [
85
-            'start'  => [
86
-                T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
87
-                T_COLON              => T_COLON,
88
-            ],
89
-            'end'    => [
90
-                T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
91
-                T_ENDIF               => T_ENDIF,
92
-                T_ELSE                => T_ELSE,
93
-                T_ELSEIF              => T_ELSEIF,
94
-            ],
95
-            'strict' => false,
96
-            'shared' => false,
97
-            'with'   => [
98
-                T_IF   => T_IF,
99
-                T_ELSE => T_ELSE,
100
-            ],
101
-        ],
102
-        T_FOR           => [
103
-            'start'  => [
104
-                T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
105
-                T_COLON              => T_COLON,
106
-            ],
107
-            'end'    => [
108
-                T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
109
-                T_ENDFOR              => T_ENDFOR,
110
-            ],
111
-            'strict' => false,
112
-            'shared' => false,
113
-            'with'   => [],
114
-        ],
115
-        T_FOREACH       => [
116
-            'start'  => [
117
-                T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
118
-                T_COLON              => T_COLON,
119
-            ],
120
-            'end'    => [
121
-                T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
122
-                T_ENDFOREACH          => T_ENDFOREACH,
123
-            ],
124
-            'strict' => false,
125
-            'shared' => false,
126
-            'with'   => [],
127
-        ],
128
-        T_INTERFACE     => [
129
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
130
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
131
-            'strict' => true,
132
-            'shared' => false,
133
-            'with'   => [],
134
-        ],
135
-        T_FUNCTION      => [
136
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
137
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
138
-            'strict' => true,
139
-            'shared' => false,
140
-            'with'   => [],
141
-        ],
142
-        T_CLASS         => [
143
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
144
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
145
-            'strict' => true,
146
-            'shared' => false,
147
-            'with'   => [],
148
-        ],
149
-        T_TRAIT         => [
150
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
151
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
152
-            'strict' => true,
153
-            'shared' => false,
154
-            'with'   => [],
155
-        ],
156
-        T_USE           => [
157
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
158
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
159
-            'strict' => false,
160
-            'shared' => false,
161
-            'with'   => [],
162
-        ],
163
-        T_DECLARE       => [
164
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
165
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
166
-            'strict' => false,
167
-            'shared' => false,
168
-            'with'   => [],
169
-        ],
170
-        T_NAMESPACE     => [
171
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
172
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
173
-            'strict' => false,
174
-            'shared' => false,
175
-            'with'   => [],
176
-        ],
177
-        T_WHILE         => [
178
-            'start'  => [
179
-                T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
180
-                T_COLON              => T_COLON,
181
-            ],
182
-            'end'    => [
183
-                T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
184
-                T_ENDWHILE            => T_ENDWHILE,
185
-            ],
186
-            'strict' => false,
187
-            'shared' => false,
188
-            'with'   => [],
189
-        ],
190
-        T_DO            => [
191
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
192
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
193
-            'strict' => true,
194
-            'shared' => false,
195
-            'with'   => [],
196
-        ],
197
-        T_SWITCH        => [
198
-            'start'  => [
199
-                T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
200
-                T_COLON              => T_COLON,
201
-            ],
202
-            'end'    => [
203
-                T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
204
-                T_ENDSWITCH           => T_ENDSWITCH,
205
-            ],
206
-            'strict' => true,
207
-            'shared' => false,
208
-            'with'   => [],
209
-        ],
210
-        T_CASE          => [
211
-            'start'  => [
212
-                T_COLON     => T_COLON,
213
-                T_SEMICOLON => T_SEMICOLON,
214
-            ],
215
-            'end'    => [
216
-                T_BREAK    => T_BREAK,
217
-                T_RETURN   => T_RETURN,
218
-                T_CONTINUE => T_CONTINUE,
219
-                T_THROW    => T_THROW,
220
-                T_EXIT     => T_EXIT,
221
-            ],
222
-            'strict' => true,
223
-            'shared' => true,
224
-            'with'   => [
225
-                T_DEFAULT => T_DEFAULT,
226
-                T_CASE    => T_CASE,
227
-                T_SWITCH  => T_SWITCH,
228
-            ],
229
-        ],
230
-        T_DEFAULT       => [
231
-            'start'  => [
232
-                T_COLON     => T_COLON,
233
-                T_SEMICOLON => T_SEMICOLON,
234
-            ],
235
-            'end'    => [
236
-                T_BREAK    => T_BREAK,
237
-                T_RETURN   => T_RETURN,
238
-                T_CONTINUE => T_CONTINUE,
239
-                T_THROW    => T_THROW,
240
-                T_EXIT     => T_EXIT,
241
-            ],
242
-            'strict' => true,
243
-            'shared' => true,
244
-            'with'   => [
245
-                T_CASE   => T_CASE,
246
-                T_SWITCH => T_SWITCH,
247
-            ],
248
-        ],
249
-        T_START_HEREDOC => [
250
-            'start'  => [T_START_HEREDOC => T_START_HEREDOC],
251
-            'end'    => [T_END_HEREDOC => T_END_HEREDOC],
252
-            'strict' => true,
253
-            'shared' => false,
254
-            'with'   => [],
255
-        ],
256
-        T_START_NOWDOC  => [
257
-            'start'  => [T_START_NOWDOC => T_START_NOWDOC],
258
-            'end'    => [T_END_NOWDOC => T_END_NOWDOC],
259
-            'strict' => true,
260
-            'shared' => false,
261
-            'with'   => [],
262
-        ],
263
-    ];
264
-
265
-    /**
266
-     * A list of tokens that end the scope.
267
-     *
268
-     * This array is just a unique collection of the end tokens
269
-     * from the scopeOpeners array. The data is duplicated here to
270
-     * save time during parsing of the file.
271
-     *
272
-     * @var array
273
-     */
274
-    public $endScopeTokens = [
275
-        T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
276
-        T_ENDIF               => T_ENDIF,
277
-        T_ENDFOR              => T_ENDFOR,
278
-        T_ENDFOREACH          => T_ENDFOREACH,
279
-        T_ENDWHILE            => T_ENDWHILE,
280
-        T_ENDSWITCH           => T_ENDSWITCH,
281
-        T_BREAK               => T_BREAK,
282
-        T_END_HEREDOC         => T_END_HEREDOC,
283
-    ];
284
-
285
-    /**
286
-     * Known lengths of tokens.
287
-     *
288
-     * @var array<int, int>
289
-     */
290
-    public $knownLengths = [
291
-        T_ABSTRACT                 => 8,
292
-        T_AND_EQUAL                => 2,
293
-        T_ARRAY                    => 5,
294
-        T_AS                       => 2,
295
-        T_BOOLEAN_AND              => 2,
296
-        T_BOOLEAN_OR               => 2,
297
-        T_BREAK                    => 5,
298
-        T_CALLABLE                 => 8,
299
-        T_CASE                     => 4,
300
-        T_CATCH                    => 5,
301
-        T_CLASS                    => 5,
302
-        T_CLASS_C                  => 9,
303
-        T_CLONE                    => 5,
304
-        T_CONCAT_EQUAL             => 2,
305
-        T_CONST                    => 5,
306
-        T_CONTINUE                 => 8,
307
-        T_CURLY_OPEN               => 2,
308
-        T_DEC                      => 2,
309
-        T_DECLARE                  => 7,
310
-        T_DEFAULT                  => 7,
311
-        T_DIR                      => 7,
312
-        T_DIV_EQUAL                => 2,
313
-        T_DO                       => 2,
314
-        T_DOLLAR_OPEN_CURLY_BRACES => 2,
315
-        T_DOUBLE_ARROW             => 2,
316
-        T_DOUBLE_COLON             => 2,
317
-        T_ECHO                     => 4,
318
-        T_ELSE                     => 4,
319
-        T_ELSEIF                   => 6,
320
-        T_EMPTY                    => 5,
321
-        T_ENDDECLARE               => 10,
322
-        T_ENDFOR                   => 6,
323
-        T_ENDFOREACH               => 10,
324
-        T_ENDIF                    => 5,
325
-        T_ENDSWITCH                => 9,
326
-        T_ENDWHILE                 => 8,
327
-        T_EVAL                     => 4,
328
-        T_EXTENDS                  => 7,
329
-        T_FILE                     => 8,
330
-        T_FINAL                    => 5,
331
-        T_FINALLY                  => 7,
332
-        T_FOR                      => 3,
333
-        T_FOREACH                  => 7,
334
-        T_FUNCTION                 => 8,
335
-        T_FUNC_C                   => 12,
336
-        T_GLOBAL                   => 6,
337
-        T_GOTO                     => 4,
338
-        T_HALT_COMPILER            => 15,
339
-        T_IF                       => 2,
340
-        T_IMPLEMENTS               => 10,
341
-        T_INC                      => 2,
342
-        T_INCLUDE                  => 7,
343
-        T_INCLUDE_ONCE             => 12,
344
-        T_INSTANCEOF               => 10,
345
-        T_INSTEADOF                => 9,
346
-        T_INTERFACE                => 9,
347
-        T_ISSET                    => 5,
348
-        T_IS_EQUAL                 => 2,
349
-        T_IS_GREATER_OR_EQUAL      => 2,
350
-        T_IS_IDENTICAL             => 3,
351
-        T_IS_NOT_EQUAL             => 2,
352
-        T_IS_NOT_IDENTICAL         => 3,
353
-        T_IS_SMALLER_OR_EQUAL      => 2,
354
-        T_LINE                     => 8,
355
-        T_LIST                     => 4,
356
-        T_LOGICAL_AND              => 3,
357
-        T_LOGICAL_OR               => 2,
358
-        T_LOGICAL_XOR              => 3,
359
-        T_METHOD_C                 => 10,
360
-        T_MINUS_EQUAL              => 2,
361
-        T_POW_EQUAL                => 3,
362
-        T_MOD_EQUAL                => 2,
363
-        T_MUL_EQUAL                => 2,
364
-        T_NAMESPACE                => 9,
365
-        T_NS_C                     => 13,
366
-        T_NS_SEPARATOR             => 1,
367
-        T_NEW                      => 3,
368
-        T_OBJECT_OPERATOR          => 2,
369
-        T_OPEN_TAG_WITH_ECHO       => 3,
370
-        T_OR_EQUAL                 => 2,
371
-        T_PLUS_EQUAL               => 2,
372
-        T_PRINT                    => 5,
373
-        T_PRIVATE                  => 7,
374
-        T_PUBLIC                   => 6,
375
-        T_PROTECTED                => 9,
376
-        T_REQUIRE                  => 7,
377
-        T_REQUIRE_ONCE             => 12,
378
-        T_RETURN                   => 6,
379
-        T_STATIC                   => 6,
380
-        T_SWITCH                   => 6,
381
-        T_THROW                    => 5,
382
-        T_TRAIT                    => 5,
383
-        T_TRAIT_C                  => 9,
384
-        T_TRY                      => 3,
385
-        T_UNSET                    => 5,
386
-        T_USE                      => 3,
387
-        T_VAR                      => 3,
388
-        T_WHILE                    => 5,
389
-        T_XOR_EQUAL                => 2,
390
-        T_YIELD                    => 5,
391
-        T_OPEN_CURLY_BRACKET       => 1,
392
-        T_CLOSE_CURLY_BRACKET      => 1,
393
-        T_OPEN_SQUARE_BRACKET      => 1,
394
-        T_CLOSE_SQUARE_BRACKET     => 1,
395
-        T_OPEN_PARENTHESIS         => 1,
396
-        T_CLOSE_PARENTHESIS        => 1,
397
-        T_COLON                    => 1,
398
-        T_STRING_CONCAT            => 1,
399
-        T_INLINE_THEN              => 1,
400
-        T_INLINE_ELSE              => 1,
401
-        T_NULLABLE                 => 1,
402
-        T_NULL                     => 4,
403
-        T_FALSE                    => 5,
404
-        T_TRUE                     => 4,
405
-        T_SEMICOLON                => 1,
406
-        T_EQUAL                    => 1,
407
-        T_MULTIPLY                 => 1,
408
-        T_DIVIDE                   => 1,
409
-        T_PLUS                     => 1,
410
-        T_MINUS                    => 1,
411
-        T_MODULUS                  => 1,
412
-        T_POW                      => 2,
413
-        T_SPACESHIP                => 3,
414
-        T_COALESCE                 => 2,
415
-        T_COALESCE_EQUAL           => 3,
416
-        T_BITWISE_AND              => 1,
417
-        T_BITWISE_OR               => 1,
418
-        T_BITWISE_XOR              => 1,
419
-        T_SL                       => 2,
420
-        T_SR                       => 2,
421
-        T_SL_EQUAL                 => 3,
422
-        T_SR_EQUAL                 => 3,
423
-        T_GREATER_THAN             => 1,
424
-        T_LESS_THAN                => 1,
425
-        T_BOOLEAN_NOT              => 1,
426
-        T_SELF                     => 4,
427
-        T_PARENT                   => 6,
428
-        T_COMMA                    => 1,
429
-        T_THIS                     => 4,
430
-        T_CLOSURE                  => 8,
431
-        T_BACKTICK                 => 1,
432
-        T_OPEN_SHORT_ARRAY         => 1,
433
-        T_CLOSE_SHORT_ARRAY        => 1,
434
-    ];
435
-
436
-
437
-    /**
438
-     * A cache of different token types, resolved into arrays.
439
-     *
440
-     * @var array
441
-     * @see standardiseToken()
442
-     */
443
-    private static $resolveTokenCache = [];
444
-
445
-
446
-    /**
447
-     * Creates an array of tokens when given some PHP code.
448
-     *
449
-     * Starts by using token_get_all() but does a lot of extra processing
450
-     * to insert information about the context of the token.
451
-     *
452
-     * @param string $string The string to tokenize.
453
-     *
454
-     * @return array
455
-     */
456
-    protected function tokenize($string)
457
-    {
458
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
459
-            echo "\t*** START PHP TOKENIZING ***".PHP_EOL;
460
-            $isWin = false;
461
-            if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
462
-                $isWin = true;
463
-            }
464
-        }
465
-
466
-        $tokens      = @token_get_all($string);
467
-        $finalTokens = [];
468
-
469
-        $newStackPtr       = 0;
470
-        $numTokens         = count($tokens);
471
-        $lastNotEmptyToken = 0;
472
-
473
-        $insideInlineIf = [];
474
-        $insideUseGroup = false;
475
-
476
-        $commentTokenizer = new Comment();
477
-
478
-        for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) {
479
-            // Special case for tokens we have needed to blank out.
480
-            if ($tokens[$stackPtr] === null) {
481
-                continue;
482
-            }
483
-
484
-            $token        = (array) $tokens[$stackPtr];
485
-            $tokenIsArray = isset($token[1]);
486
-
487
-            if (PHP_CODESNIFFER_VERBOSITY > 1) {
488
-                if ($tokenIsArray === true) {
489
-                    $type    = Util\Tokens::tokenName($token[0]);
490
-                    $content = Util\Common::prepareForOutput($token[1]);
491
-                } else {
492
-                    $newToken = self::resolveSimpleToken($token[0]);
493
-                    $type     = $newToken['type'];
494
-                    $content  = Util\Common::prepareForOutput($token[0]);
495
-                }
496
-
497
-                echo "\tProcess token ";
498
-                if ($tokenIsArray === true) {
499
-                    echo "[$stackPtr]";
500
-                } else {
501
-                    echo " $stackPtr ";
502
-                }
503
-
504
-                echo ": $type => $content";
505
-            }//end if
506
-
507
-            if ($newStackPtr > 0
508
-                && isset(Util\Tokens::$emptyTokens[$finalTokens[($newStackPtr - 1)]['code']]) === false
509
-            ) {
510
-                $lastNotEmptyToken = ($newStackPtr - 1);
511
-            }
512
-
513
-            /*
18
+	/**
19
+	 * A list of tokens that are allowed to open a scope.
20
+	 *
21
+	 * This array also contains information about what kind of token the scope
22
+	 * opener uses to open and close the scope, if the token strictly requires
23
+	 * an opener, if the token can share a scope closer, and who it can be shared
24
+	 * with. An example of a token that shares a scope closer is a CASE scope.
25
+	 *
26
+	 * @var array
27
+	 */
28
+	public $scopeOpeners = [
29
+		T_IF            => [
30
+			'start'  => [
31
+				T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
32
+				T_COLON              => T_COLON,
33
+			],
34
+			'end'    => [
35
+				T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
36
+				T_ENDIF               => T_ENDIF,
37
+				T_ELSE                => T_ELSE,
38
+				T_ELSEIF              => T_ELSEIF,
39
+			],
40
+			'strict' => false,
41
+			'shared' => false,
42
+			'with'   => [
43
+				T_ELSE   => T_ELSE,
44
+				T_ELSEIF => T_ELSEIF,
45
+			],
46
+		],
47
+		T_TRY           => [
48
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
49
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
50
+			'strict' => true,
51
+			'shared' => false,
52
+			'with'   => [],
53
+		],
54
+		T_CATCH         => [
55
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
56
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
57
+			'strict' => true,
58
+			'shared' => false,
59
+			'with'   => [],
60
+		],
61
+		T_FINALLY       => [
62
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
63
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
64
+			'strict' => true,
65
+			'shared' => false,
66
+			'with'   => [],
67
+		],
68
+		T_ELSE          => [
69
+			'start'  => [
70
+				T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
71
+				T_COLON              => T_COLON,
72
+			],
73
+			'end'    => [
74
+				T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
75
+				T_ENDIF               => T_ENDIF,
76
+			],
77
+			'strict' => false,
78
+			'shared' => false,
79
+			'with'   => [
80
+				T_IF     => T_IF,
81
+				T_ELSEIF => T_ELSEIF,
82
+			],
83
+		],
84
+		T_ELSEIF        => [
85
+			'start'  => [
86
+				T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
87
+				T_COLON              => T_COLON,
88
+			],
89
+			'end'    => [
90
+				T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
91
+				T_ENDIF               => T_ENDIF,
92
+				T_ELSE                => T_ELSE,
93
+				T_ELSEIF              => T_ELSEIF,
94
+			],
95
+			'strict' => false,
96
+			'shared' => false,
97
+			'with'   => [
98
+				T_IF   => T_IF,
99
+				T_ELSE => T_ELSE,
100
+			],
101
+		],
102
+		T_FOR           => [
103
+			'start'  => [
104
+				T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
105
+				T_COLON              => T_COLON,
106
+			],
107
+			'end'    => [
108
+				T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
109
+				T_ENDFOR              => T_ENDFOR,
110
+			],
111
+			'strict' => false,
112
+			'shared' => false,
113
+			'with'   => [],
114
+		],
115
+		T_FOREACH       => [
116
+			'start'  => [
117
+				T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
118
+				T_COLON              => T_COLON,
119
+			],
120
+			'end'    => [
121
+				T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
122
+				T_ENDFOREACH          => T_ENDFOREACH,
123
+			],
124
+			'strict' => false,
125
+			'shared' => false,
126
+			'with'   => [],
127
+		],
128
+		T_INTERFACE     => [
129
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
130
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
131
+			'strict' => true,
132
+			'shared' => false,
133
+			'with'   => [],
134
+		],
135
+		T_FUNCTION      => [
136
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
137
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
138
+			'strict' => true,
139
+			'shared' => false,
140
+			'with'   => [],
141
+		],
142
+		T_CLASS         => [
143
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
144
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
145
+			'strict' => true,
146
+			'shared' => false,
147
+			'with'   => [],
148
+		],
149
+		T_TRAIT         => [
150
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
151
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
152
+			'strict' => true,
153
+			'shared' => false,
154
+			'with'   => [],
155
+		],
156
+		T_USE           => [
157
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
158
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
159
+			'strict' => false,
160
+			'shared' => false,
161
+			'with'   => [],
162
+		],
163
+		T_DECLARE       => [
164
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
165
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
166
+			'strict' => false,
167
+			'shared' => false,
168
+			'with'   => [],
169
+		],
170
+		T_NAMESPACE     => [
171
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
172
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
173
+			'strict' => false,
174
+			'shared' => false,
175
+			'with'   => [],
176
+		],
177
+		T_WHILE         => [
178
+			'start'  => [
179
+				T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
180
+				T_COLON              => T_COLON,
181
+			],
182
+			'end'    => [
183
+				T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
184
+				T_ENDWHILE            => T_ENDWHILE,
185
+			],
186
+			'strict' => false,
187
+			'shared' => false,
188
+			'with'   => [],
189
+		],
190
+		T_DO            => [
191
+			'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
192
+			'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
193
+			'strict' => true,
194
+			'shared' => false,
195
+			'with'   => [],
196
+		],
197
+		T_SWITCH        => [
198
+			'start'  => [
199
+				T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
200
+				T_COLON              => T_COLON,
201
+			],
202
+			'end'    => [
203
+				T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
204
+				T_ENDSWITCH           => T_ENDSWITCH,
205
+			],
206
+			'strict' => true,
207
+			'shared' => false,
208
+			'with'   => [],
209
+		],
210
+		T_CASE          => [
211
+			'start'  => [
212
+				T_COLON     => T_COLON,
213
+				T_SEMICOLON => T_SEMICOLON,
214
+			],
215
+			'end'    => [
216
+				T_BREAK    => T_BREAK,
217
+				T_RETURN   => T_RETURN,
218
+				T_CONTINUE => T_CONTINUE,
219
+				T_THROW    => T_THROW,
220
+				T_EXIT     => T_EXIT,
221
+			],
222
+			'strict' => true,
223
+			'shared' => true,
224
+			'with'   => [
225
+				T_DEFAULT => T_DEFAULT,
226
+				T_CASE    => T_CASE,
227
+				T_SWITCH  => T_SWITCH,
228
+			],
229
+		],
230
+		T_DEFAULT       => [
231
+			'start'  => [
232
+				T_COLON     => T_COLON,
233
+				T_SEMICOLON => T_SEMICOLON,
234
+			],
235
+			'end'    => [
236
+				T_BREAK    => T_BREAK,
237
+				T_RETURN   => T_RETURN,
238
+				T_CONTINUE => T_CONTINUE,
239
+				T_THROW    => T_THROW,
240
+				T_EXIT     => T_EXIT,
241
+			],
242
+			'strict' => true,
243
+			'shared' => true,
244
+			'with'   => [
245
+				T_CASE   => T_CASE,
246
+				T_SWITCH => T_SWITCH,
247
+			],
248
+		],
249
+		T_START_HEREDOC => [
250
+			'start'  => [T_START_HEREDOC => T_START_HEREDOC],
251
+			'end'    => [T_END_HEREDOC => T_END_HEREDOC],
252
+			'strict' => true,
253
+			'shared' => false,
254
+			'with'   => [],
255
+		],
256
+		T_START_NOWDOC  => [
257
+			'start'  => [T_START_NOWDOC => T_START_NOWDOC],
258
+			'end'    => [T_END_NOWDOC => T_END_NOWDOC],
259
+			'strict' => true,
260
+			'shared' => false,
261
+			'with'   => [],
262
+		],
263
+	];
264
+
265
+	/**
266
+	 * A list of tokens that end the scope.
267
+	 *
268
+	 * This array is just a unique collection of the end tokens
269
+	 * from the scopeOpeners array. The data is duplicated here to
270
+	 * save time during parsing of the file.
271
+	 *
272
+	 * @var array
273
+	 */
274
+	public $endScopeTokens = [
275
+		T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
276
+		T_ENDIF               => T_ENDIF,
277
+		T_ENDFOR              => T_ENDFOR,
278
+		T_ENDFOREACH          => T_ENDFOREACH,
279
+		T_ENDWHILE            => T_ENDWHILE,
280
+		T_ENDSWITCH           => T_ENDSWITCH,
281
+		T_BREAK               => T_BREAK,
282
+		T_END_HEREDOC         => T_END_HEREDOC,
283
+	];
284
+
285
+	/**
286
+	 * Known lengths of tokens.
287
+	 *
288
+	 * @var array<int, int>
289
+	 */
290
+	public $knownLengths = [
291
+		T_ABSTRACT                 => 8,
292
+		T_AND_EQUAL                => 2,
293
+		T_ARRAY                    => 5,
294
+		T_AS                       => 2,
295
+		T_BOOLEAN_AND              => 2,
296
+		T_BOOLEAN_OR               => 2,
297
+		T_BREAK                    => 5,
298
+		T_CALLABLE                 => 8,
299
+		T_CASE                     => 4,
300
+		T_CATCH                    => 5,
301
+		T_CLASS                    => 5,
302
+		T_CLASS_C                  => 9,
303
+		T_CLONE                    => 5,
304
+		T_CONCAT_EQUAL             => 2,
305
+		T_CONST                    => 5,
306
+		T_CONTINUE                 => 8,
307
+		T_CURLY_OPEN               => 2,
308
+		T_DEC                      => 2,
309
+		T_DECLARE                  => 7,
310
+		T_DEFAULT                  => 7,
311
+		T_DIR                      => 7,
312
+		T_DIV_EQUAL                => 2,
313
+		T_DO                       => 2,
314
+		T_DOLLAR_OPEN_CURLY_BRACES => 2,
315
+		T_DOUBLE_ARROW             => 2,
316
+		T_DOUBLE_COLON             => 2,
317
+		T_ECHO                     => 4,
318
+		T_ELSE                     => 4,
319
+		T_ELSEIF                   => 6,
320
+		T_EMPTY                    => 5,
321
+		T_ENDDECLARE               => 10,
322
+		T_ENDFOR                   => 6,
323
+		T_ENDFOREACH               => 10,
324
+		T_ENDIF                    => 5,
325
+		T_ENDSWITCH                => 9,
326
+		T_ENDWHILE                 => 8,
327
+		T_EVAL                     => 4,
328
+		T_EXTENDS                  => 7,
329
+		T_FILE                     => 8,
330
+		T_FINAL                    => 5,
331
+		T_FINALLY                  => 7,
332
+		T_FOR                      => 3,
333
+		T_FOREACH                  => 7,
334
+		T_FUNCTION                 => 8,
335
+		T_FUNC_C                   => 12,
336
+		T_GLOBAL                   => 6,
337
+		T_GOTO                     => 4,
338
+		T_HALT_COMPILER            => 15,
339
+		T_IF                       => 2,
340
+		T_IMPLEMENTS               => 10,
341
+		T_INC                      => 2,
342
+		T_INCLUDE                  => 7,
343
+		T_INCLUDE_ONCE             => 12,
344
+		T_INSTANCEOF               => 10,
345
+		T_INSTEADOF                => 9,
346
+		T_INTERFACE                => 9,
347
+		T_ISSET                    => 5,
348
+		T_IS_EQUAL                 => 2,
349
+		T_IS_GREATER_OR_EQUAL      => 2,
350
+		T_IS_IDENTICAL             => 3,
351
+		T_IS_NOT_EQUAL             => 2,
352
+		T_IS_NOT_IDENTICAL         => 3,
353
+		T_IS_SMALLER_OR_EQUAL      => 2,
354
+		T_LINE                     => 8,
355
+		T_LIST                     => 4,
356
+		T_LOGICAL_AND              => 3,
357
+		T_LOGICAL_OR               => 2,
358
+		T_LOGICAL_XOR              => 3,
359
+		T_METHOD_C                 => 10,
360
+		T_MINUS_EQUAL              => 2,
361
+		T_POW_EQUAL                => 3,
362
+		T_MOD_EQUAL                => 2,
363
+		T_MUL_EQUAL                => 2,
364
+		T_NAMESPACE                => 9,
365
+		T_NS_C                     => 13,
366
+		T_NS_SEPARATOR             => 1,
367
+		T_NEW                      => 3,
368
+		T_OBJECT_OPERATOR          => 2,
369
+		T_OPEN_TAG_WITH_ECHO       => 3,
370
+		T_OR_EQUAL                 => 2,
371
+		T_PLUS_EQUAL               => 2,
372
+		T_PRINT                    => 5,
373
+		T_PRIVATE                  => 7,
374
+		T_PUBLIC                   => 6,
375
+		T_PROTECTED                => 9,
376
+		T_REQUIRE                  => 7,
377
+		T_REQUIRE_ONCE             => 12,
378
+		T_RETURN                   => 6,
379
+		T_STATIC                   => 6,
380
+		T_SWITCH                   => 6,
381
+		T_THROW                    => 5,
382
+		T_TRAIT                    => 5,
383
+		T_TRAIT_C                  => 9,
384
+		T_TRY                      => 3,
385
+		T_UNSET                    => 5,
386
+		T_USE                      => 3,
387
+		T_VAR                      => 3,
388
+		T_WHILE                    => 5,
389
+		T_XOR_EQUAL                => 2,
390
+		T_YIELD                    => 5,
391
+		T_OPEN_CURLY_BRACKET       => 1,
392
+		T_CLOSE_CURLY_BRACKET      => 1,
393
+		T_OPEN_SQUARE_BRACKET      => 1,
394
+		T_CLOSE_SQUARE_BRACKET     => 1,
395
+		T_OPEN_PARENTHESIS         => 1,
396
+		T_CLOSE_PARENTHESIS        => 1,
397
+		T_COLON                    => 1,
398
+		T_STRING_CONCAT            => 1,
399
+		T_INLINE_THEN              => 1,
400
+		T_INLINE_ELSE              => 1,
401
+		T_NULLABLE                 => 1,
402
+		T_NULL                     => 4,
403
+		T_FALSE                    => 5,
404
+		T_TRUE                     => 4,
405
+		T_SEMICOLON                => 1,
406
+		T_EQUAL                    => 1,
407
+		T_MULTIPLY                 => 1,
408
+		T_DIVIDE                   => 1,
409
+		T_PLUS                     => 1,
410
+		T_MINUS                    => 1,
411
+		T_MODULUS                  => 1,
412
+		T_POW                      => 2,
413
+		T_SPACESHIP                => 3,
414
+		T_COALESCE                 => 2,
415
+		T_COALESCE_EQUAL           => 3,
416
+		T_BITWISE_AND              => 1,
417
+		T_BITWISE_OR               => 1,
418
+		T_BITWISE_XOR              => 1,
419
+		T_SL                       => 2,
420
+		T_SR                       => 2,
421
+		T_SL_EQUAL                 => 3,
422
+		T_SR_EQUAL                 => 3,
423
+		T_GREATER_THAN             => 1,
424
+		T_LESS_THAN                => 1,
425
+		T_BOOLEAN_NOT              => 1,
426
+		T_SELF                     => 4,
427
+		T_PARENT                   => 6,
428
+		T_COMMA                    => 1,
429
+		T_THIS                     => 4,
430
+		T_CLOSURE                  => 8,
431
+		T_BACKTICK                 => 1,
432
+		T_OPEN_SHORT_ARRAY         => 1,
433
+		T_CLOSE_SHORT_ARRAY        => 1,
434
+	];
435
+
436
+
437
+	/**
438
+	 * A cache of different token types, resolved into arrays.
439
+	 *
440
+	 * @var array
441
+	 * @see standardiseToken()
442
+	 */
443
+	private static $resolveTokenCache = [];
444
+
445
+
446
+	/**
447
+	 * Creates an array of tokens when given some PHP code.
448
+	 *
449
+	 * Starts by using token_get_all() but does a lot of extra processing
450
+	 * to insert information about the context of the token.
451
+	 *
452
+	 * @param string $string The string to tokenize.
453
+	 *
454
+	 * @return array
455
+	 */
456
+	protected function tokenize($string)
457
+	{
458
+		if (PHP_CODESNIFFER_VERBOSITY > 1) {
459
+			echo "\t*** START PHP TOKENIZING ***".PHP_EOL;
460
+			$isWin = false;
461
+			if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
462
+				$isWin = true;
463
+			}
464
+		}
465
+
466
+		$tokens      = @token_get_all($string);
467
+		$finalTokens = [];
468
+
469
+		$newStackPtr       = 0;
470
+		$numTokens         = count($tokens);
471
+		$lastNotEmptyToken = 0;
472
+
473
+		$insideInlineIf = [];
474
+		$insideUseGroup = false;
475
+
476
+		$commentTokenizer = new Comment();
477
+
478
+		for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) {
479
+			// Special case for tokens we have needed to blank out.
480
+			if ($tokens[$stackPtr] === null) {
481
+				continue;
482
+			}
483
+
484
+			$token        = (array) $tokens[$stackPtr];
485
+			$tokenIsArray = isset($token[1]);
486
+
487
+			if (PHP_CODESNIFFER_VERBOSITY > 1) {
488
+				if ($tokenIsArray === true) {
489
+					$type    = Util\Tokens::tokenName($token[0]);
490
+					$content = Util\Common::prepareForOutput($token[1]);
491
+				} else {
492
+					$newToken = self::resolveSimpleToken($token[0]);
493
+					$type     = $newToken['type'];
494
+					$content  = Util\Common::prepareForOutput($token[0]);
495
+				}
496
+
497
+				echo "\tProcess token ";
498
+				if ($tokenIsArray === true) {
499
+					echo "[$stackPtr]";
500
+				} else {
501
+					echo " $stackPtr ";
502
+				}
503
+
504
+				echo ": $type => $content";
505
+			}//end if
506
+
507
+			if ($newStackPtr > 0
508
+				&& isset(Util\Tokens::$emptyTokens[$finalTokens[($newStackPtr - 1)]['code']]) === false
509
+			) {
510
+				$lastNotEmptyToken = ($newStackPtr - 1);
511
+			}
512
+
513
+			/*
514 514
                 If we are using \r\n newline characters, the \r and \n are sometimes
515 515
                 split over two tokens. This normally occurs after comments. We need
516 516
                 to merge these two characters together so that our line endings are
517 517
                 consistent for all lines.
518 518
             */
519 519
 
520
-            if ($tokenIsArray === true && substr($token[1], -1) === "\r") {
521
-                if (isset($tokens[($stackPtr + 1)]) === true
522
-                    && is_array($tokens[($stackPtr + 1)]) === true
523
-                    && $tokens[($stackPtr + 1)][1][0] === "\n"
524
-                ) {
525
-                    $token[1] .= "\n";
526
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
527
-                        if ($isWin === true) {
528
-                            echo '\n';
529
-                        } else {
530
-                            echo "\033[30;1m\\n\033[0m";
531
-                        }
532
-                    }
533
-
534
-                    if ($tokens[($stackPtr + 1)][1] === "\n") {
535
-                        // This token's content has been merged into the previous,
536
-                        // so we can skip it.
537
-                        $tokens[($stackPtr + 1)] = '';
538
-                    } else {
539
-                        $tokens[($stackPtr + 1)][1] = substr($tokens[($stackPtr + 1)][1], 1);
540
-                    }
541
-                }
542
-            }//end if
543
-
544
-            if (PHP_CODESNIFFER_VERBOSITY > 1) {
545
-                echo PHP_EOL;
546
-            }
547
-
548
-            /*
520
+			if ($tokenIsArray === true && substr($token[1], -1) === "\r") {
521
+				if (isset($tokens[($stackPtr + 1)]) === true
522
+					&& is_array($tokens[($stackPtr + 1)]) === true
523
+					&& $tokens[($stackPtr + 1)][1][0] === "\n"
524
+				) {
525
+					$token[1] .= "\n";
526
+					if (PHP_CODESNIFFER_VERBOSITY > 1) {
527
+						if ($isWin === true) {
528
+							echo '\n';
529
+						} else {
530
+							echo "\033[30;1m\\n\033[0m";
531
+						}
532
+					}
533
+
534
+					if ($tokens[($stackPtr + 1)][1] === "\n") {
535
+						// This token's content has been merged into the previous,
536
+						// so we can skip it.
537
+						$tokens[($stackPtr + 1)] = '';
538
+					} else {
539
+						$tokens[($stackPtr + 1)][1] = substr($tokens[($stackPtr + 1)][1], 1);
540
+					}
541
+				}
542
+			}//end if
543
+
544
+			if (PHP_CODESNIFFER_VERBOSITY > 1) {
545
+				echo PHP_EOL;
546
+			}
547
+
548
+			/*
549 549
                 Parse doc blocks into something that can be easily iterated over.
550 550
             */
551 551
 
552
-            if ($tokenIsArray === true
553
-                && ($token[0] === T_DOC_COMMENT
554
-                || ($token[0] === T_COMMENT && strpos($token[1], '/**') === 0))
555
-            ) {
556
-                $commentTokens = $commentTokenizer->tokenizeString($token[1], $this->eolChar, $newStackPtr);
557
-                foreach ($commentTokens as $commentToken) {
558
-                    $finalTokens[$newStackPtr] = $commentToken;
559
-                    $newStackPtr++;
560
-                }
552
+			if ($tokenIsArray === true
553
+				&& ($token[0] === T_DOC_COMMENT
554
+				|| ($token[0] === T_COMMENT && strpos($token[1], '/**') === 0))
555
+			) {
556
+				$commentTokens = $commentTokenizer->tokenizeString($token[1], $this->eolChar, $newStackPtr);
557
+				foreach ($commentTokens as $commentToken) {
558
+					$finalTokens[$newStackPtr] = $commentToken;
559
+					$newStackPtr++;
560
+				}
561 561
 
562
-                continue;
563
-            }
562
+				continue;
563
+			}
564 564
 
565
-            /*
565
+			/*
566 566
                 If this is a double quoted string, PHP will tokenize the whole
567 567
                 thing which causes problems with the scope map when braces are
568 568
                 within the string. So we need to merge the tokens together to
569 569
                 provide a single string.
570 570
             */
571 571
 
572
-            if ($tokenIsArray === false && ($token[0] === '"' || $token[0] === 'b"')) {
573
-                // Binary casts need a special token.
574
-                if ($token[0] === 'b"') {
575
-                    $finalTokens[$newStackPtr] = [
576
-                        'code'    => T_BINARY_CAST,
577
-                        'type'    => 'T_BINARY_CAST',
578
-                        'content' => 'b',
579
-                    ];
580
-                    $newStackPtr++;
581
-                }
582
-
583
-                $tokenContent = '"';
584
-                $nestedVars   = [];
585
-                for ($i = ($stackPtr + 1); $i < $numTokens; $i++) {
586
-                    $subToken        = (array) $tokens[$i];
587
-                    $subTokenIsArray = isset($subToken[1]);
588
-
589
-                    if ($subTokenIsArray === true) {
590
-                        $tokenContent .= $subToken[1];
591
-                        if ($subToken[1] === '{'
592
-                            && $subToken[0] !== T_ENCAPSED_AND_WHITESPACE
593
-                        ) {
594
-                            $nestedVars[] = $i;
595
-                        }
596
-                    } else {
597
-                        $tokenContent .= $subToken[0];
598
-                        if ($subToken[0] === '}') {
599
-                            array_pop($nestedVars);
600
-                        }
601
-                    }
602
-
603
-                    if ($subTokenIsArray === false
604
-                        && $subToken[0] === '"'
605
-                        && empty($nestedVars) === true
606
-                    ) {
607
-                        // We found the other end of the double quoted string.
608
-                        break;
609
-                    }
610
-                }//end for
611
-
612
-                $stackPtr = $i;
613
-
614
-                // Convert each line within the double quoted string to a
615
-                // new token, so it conforms with other multiple line tokens.
616
-                $tokenLines = explode($this->eolChar, $tokenContent);
617
-                $numLines   = count($tokenLines);
618
-                $newToken   = [];
619
-
620
-                for ($j = 0; $j < $numLines; $j++) {
621
-                    $newToken['content'] = $tokenLines[$j];
622
-                    if ($j === ($numLines - 1)) {
623
-                        if ($tokenLines[$j] === '') {
624
-                            break;
625
-                        }
626
-                    } else {
627
-                        $newToken['content'] .= $this->eolChar;
628
-                    }
629
-
630
-                    $newToken['code']          = T_DOUBLE_QUOTED_STRING;
631
-                    $newToken['type']          = 'T_DOUBLE_QUOTED_STRING';
632
-                    $finalTokens[$newStackPtr] = $newToken;
633
-                    $newStackPtr++;
634
-                }
635
-
636
-                // Continue, as we're done with this token.
637
-                continue;
638
-            }//end if
639
-
640
-            /*
572
+			if ($tokenIsArray === false && ($token[0] === '"' || $token[0] === 'b"')) {
573
+				// Binary casts need a special token.
574
+				if ($token[0] === 'b"') {
575
+					$finalTokens[$newStackPtr] = [
576
+						'code'    => T_BINARY_CAST,
577
+						'type'    => 'T_BINARY_CAST',
578
+						'content' => 'b',
579
+					];
580
+					$newStackPtr++;
581
+				}
582
+
583
+				$tokenContent = '"';
584
+				$nestedVars   = [];
585
+				for ($i = ($stackPtr + 1); $i < $numTokens; $i++) {
586
+					$subToken        = (array) $tokens[$i];
587
+					$subTokenIsArray = isset($subToken[1]);
588
+
589
+					if ($subTokenIsArray === true) {
590
+						$tokenContent .= $subToken[1];
591
+						if ($subToken[1] === '{'
592
+							&& $subToken[0] !== T_ENCAPSED_AND_WHITESPACE
593
+						) {
594
+							$nestedVars[] = $i;
595
+						}
596
+					} else {
597
+						$tokenContent .= $subToken[0];
598
+						if ($subToken[0] === '}') {
599
+							array_pop($nestedVars);
600
+						}
601
+					}
602
+
603
+					if ($subTokenIsArray === false
604
+						&& $subToken[0] === '"'
605
+						&& empty($nestedVars) === true
606
+					) {
607
+						// We found the other end of the double quoted string.
608
+						break;
609
+					}
610
+				}//end for
611
+
612
+				$stackPtr = $i;
613
+
614
+				// Convert each line within the double quoted string to a
615
+				// new token, so it conforms with other multiple line tokens.
616
+				$tokenLines = explode($this->eolChar, $tokenContent);
617
+				$numLines   = count($tokenLines);
618
+				$newToken   = [];
619
+
620
+				for ($j = 0; $j < $numLines; $j++) {
621
+					$newToken['content'] = $tokenLines[$j];
622
+					if ($j === ($numLines - 1)) {
623
+						if ($tokenLines[$j] === '') {
624
+							break;
625
+						}
626
+					} else {
627
+						$newToken['content'] .= $this->eolChar;
628
+					}
629
+
630
+					$newToken['code']          = T_DOUBLE_QUOTED_STRING;
631
+					$newToken['type']          = 'T_DOUBLE_QUOTED_STRING';
632
+					$finalTokens[$newStackPtr] = $newToken;
633
+					$newStackPtr++;
634
+				}
635
+
636
+				// Continue, as we're done with this token.
637
+				continue;
638
+			}//end if
639
+
640
+			/*
641 641
                 Detect binary casting and assign the casts their own token.
642 642
             */
643 643
 
644
-            if ($tokenIsArray === true
645
-                && $token[0] === T_CONSTANT_ENCAPSED_STRING
646
-                && (substr($token[1], 0, 2) === 'b"'
647
-                || substr($token[1], 0, 2) === "b'")
648
-            ) {
649
-                $finalTokens[$newStackPtr] = [
650
-                    'code'    => T_BINARY_CAST,
651
-                    'type'    => 'T_BINARY_CAST',
652
-                    'content' => 'b',
653
-                ];
654
-                $newStackPtr++;
655
-                $token[1] = substr($token[1], 1);
656
-            }
657
-
658
-            if ($tokenIsArray === true
659
-                && $token[0] === T_STRING_CAST
660
-                && preg_match('`^\(\s*binary\s*\)$`i', $token[1]) === 1
661
-            ) {
662
-                $finalTokens[$newStackPtr] = [
663
-                    'code'    => T_BINARY_CAST,
664
-                    'type'    => 'T_BINARY_CAST',
665
-                    'content' => $token[1],
666
-                ];
667
-                $newStackPtr++;
668
-                continue;
669
-            }
670
-
671
-            /*
644
+			if ($tokenIsArray === true
645
+				&& $token[0] === T_CONSTANT_ENCAPSED_STRING
646
+				&& (substr($token[1], 0, 2) === 'b"'
647
+				|| substr($token[1], 0, 2) === "b'")
648
+			) {
649
+				$finalTokens[$newStackPtr] = [
650
+					'code'    => T_BINARY_CAST,
651
+					'type'    => 'T_BINARY_CAST',
652
+					'content' => 'b',
653
+				];
654
+				$newStackPtr++;
655
+				$token[1] = substr($token[1], 1);
656
+			}
657
+
658
+			if ($tokenIsArray === true
659
+				&& $token[0] === T_STRING_CAST
660
+				&& preg_match('`^\(\s*binary\s*\)$`i', $token[1]) === 1
661
+			) {
662
+				$finalTokens[$newStackPtr] = [
663
+					'code'    => T_BINARY_CAST,
664
+					'type'    => 'T_BINARY_CAST',
665
+					'content' => $token[1],
666
+				];
667
+				$newStackPtr++;
668
+				continue;
669
+			}
670
+
671
+			/*
672 672
                 If this is a heredoc, PHP will tokenize the whole
673 673
                 thing which causes problems when heredocs don't
674 674
                 contain real PHP code, which is almost never.
@@ -676,243 +676,243 @@  discard block
 block discarded – undo
676 676
                 alone though.
677 677
             */
678 678
 
679
-            if ($tokenIsArray === true && $token[0] === T_START_HEREDOC) {
680
-                // Add the start heredoc token to the final array.
681
-                $finalTokens[$newStackPtr] = self::standardiseToken($token);
682
-
683
-                // Check if this is actually a nowdoc and use a different token
684
-                // to help the sniffs.
685
-                $nowdoc = false;
686
-                if (strpos($token[1], "'") !== false) {
687
-                    $finalTokens[$newStackPtr]['code'] = T_START_NOWDOC;
688
-                    $finalTokens[$newStackPtr]['type'] = 'T_START_NOWDOC';
689
-                    $nowdoc = true;
690
-                }
691
-
692
-                $tokenContent = '';
693
-                for ($i = ($stackPtr + 1); $i < $numTokens; $i++) {
694
-                    $subTokenIsArray = is_array($tokens[$i]);
695
-                    if ($subTokenIsArray === true
696
-                        && $tokens[$i][0] === T_END_HEREDOC
697
-                    ) {
698
-                        // We found the other end of the heredoc.
699
-                        break;
700
-                    }
701
-
702
-                    if ($subTokenIsArray === true) {
703
-                        $tokenContent .= $tokens[$i][1];
704
-                    } else {
705
-                        $tokenContent .= $tokens[$i];
706
-                    }
707
-                }
708
-
709
-                if ($i === $numTokens) {
710
-                    // We got to the end of the file and never
711
-                    // found the closing token, so this probably wasn't
712
-                    // a heredoc.
713
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
714
-                        $type = $finalTokens[$newStackPtr]['type'];
715
-                        echo "\t\t* failed to find the end of the here/nowdoc".PHP_EOL;
716
-                        echo "\t\t* token $stackPtr changed from $type to T_STRING".PHP_EOL;
717
-                    }
718
-
719
-                    $finalTokens[$newStackPtr]['code'] = T_STRING;
720
-                    $finalTokens[$newStackPtr]['type'] = 'T_STRING';
721
-                    $newStackPtr++;
722
-                    continue;
723
-                }
724
-
725
-                $stackPtr = $i;
726
-                $newStackPtr++;
727
-
728
-                // Convert each line within the heredoc to a
729
-                // new token, so it conforms with other multiple line tokens.
730
-                $tokenLines = explode($this->eolChar, $tokenContent);
731
-                $numLines   = count($tokenLines);
732
-                $newToken   = [];
733
-
734
-                for ($j = 0; $j < $numLines; $j++) {
735
-                    $newToken['content'] = $tokenLines[$j];
736
-                    if ($j === ($numLines - 1)) {
737
-                        if ($tokenLines[$j] === '') {
738
-                            break;
739
-                        }
740
-                    } else {
741
-                        $newToken['content'] .= $this->eolChar;
742
-                    }
743
-
744
-                    if ($nowdoc === true) {
745
-                        $newToken['code'] = T_NOWDOC;
746
-                        $newToken['type'] = 'T_NOWDOC';
747
-                    } else {
748
-                        $newToken['code'] = T_HEREDOC;
749
-                        $newToken['type'] = 'T_HEREDOC';
750
-                    }
751
-
752
-                    $finalTokens[$newStackPtr] = $newToken;
753
-                    $newStackPtr++;
754
-                }//end for
755
-
756
-                // Add the end heredoc token to the final array.
757
-                $finalTokens[$newStackPtr] = self::standardiseToken($tokens[$stackPtr]);
758
-
759
-                if ($nowdoc === true) {
760
-                    $finalTokens[$newStackPtr]['code'] = T_END_NOWDOC;
761
-                    $finalTokens[$newStackPtr]['type'] = 'T_END_NOWDOC';
762
-                }
763
-
764
-                $newStackPtr++;
765
-
766
-                // Continue, as we're done with this token.
767
-                continue;
768
-            }//end if
769
-
770
-            /*
679
+			if ($tokenIsArray === true && $token[0] === T_START_HEREDOC) {
680
+				// Add the start heredoc token to the final array.
681
+				$finalTokens[$newStackPtr] = self::standardiseToken($token);
682
+
683
+				// Check if this is actually a nowdoc and use a different token
684
+				// to help the sniffs.
685
+				$nowdoc = false;
686
+				if (strpos($token[1], "'") !== false) {
687
+					$finalTokens[$newStackPtr]['code'] = T_START_NOWDOC;
688
+					$finalTokens[$newStackPtr]['type'] = 'T_START_NOWDOC';
689
+					$nowdoc = true;
690
+				}
691
+
692
+				$tokenContent = '';
693
+				for ($i = ($stackPtr + 1); $i < $numTokens; $i++) {
694
+					$subTokenIsArray = is_array($tokens[$i]);
695
+					if ($subTokenIsArray === true
696
+						&& $tokens[$i][0] === T_END_HEREDOC
697
+					) {
698
+						// We found the other end of the heredoc.
699
+						break;
700
+					}
701
+
702
+					if ($subTokenIsArray === true) {
703
+						$tokenContent .= $tokens[$i][1];
704
+					} else {
705
+						$tokenContent .= $tokens[$i];
706
+					}
707
+				}
708
+
709
+				if ($i === $numTokens) {
710
+					// We got to the end of the file and never
711
+					// found the closing token, so this probably wasn't
712
+					// a heredoc.
713
+					if (PHP_CODESNIFFER_VERBOSITY > 1) {
714
+						$type = $finalTokens[$newStackPtr]['type'];
715
+						echo "\t\t* failed to find the end of the here/nowdoc".PHP_EOL;
716
+						echo "\t\t* token $stackPtr changed from $type to T_STRING".PHP_EOL;
717
+					}
718
+
719
+					$finalTokens[$newStackPtr]['code'] = T_STRING;
720
+					$finalTokens[$newStackPtr]['type'] = 'T_STRING';
721
+					$newStackPtr++;
722
+					continue;
723
+				}
724
+
725
+				$stackPtr = $i;
726
+				$newStackPtr++;
727
+
728
+				// Convert each line within the heredoc to a
729
+				// new token, so it conforms with other multiple line tokens.
730
+				$tokenLines = explode($this->eolChar, $tokenContent);
731
+				$numLines   = count($tokenLines);
732
+				$newToken   = [];
733
+
734
+				for ($j = 0; $j < $numLines; $j++) {
735
+					$newToken['content'] = $tokenLines[$j];
736
+					if ($j === ($numLines - 1)) {
737
+						if ($tokenLines[$j] === '') {
738
+							break;
739
+						}
740
+					} else {
741
+						$newToken['content'] .= $this->eolChar;
742
+					}
743
+
744
+					if ($nowdoc === true) {
745
+						$newToken['code'] = T_NOWDOC;
746
+						$newToken['type'] = 'T_NOWDOC';
747
+					} else {
748
+						$newToken['code'] = T_HEREDOC;
749
+						$newToken['type'] = 'T_HEREDOC';
750
+					}
751
+
752
+					$finalTokens[$newStackPtr] = $newToken;
753
+					$newStackPtr++;
754
+				}//end for
755
+
756
+				// Add the end heredoc token to the final array.
757
+				$finalTokens[$newStackPtr] = self::standardiseToken($tokens[$stackPtr]);
758
+
759
+				if ($nowdoc === true) {
760
+					$finalTokens[$newStackPtr]['code'] = T_END_NOWDOC;
761
+					$finalTokens[$newStackPtr]['type'] = 'T_END_NOWDOC';
762
+				}
763
+
764
+				$newStackPtr++;
765
+
766
+				// Continue, as we're done with this token.
767
+				continue;
768
+			}//end if
769
+
770
+			/*
771 771
                 Before PHP 7.0, the "yield from" was tokenized as
772 772
                 T_YIELD, T_WHITESPACE and T_STRING. So look for
773 773
                 and change this token in earlier versions.
774 774
             */
775 775
 
776
-            if (PHP_VERSION_ID < 70000
777
-                && PHP_VERSION_ID >= 50500
778
-                && $tokenIsArray === true
779
-                && $token[0] === T_YIELD
780
-                && isset($tokens[($stackPtr + 1)]) === true
781
-                && isset($tokens[($stackPtr + 2)]) === true
782
-                && $tokens[($stackPtr + 1)][0] === T_WHITESPACE
783
-                && $tokens[($stackPtr + 2)][0] === T_STRING
784
-                && strtolower($tokens[($stackPtr + 2)][1]) === 'from'
785
-            ) {
786
-                // Could be multi-line, so just the token stack.
787
-                $token[0]  = T_YIELD_FROM;
788
-                $token[1] .= $tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
789
-
790
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
791
-                    for ($i = ($stackPtr + 1); $i <= ($stackPtr + 2); $i++) {
792
-                        $type    = Util\Tokens::tokenName($tokens[$i][0]);
793
-                        $content = Util\Common::prepareForOutput($tokens[$i][1]);
794
-                        echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content".PHP_EOL;
795
-                    }
796
-                }
797
-
798
-                $tokens[($stackPtr + 1)] = null;
799
-                $tokens[($stackPtr + 2)] = null;
800
-            }
801
-
802
-            /*
776
+			if (PHP_VERSION_ID < 70000
777
+				&& PHP_VERSION_ID >= 50500
778
+				&& $tokenIsArray === true
779
+				&& $token[0] === T_YIELD
780
+				&& isset($tokens[($stackPtr + 1)]) === true
781
+				&& isset($tokens[($stackPtr + 2)]) === true
782
+				&& $tokens[($stackPtr + 1)][0] === T_WHITESPACE
783
+				&& $tokens[($stackPtr + 2)][0] === T_STRING
784
+				&& strtolower($tokens[($stackPtr + 2)][1]) === 'from'
785
+			) {
786
+				// Could be multi-line, so just the token stack.
787
+				$token[0]  = T_YIELD_FROM;
788
+				$token[1] .= $tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
789
+
790
+				if (PHP_CODESNIFFER_VERBOSITY > 1) {
791
+					for ($i = ($stackPtr + 1); $i <= ($stackPtr + 2); $i++) {
792
+						$type    = Util\Tokens::tokenName($tokens[$i][0]);
793
+						$content = Util\Common::prepareForOutput($tokens[$i][1]);
794
+						echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content".PHP_EOL;
795
+					}
796
+				}
797
+
798
+				$tokens[($stackPtr + 1)] = null;
799
+				$tokens[($stackPtr + 2)] = null;
800
+			}
801
+
802
+			/*
803 803
                 Before PHP 5.5, the yield keyword was tokenized as
804 804
                 T_STRING. So look for and change this token in
805 805
                 earlier versions.
806 806
                 Checks also if it is just "yield" or "yield from".
807 807
             */
808 808
 
809
-            if (PHP_VERSION_ID < 50500
810
-                && $tokenIsArray === true
811
-                && $token[0] === T_STRING
812
-                && strtolower($token[1]) === 'yield'
813
-            ) {
814
-                if (isset($tokens[($stackPtr + 1)]) === true
815
-                    && isset($tokens[($stackPtr + 2)]) === true
816
-                    && $tokens[($stackPtr + 1)][0] === T_WHITESPACE
817
-                    && $tokens[($stackPtr + 2)][0] === T_STRING
818
-                    && strtolower($tokens[($stackPtr + 2)][1]) === 'from'
819
-                ) {
820
-                    // Could be multi-line, so just just the token stack.
821
-                    $token[0]  = T_YIELD_FROM;
822
-                    $token[1] .= $tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
823
-
824
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
825
-                        for ($i = ($stackPtr + 1); $i <= ($stackPtr + 2); $i++) {
826
-                            $type    = Util\Tokens::tokenName($tokens[$i][0]);
827
-                            $content = Util\Common::prepareForOutput($tokens[$i][1]);
828
-                            echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content".PHP_EOL;
829
-                        }
830
-                    }
831
-
832
-                    $tokens[($stackPtr + 1)] = null;
833
-                    $tokens[($stackPtr + 2)] = null;
834
-                } else {
835
-                    $newToken            = [];
836
-                    $newToken['code']    = T_YIELD;
837
-                    $newToken['type']    = 'T_YIELD';
838
-                    $newToken['content'] = $token[1];
839
-                    $finalTokens[$newStackPtr] = $newToken;
840
-
841
-                    $newStackPtr++;
842
-                    continue;
843
-                }//end if
844
-            }//end if
845
-
846
-            /*
809
+			if (PHP_VERSION_ID < 50500
810
+				&& $tokenIsArray === true
811
+				&& $token[0] === T_STRING
812
+				&& strtolower($token[1]) === 'yield'
813
+			) {
814
+				if (isset($tokens[($stackPtr + 1)]) === true
815
+					&& isset($tokens[($stackPtr + 2)]) === true
816
+					&& $tokens[($stackPtr + 1)][0] === T_WHITESPACE
817
+					&& $tokens[($stackPtr + 2)][0] === T_STRING
818
+					&& strtolower($tokens[($stackPtr + 2)][1]) === 'from'
819
+				) {
820
+					// Could be multi-line, so just just the token stack.
821
+					$token[0]  = T_YIELD_FROM;
822
+					$token[1] .= $tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
823
+
824
+					if (PHP_CODESNIFFER_VERBOSITY > 1) {
825
+						for ($i = ($stackPtr + 1); $i <= ($stackPtr + 2); $i++) {
826
+							$type    = Util\Tokens::tokenName($tokens[$i][0]);
827
+							$content = Util\Common::prepareForOutput($tokens[$i][1]);
828
+							echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content".PHP_EOL;
829
+						}
830
+					}
831
+
832
+					$tokens[($stackPtr + 1)] = null;
833
+					$tokens[($stackPtr + 2)] = null;
834
+				} else {
835
+					$newToken            = [];
836
+					$newToken['code']    = T_YIELD;
837
+					$newToken['type']    = 'T_YIELD';
838
+					$newToken['content'] = $token[1];
839
+					$finalTokens[$newStackPtr] = $newToken;
840
+
841
+					$newStackPtr++;
842
+					continue;
843
+				}//end if
844
+			}//end if
845
+
846
+			/*
847 847
                 Before PHP 5.6, the ... operator was tokenized as three
848 848
                 T_STRING_CONCAT tokens in a row. So look for and combine
849 849
                 these tokens in earlier versions.
850 850
             */
851 851
 
852
-            if ($tokenIsArray === false
853
-                && $token[0] === '.'
854
-                && isset($tokens[($stackPtr + 1)]) === true
855
-                && isset($tokens[($stackPtr + 2)]) === true
856
-                && $tokens[($stackPtr + 1)] === '.'
857
-                && $tokens[($stackPtr + 2)] === '.'
858
-            ) {
859
-                $newToken            = [];
860
-                $newToken['code']    = T_ELLIPSIS;
861
-                $newToken['type']    = 'T_ELLIPSIS';
862
-                $newToken['content'] = '...';
863
-                $finalTokens[$newStackPtr] = $newToken;
864
-
865
-                $newStackPtr++;
866
-                $stackPtr += 2;
867
-                continue;
868
-            }
869
-
870
-            /*
852
+			if ($tokenIsArray === false
853
+				&& $token[0] === '.'
854
+				&& isset($tokens[($stackPtr + 1)]) === true
855
+				&& isset($tokens[($stackPtr + 2)]) === true
856
+				&& $tokens[($stackPtr + 1)] === '.'
857
+				&& $tokens[($stackPtr + 2)] === '.'
858
+			) {
859
+				$newToken            = [];
860
+				$newToken['code']    = T_ELLIPSIS;
861
+				$newToken['type']    = 'T_ELLIPSIS';
862
+				$newToken['content'] = '...';
863
+				$finalTokens[$newStackPtr] = $newToken;
864
+
865
+				$newStackPtr++;
866
+				$stackPtr += 2;
867
+				continue;
868
+			}
869
+
870
+			/*
871 871
                 Before PHP 5.6, the ** operator was tokenized as two
872 872
                 T_MULTIPLY tokens in a row. So look for and combine
873 873
                 these tokens in earlier versions.
874 874
             */
875 875
 
876
-            if ($tokenIsArray === false
877
-                && $token[0] === '*'
878
-                && isset($tokens[($stackPtr + 1)]) === true
879
-                && $tokens[($stackPtr + 1)] === '*'
880
-            ) {
881
-                $newToken            = [];
882
-                $newToken['code']    = T_POW;
883
-                $newToken['type']    = 'T_POW';
884
-                $newToken['content'] = '**';
885
-                $finalTokens[$newStackPtr] = $newToken;
886
-
887
-                $newStackPtr++;
888
-                $stackPtr++;
889
-                continue;
890
-            }
891
-
892
-            /*
876
+			if ($tokenIsArray === false
877
+				&& $token[0] === '*'
878
+				&& isset($tokens[($stackPtr + 1)]) === true
879
+				&& $tokens[($stackPtr + 1)] === '*'
880
+			) {
881
+				$newToken            = [];
882
+				$newToken['code']    = T_POW;
883
+				$newToken['type']    = 'T_POW';
884
+				$newToken['content'] = '**';
885
+				$finalTokens[$newStackPtr] = $newToken;
886
+
887
+				$newStackPtr++;
888
+				$stackPtr++;
889
+				continue;
890
+			}
891
+
892
+			/*
893 893
                 Before PHP 5.6, the **= operator was tokenized as
894 894
                 T_MULTIPLY followed by T_MUL_EQUAL. So look for and combine
895 895
                 these tokens in earlier versions.
896 896
             */
897 897
 
898
-            if ($tokenIsArray === false
899
-                && $token[0] === '*'
900
-                && isset($tokens[($stackPtr + 1)]) === true
901
-                && is_array($tokens[($stackPtr + 1)]) === true
902
-                && $tokens[($stackPtr + 1)][1] === '*='
903
-            ) {
904
-                $newToken            = [];
905
-                $newToken['code']    = T_POW_EQUAL;
906
-                $newToken['type']    = 'T_POW_EQUAL';
907
-                $newToken['content'] = '**=';
908
-                $finalTokens[$newStackPtr] = $newToken;
909
-
910
-                $newStackPtr++;
911
-                $stackPtr++;
912
-                continue;
913
-            }
914
-
915
-            /*
898
+			if ($tokenIsArray === false
899
+				&& $token[0] === '*'
900
+				&& isset($tokens[($stackPtr + 1)]) === true
901
+				&& is_array($tokens[($stackPtr + 1)]) === true
902
+				&& $tokens[($stackPtr + 1)][1] === '*='
903
+			) {
904
+				$newToken            = [];
905
+				$newToken['code']    = T_POW_EQUAL;
906
+				$newToken['type']    = 'T_POW_EQUAL';
907
+				$newToken['content'] = '**=';
908
+				$finalTokens[$newStackPtr] = $newToken;
909
+
910
+				$newStackPtr++;
911
+				$stackPtr++;
912
+				continue;
913
+			}
914
+
915
+			/*
916 916
                 Before PHP 7, the ??= operator was tokenized as
917 917
                 T_INLINE_THEN, T_INLINE_THEN, T_EQUAL.
918 918
                 Between PHP 7.0 and 7.2, the ??= operator was tokenized as
@@ -920,277 +920,277 @@  discard block
 block discarded – undo
920 920
                 So look for and combine these tokens in earlier versions.
921 921
             */
922 922
 
923
-            if (($tokenIsArray === false
924
-                && $token[0] === '?'
925
-                && isset($tokens[($stackPtr + 1)]) === true
926
-                && $tokens[($stackPtr + 1)][0] === '?'
927
-                && isset($tokens[($stackPtr + 2)]) === true
928
-                && $tokens[($stackPtr + 2)][0] === '=')
929
-                || ($tokenIsArray === true
930
-                && $token[0] === T_COALESCE
931
-                && isset($tokens[($stackPtr + 1)]) === true
932
-                && $tokens[($stackPtr + 1)][0] === '=')
933
-            ) {
934
-                $newToken            = [];
935
-                $newToken['code']    = T_COALESCE_EQUAL;
936
-                $newToken['type']    = 'T_COALESCE_EQUAL';
937
-                $newToken['content'] = '??=';
938
-                $finalTokens[$newStackPtr] = $newToken;
939
-
940
-                $newStackPtr++;
941
-                $stackPtr++;
942
-
943
-                if ($tokenIsArray === false) {
944
-                    // Pre PHP 7.
945
-                    $stackPtr++;
946
-                }
947
-
948
-                continue;
949
-            }
950
-
951
-            /*
923
+			if (($tokenIsArray === false
924
+				&& $token[0] === '?'
925
+				&& isset($tokens[($stackPtr + 1)]) === true
926
+				&& $tokens[($stackPtr + 1)][0] === '?'
927
+				&& isset($tokens[($stackPtr + 2)]) === true
928
+				&& $tokens[($stackPtr + 2)][0] === '=')
929
+				|| ($tokenIsArray === true
930
+				&& $token[0] === T_COALESCE
931
+				&& isset($tokens[($stackPtr + 1)]) === true
932
+				&& $tokens[($stackPtr + 1)][0] === '=')
933
+			) {
934
+				$newToken            = [];
935
+				$newToken['code']    = T_COALESCE_EQUAL;
936
+				$newToken['type']    = 'T_COALESCE_EQUAL';
937
+				$newToken['content'] = '??=';
938
+				$finalTokens[$newStackPtr] = $newToken;
939
+
940
+				$newStackPtr++;
941
+				$stackPtr++;
942
+
943
+				if ($tokenIsArray === false) {
944
+					// Pre PHP 7.
945
+					$stackPtr++;
946
+				}
947
+
948
+				continue;
949
+			}
950
+
951
+			/*
952 952
                 Before PHP 7, the ?? operator was tokenized as
953 953
                 T_INLINE_THEN followed by T_INLINE_THEN.
954 954
                 So look for and combine these tokens in earlier versions.
955 955
             */
956 956
 
957
-            if ($tokenIsArray === false
958
-                && $token[0] === '?'
959
-                && isset($tokens[($stackPtr + 1)]) === true
960
-                && $tokens[($stackPtr + 1)][0] === '?'
961
-            ) {
962
-                $newToken            = [];
963
-                $newToken['code']    = T_COALESCE;
964
-                $newToken['type']    = 'T_COALESCE';
965
-                $newToken['content'] = '??';
966
-                $finalTokens[$newStackPtr] = $newToken;
967
-
968
-                $newStackPtr++;
969
-                $stackPtr++;
970
-                continue;
971
-            }
972
-
973
-            /*
957
+			if ($tokenIsArray === false
958
+				&& $token[0] === '?'
959
+				&& isset($tokens[($stackPtr + 1)]) === true
960
+				&& $tokens[($stackPtr + 1)][0] === '?'
961
+			) {
962
+				$newToken            = [];
963
+				$newToken['code']    = T_COALESCE;
964
+				$newToken['type']    = 'T_COALESCE';
965
+				$newToken['content'] = '??';
966
+				$finalTokens[$newStackPtr] = $newToken;
967
+
968
+				$newStackPtr++;
969
+				$stackPtr++;
970
+				continue;
971
+			}
972
+
973
+			/*
974 974
                 Convert ? to T_NULLABLE OR T_INLINE_THEN
975 975
             */
976 976
 
977
-            if ($tokenIsArray === false && $token[0] === '?') {
978
-                $newToken            = [];
979
-                $newToken['content'] = '?';
980
-
981
-                $prevNonEmpty = null;
982
-                for ($i = ($stackPtr - 1); $i >= 0; $i--) {
983
-                    if (is_array($tokens[$i]) === true) {
984
-                        $tokenType = $tokens[$i][0];
985
-                    } else {
986
-                        $tokenType = $tokens[$i];
987
-                    }
988
-
989
-                    if ($prevNonEmpty === null
990
-                        && isset(Util\Tokens::$emptyTokens[$tokenType]) === false
991
-                    ) {
992
-                        // Found the previous non-empty token.
993
-                        if ($tokenType === ':' || $tokenType === ',') {
994
-                            $newToken['code'] = T_NULLABLE;
995
-                            $newToken['type'] = 'T_NULLABLE';
996
-                            break;
997
-                        }
998
-
999
-                        $prevNonEmpty = $tokenType;
1000
-                    }
1001
-
1002
-                    if ($tokenType === T_FUNCTION) {
1003
-                        $newToken['code'] = T_NULLABLE;
1004
-                        $newToken['type'] = 'T_NULLABLE';
1005
-                        break;
1006
-                    } else if (in_array($tokenType, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';'], true) === true) {
1007
-                        $newToken['code'] = T_INLINE_THEN;
1008
-                        $newToken['type'] = 'T_INLINE_THEN';
1009
-
1010
-                        $insideInlineIf[] = $stackPtr;
1011
-                        break;
1012
-                    }
1013
-                }//end for
1014
-
1015
-                $finalTokens[$newStackPtr] = $newToken;
1016
-                $newStackPtr++;
1017
-                continue;
1018
-            }//end if
1019
-
1020
-            /*
977
+			if ($tokenIsArray === false && $token[0] === '?') {
978
+				$newToken            = [];
979
+				$newToken['content'] = '?';
980
+
981
+				$prevNonEmpty = null;
982
+				for ($i = ($stackPtr - 1); $i >= 0; $i--) {
983
+					if (is_array($tokens[$i]) === true) {
984
+						$tokenType = $tokens[$i][0];
985
+					} else {
986
+						$tokenType = $tokens[$i];
987
+					}
988
+
989
+					if ($prevNonEmpty === null
990
+						&& isset(Util\Tokens::$emptyTokens[$tokenType]) === false
991
+					) {
992
+						// Found the previous non-empty token.
993
+						if ($tokenType === ':' || $tokenType === ',') {
994
+							$newToken['code'] = T_NULLABLE;
995
+							$newToken['type'] = 'T_NULLABLE';
996
+							break;
997
+						}
998
+
999
+						$prevNonEmpty = $tokenType;
1000
+					}
1001
+
1002
+					if ($tokenType === T_FUNCTION) {
1003
+						$newToken['code'] = T_NULLABLE;
1004
+						$newToken['type'] = 'T_NULLABLE';
1005
+						break;
1006
+					} else if (in_array($tokenType, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';'], true) === true) {
1007
+						$newToken['code'] = T_INLINE_THEN;
1008
+						$newToken['type'] = 'T_INLINE_THEN';
1009
+
1010
+						$insideInlineIf[] = $stackPtr;
1011
+						break;
1012
+					}
1013
+				}//end for
1014
+
1015
+				$finalTokens[$newStackPtr] = $newToken;
1016
+				$newStackPtr++;
1017
+				continue;
1018
+			}//end if
1019
+
1020
+			/*
1021 1021
                 Tokens after a double colon may be look like scope openers,
1022 1022
                 such as when writing code like Foo::NAMESPACE, but they are
1023 1023
                 only ever variables or strings.
1024 1024
             */
1025 1025
 
1026
-            if ($stackPtr > 1
1027
-                && (is_array($tokens[($stackPtr - 1)]) === true
1028
-                && $tokens[($stackPtr - 1)][0] === T_PAAMAYIM_NEKUDOTAYIM)
1029
-                && $tokenIsArray === true
1030
-                && $token[0] !== T_STRING
1031
-                && $token[0] !== T_VARIABLE
1032
-                && $token[0] !== T_DOLLAR
1033
-                && isset(Util\Tokens::$emptyTokens[$token[0]]) === false
1034
-            ) {
1035
-                $newToken            = [];
1036
-                $newToken['code']    = T_STRING;
1037
-                $newToken['type']    = 'T_STRING';
1038
-                $newToken['content'] = $token[1];
1039
-                $finalTokens[$newStackPtr] = $newToken;
1040
-
1041
-                $newStackPtr++;
1042
-                continue;
1043
-            }
1044
-
1045
-            /*
1026
+			if ($stackPtr > 1
1027
+				&& (is_array($tokens[($stackPtr - 1)]) === true
1028
+				&& $tokens[($stackPtr - 1)][0] === T_PAAMAYIM_NEKUDOTAYIM)
1029
+				&& $tokenIsArray === true
1030
+				&& $token[0] !== T_STRING
1031
+				&& $token[0] !== T_VARIABLE
1032
+				&& $token[0] !== T_DOLLAR
1033
+				&& isset(Util\Tokens::$emptyTokens[$token[0]]) === false
1034
+			) {
1035
+				$newToken            = [];
1036
+				$newToken['code']    = T_STRING;
1037
+				$newToken['type']    = 'T_STRING';
1038
+				$newToken['content'] = $token[1];
1039
+				$finalTokens[$newStackPtr] = $newToken;
1040
+
1041
+				$newStackPtr++;
1042
+				continue;
1043
+			}
1044
+
1045
+			/*
1046 1046
                 The string-like token after a function keyword should always be
1047 1047
                 tokenized as T_STRING even if it appears to be a different token,
1048 1048
                 such as when writing code like: function default(): foo
1049 1049
                 so go forward and change the token type before it is processed.
1050 1050
             */
1051 1051
 
1052
-            if ($tokenIsArray === true
1053
-                && $token[0] === T_FUNCTION
1054
-                && $finalTokens[$lastNotEmptyToken]['code'] !== T_USE
1055
-            ) {
1056
-                for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
1057
-                    if (is_array($tokens[$x]) === false
1058
-                        || isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === false
1059
-                    ) {
1060
-                        // Non-empty content.
1061
-                        break;
1062
-                    }
1063
-                }
1064
-
1065
-                if ($x < $numTokens && is_array($tokens[$x]) === true) {
1066
-                    $tokens[$x][0] = T_STRING;
1067
-                }
1068
-
1069
-                /*
1052
+			if ($tokenIsArray === true
1053
+				&& $token[0] === T_FUNCTION
1054
+				&& $finalTokens[$lastNotEmptyToken]['code'] !== T_USE
1055
+			) {
1056
+				for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
1057
+					if (is_array($tokens[$x]) === false
1058
+						|| isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === false
1059
+					) {
1060
+						// Non-empty content.
1061
+						break;
1062
+					}
1063
+				}
1064
+
1065
+				if ($x < $numTokens && is_array($tokens[$x]) === true) {
1066
+					$tokens[$x][0] = T_STRING;
1067
+				}
1068
+
1069
+				/*
1070 1070
                     This is a special condition for T_ARRAY tokens used for
1071 1071
                     function return types. We want to keep the parenthesis map clean,
1072 1072
                     so let's tag these tokens as T_STRING.
1073 1073
                 */
1074 1074
 
1075
-                // Go looking for the colon to start the return type hint.
1076
-                // Start by finding the closing parenthesis of the function.
1077
-                $parenthesisStack  = [];
1078
-                $parenthesisCloser = false;
1079
-                for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
1080
-                    if (is_array($tokens[$x]) === false && $tokens[$x] === '(') {
1081
-                        $parenthesisStack[] = $x;
1082
-                    } else if (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
1083
-                        array_pop($parenthesisStack);
1084
-                        if (empty($parenthesisStack) === true) {
1085
-                            $parenthesisCloser = $x;
1086
-                            break;
1087
-                        }
1088
-                    }
1089
-                }
1090
-
1091
-                if ($parenthesisCloser !== false) {
1092
-                    for ($x = ($parenthesisCloser + 1); $x < $numTokens; $x++) {
1093
-                        if (is_array($tokens[$x]) === false
1094
-                            || isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === false
1095
-                        ) {
1096
-                            // Non-empty content.
1097
-                            if (is_array($tokens[$x]) === true && $tokens[$x][0] === T_USE) {
1098
-                                // Found a use statements, so search ahead for the closing parenthesis.
1099
-                                for ($x += 1; $x < $numTokens; $x++) {
1100
-                                    if (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
1101
-                                        continue(2);
1102
-                                    }
1103
-                                }
1104
-                            }
1105
-
1106
-                            break;
1107
-                        }
1108
-                    }
1109
-
1110
-                    if (isset($tokens[$x]) === true
1111
-                        && is_array($tokens[$x]) === false
1112
-                        && $tokens[$x] === ':'
1113
-                    ) {
1114
-                        $allowed = [
1115
-                            T_STRING       => T_STRING,
1116
-                            T_ARRAY        => T_ARRAY,
1117
-                            T_CALLABLE     => T_CALLABLE,
1118
-                            T_SELF         => T_SELF,
1119
-                            T_PARENT       => T_PARENT,
1120
-                            T_NS_SEPARATOR => T_NS_SEPARATOR,
1121
-                        ];
1122
-
1123
-                        $allowed += Util\Tokens::$emptyTokens;
1124
-
1125
-                        // Find the start of the return type.
1126
-                        for ($x += 1; $x < $numTokens; $x++) {
1127
-                            if (is_array($tokens[$x]) === true
1128
-                                && isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === true
1129
-                            ) {
1130
-                                // Whitespace or comments before the return type.
1131
-                                continue;
1132
-                            }
1133
-
1134
-                            if (is_array($tokens[$x]) === false && $tokens[$x] === '?') {
1135
-                                // Found a nullable operator, so skip it.
1136
-                                // But also covert the token to save the tokenizer
1137
-                                // a bit of time later on.
1138
-                                $tokens[$x] = [
1139
-                                    T_NULLABLE,
1140
-                                    '?',
1141
-                                ];
1142
-
1143
-                                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1144
-                                    echo "\t\t* token $x changed from ? to T_NULLABLE".PHP_EOL;
1145
-                                }
1146
-
1147
-                                continue;
1148
-                            }
1149
-
1150
-                            break;
1151
-                        }//end for
1152
-
1153
-                        // Any T_ARRAY tokens we find between here and the next
1154
-                        // token that can't be part of the return type need to be
1155
-                        // converted to T_STRING tokens.
1156
-                        for ($x; $x < $numTokens; $x++) {
1157
-                            if (is_array($tokens[$x]) === false || isset($allowed[$tokens[$x][0]]) === false) {
1158
-                                break;
1159
-                            } else if ($tokens[$x][0] === T_ARRAY) {
1160
-                                $tokens[$x][0] = T_STRING;
1161
-
1162
-                                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1163
-                                    echo "\t\t* token $x changed from T_ARRAY to T_STRING".PHP_EOL;
1164
-                                }
1165
-                            }
1166
-                        }
1167
-                    }//end if
1168
-                }//end if
1169
-            }//end if
1170
-
1171
-            /*
1075
+				// Go looking for the colon to start the return type hint.
1076
+				// Start by finding the closing parenthesis of the function.
1077
+				$parenthesisStack  = [];
1078
+				$parenthesisCloser = false;
1079
+				for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
1080
+					if (is_array($tokens[$x]) === false && $tokens[$x] === '(') {
1081
+						$parenthesisStack[] = $x;
1082
+					} else if (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
1083
+						array_pop($parenthesisStack);
1084
+						if (empty($parenthesisStack) === true) {
1085
+							$parenthesisCloser = $x;
1086
+							break;
1087
+						}
1088
+					}
1089
+				}
1090
+
1091
+				if ($parenthesisCloser !== false) {
1092
+					for ($x = ($parenthesisCloser + 1); $x < $numTokens; $x++) {
1093
+						if (is_array($tokens[$x]) === false
1094
+							|| isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === false
1095
+						) {
1096
+							// Non-empty content.
1097
+							if (is_array($tokens[$x]) === true && $tokens[$x][0] === T_USE) {
1098
+								// Found a use statements, so search ahead for the closing parenthesis.
1099
+								for ($x += 1; $x < $numTokens; $x++) {
1100
+									if (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
1101
+										continue(2);
1102
+									}
1103
+								}
1104
+							}
1105
+
1106
+							break;
1107
+						}
1108
+					}
1109
+
1110
+					if (isset($tokens[$x]) === true
1111
+						&& is_array($tokens[$x]) === false
1112
+						&& $tokens[$x] === ':'
1113
+					) {
1114
+						$allowed = [
1115
+							T_STRING       => T_STRING,
1116
+							T_ARRAY        => T_ARRAY,
1117
+							T_CALLABLE     => T_CALLABLE,
1118
+							T_SELF         => T_SELF,
1119
+							T_PARENT       => T_PARENT,
1120
+							T_NS_SEPARATOR => T_NS_SEPARATOR,
1121
+						];
1122
+
1123
+						$allowed += Util\Tokens::$emptyTokens;
1124
+
1125
+						// Find the start of the return type.
1126
+						for ($x += 1; $x < $numTokens; $x++) {
1127
+							if (is_array($tokens[$x]) === true
1128
+								&& isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === true
1129
+							) {
1130
+								// Whitespace or comments before the return type.
1131
+								continue;
1132
+							}
1133
+
1134
+							if (is_array($tokens[$x]) === false && $tokens[$x] === '?') {
1135
+								// Found a nullable operator, so skip it.
1136
+								// But also covert the token to save the tokenizer
1137
+								// a bit of time later on.
1138
+								$tokens[$x] = [
1139
+									T_NULLABLE,
1140
+									'?',
1141
+								];
1142
+
1143
+								if (PHP_CODESNIFFER_VERBOSITY > 1) {
1144
+									echo "\t\t* token $x changed from ? to T_NULLABLE".PHP_EOL;
1145
+								}
1146
+
1147
+								continue;
1148
+							}
1149
+
1150
+							break;
1151
+						}//end for
1152
+
1153
+						// Any T_ARRAY tokens we find between here and the next
1154
+						// token that can't be part of the return type need to be
1155
+						// converted to T_STRING tokens.
1156
+						for ($x; $x < $numTokens; $x++) {
1157
+							if (is_array($tokens[$x]) === false || isset($allowed[$tokens[$x][0]]) === false) {
1158
+								break;
1159
+							} else if ($tokens[$x][0] === T_ARRAY) {
1160
+								$tokens[$x][0] = T_STRING;
1161
+
1162
+								if (PHP_CODESNIFFER_VERBOSITY > 1) {
1163
+									echo "\t\t* token $x changed from T_ARRAY to T_STRING".PHP_EOL;
1164
+								}
1165
+							}
1166
+						}
1167
+					}//end if
1168
+				}//end if
1169
+			}//end if
1170
+
1171
+			/*
1172 1172
                 Before PHP 7, the <=> operator was tokenized as
1173 1173
                 T_IS_SMALLER_OR_EQUAL followed by T_GREATER_THAN.
1174 1174
                 So look for and combine these tokens in earlier versions.
1175 1175
             */
1176 1176
 
1177
-            if ($tokenIsArray === true
1178
-                && $token[0] === T_IS_SMALLER_OR_EQUAL
1179
-                && isset($tokens[($stackPtr + 1)]) === true
1180
-                && $tokens[($stackPtr + 1)][0] === '>'
1181
-            ) {
1182
-                $newToken            = [];
1183
-                $newToken['code']    = T_SPACESHIP;
1184
-                $newToken['type']    = 'T_SPACESHIP';
1185
-                $newToken['content'] = '<=>';
1186
-                $finalTokens[$newStackPtr] = $newToken;
1187
-
1188
-                $newStackPtr++;
1189
-                $stackPtr++;
1190
-                continue;
1191
-            }
1192
-
1193
-            /*
1177
+			if ($tokenIsArray === true
1178
+				&& $token[0] === T_IS_SMALLER_OR_EQUAL
1179
+				&& isset($tokens[($stackPtr + 1)]) === true
1180
+				&& $tokens[($stackPtr + 1)][0] === '>'
1181
+			) {
1182
+				$newToken            = [];
1183
+				$newToken['code']    = T_SPACESHIP;
1184
+				$newToken['type']    = 'T_SPACESHIP';
1185
+				$newToken['content'] = '<=>';
1186
+				$finalTokens[$newStackPtr] = $newToken;
1187
+
1188
+				$newStackPtr++;
1189
+				$stackPtr++;
1190
+				continue;
1191
+			}
1192
+
1193
+			/*
1194 1194
                 PHP doesn't assign a token to goto labels, so we have to.
1195 1195
                 These are just string tokens with a single colon after them. Double
1196 1196
                 colons are already tokenized and so don't interfere with this check.
@@ -1198,820 +1198,820 @@  discard block
 block discarded – undo
1198 1198
                 goto labels.
1199 1199
             */
1200 1200
 
1201
-            if ($tokenIsArray === true
1202
-                && $token[0] === T_STRING
1203
-                && isset($tokens[($stackPtr + 1)]) === true
1204
-                && $tokens[($stackPtr + 1)] === ':'
1205
-                && $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM
1206
-            ) {
1207
-                $stopTokens = [
1208
-                    T_CASE               => true,
1209
-                    T_SEMICOLON          => true,
1210
-                    T_OPEN_CURLY_BRACKET => true,
1211
-                    T_INLINE_THEN        => true,
1212
-                ];
1213
-
1214
-                for ($x = ($newStackPtr - 1); $x > 0; $x--) {
1215
-                    if (isset($stopTokens[$finalTokens[$x]['code']]) === true) {
1216
-                        break;
1217
-                    }
1218
-                }
1219
-
1220
-                if ($finalTokens[$x]['code'] !== T_CASE
1221
-                    && $finalTokens[$x]['code'] !== T_INLINE_THEN
1222
-                ) {
1223
-                    $finalTokens[$newStackPtr] = [
1224
-                        'content' => $token[1].':',
1225
-                        'code'    => T_GOTO_LABEL,
1226
-                        'type'    => 'T_GOTO_LABEL',
1227
-                    ];
1228
-
1229
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1230
-                        echo "\t\t* token $stackPtr changed from T_STRING to T_GOTO_LABEL".PHP_EOL;
1231
-                        echo "\t\t* skipping T_COLON token ".($stackPtr + 1).PHP_EOL;
1232
-                    }
1233
-
1234
-                    $newStackPtr++;
1235
-                    $stackPtr++;
1236
-                    continue;
1237
-                }
1238
-            }//end if
1239
-
1240
-            /*
1201
+			if ($tokenIsArray === true
1202
+				&& $token[0] === T_STRING
1203
+				&& isset($tokens[($stackPtr + 1)]) === true
1204
+				&& $tokens[($stackPtr + 1)] === ':'
1205
+				&& $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM
1206
+			) {
1207
+				$stopTokens = [
1208
+					T_CASE               => true,
1209
+					T_SEMICOLON          => true,
1210
+					T_OPEN_CURLY_BRACKET => true,
1211
+					T_INLINE_THEN        => true,
1212
+				];
1213
+
1214
+				for ($x = ($newStackPtr - 1); $x > 0; $x--) {
1215
+					if (isset($stopTokens[$finalTokens[$x]['code']]) === true) {
1216
+						break;
1217
+					}
1218
+				}
1219
+
1220
+				if ($finalTokens[$x]['code'] !== T_CASE
1221
+					&& $finalTokens[$x]['code'] !== T_INLINE_THEN
1222
+				) {
1223
+					$finalTokens[$newStackPtr] = [
1224
+						'content' => $token[1].':',
1225
+						'code'    => T_GOTO_LABEL,
1226
+						'type'    => 'T_GOTO_LABEL',
1227
+					];
1228
+
1229
+					if (PHP_CODESNIFFER_VERBOSITY > 1) {
1230
+						echo "\t\t* token $stackPtr changed from T_STRING to T_GOTO_LABEL".PHP_EOL;
1231
+						echo "\t\t* skipping T_COLON token ".($stackPtr + 1).PHP_EOL;
1232
+					}
1233
+
1234
+					$newStackPtr++;
1235
+					$stackPtr++;
1236
+					continue;
1237
+				}
1238
+			}//end if
1239
+
1240
+			/*
1241 1241
                 If this token has newlines in its content, split each line up
1242 1242
                 and create a new token for each line. We do this so it's easier
1243 1243
                 to ascertain where errors occur on a line.
1244 1244
                 Note that $token[1] is the token's content.
1245 1245
             */
1246 1246
 
1247
-            if ($tokenIsArray === true && strpos($token[1], $this->eolChar) !== false) {
1248
-                $tokenLines = explode($this->eolChar, $token[1]);
1249
-                $numLines   = count($tokenLines);
1250
-                $newToken   = [
1251
-                    'type'    => Util\Tokens::tokenName($token[0]),
1252
-                    'code'    => $token[0],
1253
-                    'content' => '',
1254
-                ];
1255
-
1256
-                for ($i = 0; $i < $numLines; $i++) {
1257
-                    $newToken['content'] = $tokenLines[$i];
1258
-                    if ($i === ($numLines - 1)) {
1259
-                        if ($tokenLines[$i] === '') {
1260
-                            break;
1261
-                        }
1262
-                    } else {
1263
-                        $newToken['content'] .= $this->eolChar;
1264
-                    }
1265
-
1266
-                    $finalTokens[$newStackPtr] = $newToken;
1267
-                    $newStackPtr++;
1268
-                }
1269
-            } else {
1270
-                if ($tokenIsArray === true && $token[0] === T_STRING) {
1271
-                    // Some T_STRING tokens should remain that way
1272
-                    // due to their context.
1273
-                    $context = [
1274
-                        T_OBJECT_OPERATOR      => true,
1275
-                        T_FUNCTION             => true,
1276
-                        T_CLASS                => true,
1277
-                        T_EXTENDS              => true,
1278
-                        T_IMPLEMENTS           => true,
1279
-                        T_NEW                  => true,
1280
-                        T_CONST                => true,
1281
-                        T_NS_SEPARATOR         => true,
1282
-                        T_USE                  => true,
1283
-                        T_NAMESPACE            => true,
1284
-                        T_PAAMAYIM_NEKUDOTAYIM => true,
1285
-                    ];
1286
-
1287
-                    if (isset($context[$finalTokens[$lastNotEmptyToken]['code']]) === true) {
1288
-                        // Special case for syntax like: return new self
1289
-                        // where self should not be a string.
1290
-                        if ($finalTokens[$lastNotEmptyToken]['code'] === T_NEW
1291
-                            && strtolower($token[1]) === 'self'
1292
-                        ) {
1293
-                            $finalTokens[$newStackPtr] = [
1294
-                                'content' => $token[1],
1295
-                                'code'    => T_SELF,
1296
-                                'type'    => 'T_SELF',
1297
-                            ];
1298
-                        } else {
1299
-                            $finalTokens[$newStackPtr] = [
1300
-                                'content' => $token[1],
1301
-                                'code'    => T_STRING,
1302
-                                'type'    => 'T_STRING',
1303
-                            ];
1304
-                        }
1305
-
1306
-                        $newStackPtr++;
1307
-                        continue;
1308
-                    }//end if
1309
-                }//end if
1310
-
1311
-                $newToken = null;
1312
-                if ($tokenIsArray === false) {
1313
-                    if (isset(self::$resolveTokenCache[$token[0]]) === true) {
1314
-                        $newToken = self::$resolveTokenCache[$token[0]];
1315
-                    }
1316
-                } else {
1317
-                    $cacheKey = null;
1318
-                    if ($token[0] === T_STRING) {
1319
-                        $cacheKey = strtolower($token[1]);
1320
-                    } else if ($token[0] !== T_CURLY_OPEN) {
1321
-                        $cacheKey = $token[0];
1322
-                    }
1323
-
1324
-                    if ($cacheKey !== null && isset(self::$resolveTokenCache[$cacheKey]) === true) {
1325
-                        $newToken            = self::$resolveTokenCache[$cacheKey];
1326
-                        $newToken['content'] = $token[1];
1327
-                    }
1328
-                }
1329
-
1330
-                if ($newToken === null) {
1331
-                    $newToken = self::standardiseToken($token);
1332
-                }
1333
-
1334
-                // Convert colons that are actually the ELSE component of an
1335
-                // inline IF statement.
1336
-                if (empty($insideInlineIf) === false && $newToken['code'] === T_COLON) {
1337
-                    // Make sure this isn't the return type separator of a closure.
1338
-                    $isReturnType = false;
1339
-                    for ($i = ($stackPtr - 1); $i > 0; $i--) {
1340
-                        if (is_array($tokens[$i]) === false
1341
-                            || ($tokens[$i][0] !== T_DOC_COMMENT
1342
-                            && $tokens[$i][0] !== T_COMMENT
1343
-                            && $tokens[$i][0] !== T_WHITESPACE)
1344
-                        ) {
1345
-                            break;
1346
-                        }
1347
-                    }
1348
-
1349
-                    if ($tokens[$i] === ')') {
1350
-                        $parenCount = 1;
1351
-                        for ($i--; $i > 0; $i--) {
1352
-                            if ($tokens[$i] === '(') {
1353
-                                $parenCount--;
1354
-                                if ($parenCount === 0) {
1355
-                                    break;
1356
-                                }
1357
-                            } else if ($tokens[$i] === ')') {
1358
-                                $parenCount++;
1359
-                            }
1360
-                        }
1361
-
1362
-                        // We've found the open parenthesis, so if the previous
1363
-                        // non-empty token is FUNCTION or USE, this is a closure.
1364
-                        for ($i--; $i > 0; $i--) {
1365
-                            if (is_array($tokens[$i]) === false
1366
-                                || ($tokens[$i][0] !== T_DOC_COMMENT
1367
-                                && $tokens[$i][0] !== T_COMMENT
1368
-                                && $tokens[$i][0] !== T_WHITESPACE)
1369
-                            ) {
1370
-                                break;
1371
-                            }
1372
-                        }
1373
-
1374
-                        if ($tokens[$i][0] === T_FUNCTION || $tokens[$i][0] === T_USE) {
1375
-                            $isReturnType = true;
1376
-                        }
1377
-                    }//end if
1378
-
1379
-                    if ($isReturnType === false) {
1380
-                        array_pop($insideInlineIf);
1381
-                        $newToken['code'] = T_INLINE_ELSE;
1382
-                        $newToken['type'] = 'T_INLINE_ELSE';
1383
-                    }
1384
-                }//end if
1385
-
1386
-                // This is a special condition for T_ARRAY tokens used for
1387
-                // type hinting function arguments as being arrays. We want to keep
1388
-                // the parenthesis map clean, so let's tag these tokens as
1389
-                // T_STRING.
1390
-                if ($newToken['code'] === T_ARRAY) {
1391
-                    for ($i = $stackPtr; $i < $numTokens; $i++) {
1392
-                        if ($tokens[$i] === '(') {
1393
-                            break;
1394
-                        } else if ($tokens[$i][0] === T_VARIABLE) {
1395
-                            $newToken['code'] = T_STRING;
1396
-                            $newToken['type'] = 'T_STRING';
1397
-                            break;
1398
-                        }
1399
-                    }
1400
-                }
1401
-
1402
-                // This is a special case when checking PHP 5.5+ code in PHP < 5.5
1403
-                // where "finally" should be T_FINALLY instead of T_STRING.
1404
-                if ($newToken['code'] === T_STRING
1405
-                    && strtolower($newToken['content']) === 'finally'
1406
-                ) {
1407
-                    $newToken['code'] = T_FINALLY;
1408
-                    $newToken['type'] = 'T_FINALLY';
1409
-                }
1410
-
1411
-                // This is a special case for the PHP 5.5 classname::class syntax
1412
-                // where "class" should be T_STRING instead of T_CLASS.
1413
-                if (($newToken['code'] === T_CLASS
1414
-                    || $newToken['code'] === T_FUNCTION)
1415
-                    && $finalTokens[$lastNotEmptyToken]['code'] === T_DOUBLE_COLON
1416
-                ) {
1417
-                    $newToken['code'] = T_STRING;
1418
-                    $newToken['type'] = 'T_STRING';
1419
-                }
1420
-
1421
-                // This is a special case for PHP 5.6 use function and use const
1422
-                // where "function" and "const" should be T_STRING instead of T_FUNCTION
1423
-                // and T_CONST.
1424
-                if (($newToken['code'] === T_FUNCTION
1425
-                    || $newToken['code'] === T_CONST)
1426
-                    && ($finalTokens[$lastNotEmptyToken]['code'] === T_USE || $insideUseGroup === true)
1427
-                ) {
1428
-                    $newToken['code'] = T_STRING;
1429
-                    $newToken['type'] = 'T_STRING';
1430
-                }
1431
-
1432
-                // This is a special case for use groups in PHP 7+ where leaving
1433
-                // the curly braces as their normal tokens would confuse
1434
-                // the scope map and sniffs.
1435
-                if ($newToken['code'] === T_OPEN_CURLY_BRACKET
1436
-                    && $finalTokens[$lastNotEmptyToken]['code'] === T_NS_SEPARATOR
1437
-                ) {
1438
-                    $newToken['code'] = T_OPEN_USE_GROUP;
1439
-                    $newToken['type'] = 'T_OPEN_USE_GROUP';
1440
-                    $insideUseGroup   = true;
1441
-                }
1442
-
1443
-                if ($insideUseGroup === true && $newToken['code'] === T_CLOSE_CURLY_BRACKET) {
1444
-                    $newToken['code'] = T_CLOSE_USE_GROUP;
1445
-                    $newToken['type'] = 'T_CLOSE_USE_GROUP';
1446
-                    $insideUseGroup   = false;
1447
-                }
1448
-
1449
-                $finalTokens[$newStackPtr] = $newToken;
1450
-                $newStackPtr++;
1451
-            }//end if
1452
-        }//end for
1453
-
1454
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1455
-            echo "\t*** END PHP TOKENIZING ***".PHP_EOL;
1456
-        }
1457
-
1458
-        return $finalTokens;
1459
-
1460
-    }//end tokenize()
1461
-
1462
-
1463
-    /**
1464
-     * Performs additional processing after main tokenizing.
1465
-     *
1466
-     * This additional processing checks for CASE statements that are using curly
1467
-     * braces for scope openers and closers. It also turns some T_FUNCTION tokens
1468
-     * into T_CLOSURE when they are not standard function definitions. It also
1469
-     * detects short array syntax and converts those square brackets into new tokens.
1470
-     * It also corrects some usage of the static and class keywords. It also
1471
-     * assigns tokens to function return types.
1472
-     *
1473
-     * @return void
1474
-     */
1475
-    protected function processAdditional()
1476
-    {
1477
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1478
-            echo "\t*** START ADDITIONAL PHP PROCESSING ***".PHP_EOL;
1479
-        }
1480
-
1481
-        $numTokens = count($this->tokens);
1482
-        for ($i = ($numTokens - 1); $i >= 0; $i--) {
1483
-            // Check for any unset scope conditions due to alternate IF/ENDIF syntax.
1484
-            if (isset($this->tokens[$i]['scope_opener']) === true
1485
-                && isset($this->tokens[$i]['scope_condition']) === false
1486
-            ) {
1487
-                $this->tokens[$i]['scope_condition'] = $this->tokens[$this->tokens[$i]['scope_opener']]['scope_condition'];
1488
-            }
1489
-
1490
-            if ($this->tokens[$i]['code'] === T_FUNCTION) {
1491
-                /*
1247
+			if ($tokenIsArray === true && strpos($token[1], $this->eolChar) !== false) {
1248
+				$tokenLines = explode($this->eolChar, $token[1]);
1249
+				$numLines   = count($tokenLines);
1250
+				$newToken   = [
1251
+					'type'    => Util\Tokens::tokenName($token[0]),
1252
+					'code'    => $token[0],
1253
+					'content' => '',
1254
+				];
1255
+
1256
+				for ($i = 0; $i < $numLines; $i++) {
1257
+					$newToken['content'] = $tokenLines[$i];
1258
+					if ($i === ($numLines - 1)) {
1259
+						if ($tokenLines[$i] === '') {
1260
+							break;
1261
+						}
1262
+					} else {
1263
+						$newToken['content'] .= $this->eolChar;
1264
+					}
1265
+
1266
+					$finalTokens[$newStackPtr] = $newToken;
1267
+					$newStackPtr++;
1268
+				}
1269
+			} else {
1270
+				if ($tokenIsArray === true && $token[0] === T_STRING) {
1271
+					// Some T_STRING tokens should remain that way
1272
+					// due to their context.
1273
+					$context = [
1274
+						T_OBJECT_OPERATOR      => true,
1275
+						T_FUNCTION             => true,
1276
+						T_CLASS                => true,
1277
+						T_EXTENDS              => true,
1278
+						T_IMPLEMENTS           => true,
1279
+						T_NEW                  => true,
1280
+						T_CONST                => true,
1281
+						T_NS_SEPARATOR         => true,
1282
+						T_USE                  => true,
1283
+						T_NAMESPACE            => true,
1284
+						T_PAAMAYIM_NEKUDOTAYIM => true,
1285
+					];
1286
+
1287
+					if (isset($context[$finalTokens[$lastNotEmptyToken]['code']]) === true) {
1288
+						// Special case for syntax like: return new self
1289
+						// where self should not be a string.
1290
+						if ($finalTokens[$lastNotEmptyToken]['code'] === T_NEW
1291
+							&& strtolower($token[1]) === 'self'
1292
+						) {
1293
+							$finalTokens[$newStackPtr] = [
1294
+								'content' => $token[1],
1295
+								'code'    => T_SELF,
1296
+								'type'    => 'T_SELF',
1297
+							];
1298
+						} else {
1299
+							$finalTokens[$newStackPtr] = [
1300
+								'content' => $token[1],
1301
+								'code'    => T_STRING,
1302
+								'type'    => 'T_STRING',
1303
+							];
1304
+						}
1305
+
1306
+						$newStackPtr++;
1307
+						continue;
1308
+					}//end if
1309
+				}//end if
1310
+
1311
+				$newToken = null;
1312
+				if ($tokenIsArray === false) {
1313
+					if (isset(self::$resolveTokenCache[$token[0]]) === true) {
1314
+						$newToken = self::$resolveTokenCache[$token[0]];
1315
+					}
1316
+				} else {
1317
+					$cacheKey = null;
1318
+					if ($token[0] === T_STRING) {
1319
+						$cacheKey = strtolower($token[1]);
1320
+					} else if ($token[0] !== T_CURLY_OPEN) {
1321
+						$cacheKey = $token[0];
1322
+					}
1323
+
1324
+					if ($cacheKey !== null && isset(self::$resolveTokenCache[$cacheKey]) === true) {
1325
+						$newToken            = self::$resolveTokenCache[$cacheKey];
1326
+						$newToken['content'] = $token[1];
1327
+					}
1328
+				}
1329
+
1330
+				if ($newToken === null) {
1331
+					$newToken = self::standardiseToken($token);
1332
+				}
1333
+
1334
+				// Convert colons that are actually the ELSE component of an
1335
+				// inline IF statement.
1336
+				if (empty($insideInlineIf) === false && $newToken['code'] === T_COLON) {
1337
+					// Make sure this isn't the return type separator of a closure.
1338
+					$isReturnType = false;
1339
+					for ($i = ($stackPtr - 1); $i > 0; $i--) {
1340
+						if (is_array($tokens[$i]) === false
1341
+							|| ($tokens[$i][0] !== T_DOC_COMMENT
1342
+							&& $tokens[$i][0] !== T_COMMENT
1343
+							&& $tokens[$i][0] !== T_WHITESPACE)
1344
+						) {
1345
+							break;
1346
+						}
1347
+					}
1348
+
1349
+					if ($tokens[$i] === ')') {
1350
+						$parenCount = 1;
1351
+						for ($i--; $i > 0; $i--) {
1352
+							if ($tokens[$i] === '(') {
1353
+								$parenCount--;
1354
+								if ($parenCount === 0) {
1355
+									break;
1356
+								}
1357
+							} else if ($tokens[$i] === ')') {
1358
+								$parenCount++;
1359
+							}
1360
+						}
1361
+
1362
+						// We've found the open parenthesis, so if the previous
1363
+						// non-empty token is FUNCTION or USE, this is a closure.
1364
+						for ($i--; $i > 0; $i--) {
1365
+							if (is_array($tokens[$i]) === false
1366
+								|| ($tokens[$i][0] !== T_DOC_COMMENT
1367
+								&& $tokens[$i][0] !== T_COMMENT
1368
+								&& $tokens[$i][0] !== T_WHITESPACE)
1369
+							) {
1370
+								break;
1371
+							}
1372
+						}
1373
+
1374
+						if ($tokens[$i][0] === T_FUNCTION || $tokens[$i][0] === T_USE) {
1375
+							$isReturnType = true;
1376
+						}
1377
+					}//end if
1378
+
1379
+					if ($isReturnType === false) {
1380
+						array_pop($insideInlineIf);
1381
+						$newToken['code'] = T_INLINE_ELSE;
1382
+						$newToken['type'] = 'T_INLINE_ELSE';
1383
+					}
1384
+				}//end if
1385
+
1386
+				// This is a special condition for T_ARRAY tokens used for
1387
+				// type hinting function arguments as being arrays. We want to keep
1388
+				// the parenthesis map clean, so let's tag these tokens as
1389
+				// T_STRING.
1390
+				if ($newToken['code'] === T_ARRAY) {
1391
+					for ($i = $stackPtr; $i < $numTokens; $i++) {
1392
+						if ($tokens[$i] === '(') {
1393
+							break;
1394
+						} else if ($tokens[$i][0] === T_VARIABLE) {
1395
+							$newToken['code'] = T_STRING;
1396
+							$newToken['type'] = 'T_STRING';
1397
+							break;
1398
+						}
1399
+					}
1400
+				}
1401
+
1402
+				// This is a special case when checking PHP 5.5+ code in PHP < 5.5
1403
+				// where "finally" should be T_FINALLY instead of T_STRING.
1404
+				if ($newToken['code'] === T_STRING
1405
+					&& strtolower($newToken['content']) === 'finally'
1406
+				) {
1407
+					$newToken['code'] = T_FINALLY;
1408
+					$newToken['type'] = 'T_FINALLY';
1409
+				}
1410
+
1411
+				// This is a special case for the PHP 5.5 classname::class syntax
1412
+				// where "class" should be T_STRING instead of T_CLASS.
1413
+				if (($newToken['code'] === T_CLASS
1414
+					|| $newToken['code'] === T_FUNCTION)
1415
+					&& $finalTokens[$lastNotEmptyToken]['code'] === T_DOUBLE_COLON
1416
+				) {
1417
+					$newToken['code'] = T_STRING;
1418
+					$newToken['type'] = 'T_STRING';
1419
+				}
1420
+
1421
+				// This is a special case for PHP 5.6 use function and use const
1422
+				// where "function" and "const" should be T_STRING instead of T_FUNCTION
1423
+				// and T_CONST.
1424
+				if (($newToken['code'] === T_FUNCTION
1425
+					|| $newToken['code'] === T_CONST)
1426
+					&& ($finalTokens[$lastNotEmptyToken]['code'] === T_USE || $insideUseGroup === true)
1427
+				) {
1428
+					$newToken['code'] = T_STRING;
1429
+					$newToken['type'] = 'T_STRING';
1430
+				}
1431
+
1432
+				// This is a special case for use groups in PHP 7+ where leaving
1433
+				// the curly braces as their normal tokens would confuse
1434
+				// the scope map and sniffs.
1435
+				if ($newToken['code'] === T_OPEN_CURLY_BRACKET
1436
+					&& $finalTokens[$lastNotEmptyToken]['code'] === T_NS_SEPARATOR
1437
+				) {
1438
+					$newToken['code'] = T_OPEN_USE_GROUP;
1439
+					$newToken['type'] = 'T_OPEN_USE_GROUP';
1440
+					$insideUseGroup   = true;
1441
+				}
1442
+
1443
+				if ($insideUseGroup === true && $newToken['code'] === T_CLOSE_CURLY_BRACKET) {
1444
+					$newToken['code'] = T_CLOSE_USE_GROUP;
1445
+					$newToken['type'] = 'T_CLOSE_USE_GROUP';
1446
+					$insideUseGroup   = false;
1447
+				}
1448
+
1449
+				$finalTokens[$newStackPtr] = $newToken;
1450
+				$newStackPtr++;
1451
+			}//end if
1452
+		}//end for
1453
+
1454
+		if (PHP_CODESNIFFER_VERBOSITY > 1) {
1455
+			echo "\t*** END PHP TOKENIZING ***".PHP_EOL;
1456
+		}
1457
+
1458
+		return $finalTokens;
1459
+
1460
+	}//end tokenize()
1461
+
1462
+
1463
+	/**
1464
+	 * Performs additional processing after main tokenizing.
1465
+	 *
1466
+	 * This additional processing checks for CASE statements that are using curly
1467
+	 * braces for scope openers and closers. It also turns some T_FUNCTION tokens
1468
+	 * into T_CLOSURE when they are not standard function definitions. It also
1469
+	 * detects short array syntax and converts those square brackets into new tokens.
1470
+	 * It also corrects some usage of the static and class keywords. It also
1471
+	 * assigns tokens to function return types.
1472
+	 *
1473
+	 * @return void
1474
+	 */
1475
+	protected function processAdditional()
1476
+	{
1477
+		if (PHP_CODESNIFFER_VERBOSITY > 1) {
1478
+			echo "\t*** START ADDITIONAL PHP PROCESSING ***".PHP_EOL;
1479
+		}
1480
+
1481
+		$numTokens = count($this->tokens);
1482
+		for ($i = ($numTokens - 1); $i >= 0; $i--) {
1483
+			// Check for any unset scope conditions due to alternate IF/ENDIF syntax.
1484
+			if (isset($this->tokens[$i]['scope_opener']) === true
1485
+				&& isset($this->tokens[$i]['scope_condition']) === false
1486
+			) {
1487
+				$this->tokens[$i]['scope_condition'] = $this->tokens[$this->tokens[$i]['scope_opener']]['scope_condition'];
1488
+			}
1489
+
1490
+			if ($this->tokens[$i]['code'] === T_FUNCTION) {
1491
+				/*
1492 1492
                     Detect functions that are actually closures and
1493 1493
                     assign them a different token.
1494 1494
                 */
1495 1495
 
1496
-                if (isset($this->tokens[$i]['scope_opener']) === true) {
1497
-                    for ($x = ($i + 1); $x < $numTokens; $x++) {
1498
-                        if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false
1499
-                            && $this->tokens[$x]['code'] !== T_BITWISE_AND
1500
-                        ) {
1501
-                            break;
1502
-                        }
1503
-                    }
1504
-
1505
-                    if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) {
1506
-                        $this->tokens[$i]['code'] = T_CLOSURE;
1507
-                        $this->tokens[$i]['type'] = 'T_CLOSURE';
1508
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1509
-                            $line = $this->tokens[$i]['line'];
1510
-                            echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE".PHP_EOL;
1511
-                        }
1512
-
1513
-                        for ($x = ($this->tokens[$i]['scope_opener'] + 1); $x < $this->tokens[$i]['scope_closer']; $x++) {
1514
-                            if (isset($this->tokens[$x]['conditions'][$i]) === false) {
1515
-                                continue;
1516
-                            }
1517
-
1518
-                            $this->tokens[$x]['conditions'][$i] = T_CLOSURE;
1519
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1520
-                                $type = $this->tokens[$x]['type'];
1521
-                                echo "\t\t* cleaned $x ($type) *".PHP_EOL;
1522
-                            }
1523
-                        }
1524
-                    }
1525
-                }//end if
1526
-
1527
-                continue;
1528
-            } else if ($this->tokens[$i]['code'] === T_CLASS && isset($this->tokens[$i]['scope_opener']) === true) {
1529
-                /*
1496
+				if (isset($this->tokens[$i]['scope_opener']) === true) {
1497
+					for ($x = ($i + 1); $x < $numTokens; $x++) {
1498
+						if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false
1499
+							&& $this->tokens[$x]['code'] !== T_BITWISE_AND
1500
+						) {
1501
+							break;
1502
+						}
1503
+					}
1504
+
1505
+					if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) {
1506
+						$this->tokens[$i]['code'] = T_CLOSURE;
1507
+						$this->tokens[$i]['type'] = 'T_CLOSURE';
1508
+						if (PHP_CODESNIFFER_VERBOSITY > 1) {
1509
+							$line = $this->tokens[$i]['line'];
1510
+							echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE".PHP_EOL;
1511
+						}
1512
+
1513
+						for ($x = ($this->tokens[$i]['scope_opener'] + 1); $x < $this->tokens[$i]['scope_closer']; $x++) {
1514
+							if (isset($this->tokens[$x]['conditions'][$i]) === false) {
1515
+								continue;
1516
+							}
1517
+
1518
+							$this->tokens[$x]['conditions'][$i] = T_CLOSURE;
1519
+							if (PHP_CODESNIFFER_VERBOSITY > 1) {
1520
+								$type = $this->tokens[$x]['type'];
1521
+								echo "\t\t* cleaned $x ($type) *".PHP_EOL;
1522
+							}
1523
+						}
1524
+					}
1525
+				}//end if
1526
+
1527
+				continue;
1528
+			} else if ($this->tokens[$i]['code'] === T_CLASS && isset($this->tokens[$i]['scope_opener']) === true) {
1529
+				/*
1530 1530
                     Detect anonymous classes and assign them a different token.
1531 1531
                 */
1532 1532
 
1533
-                for ($x = ($i + 1); $x < $numTokens; $x++) {
1534
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1535
-                        break;
1536
-                    }
1537
-                }
1538
-
1539
-                if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS
1540
-                    || $this->tokens[$x]['code'] === T_OPEN_CURLY_BRACKET
1541
-                    || $this->tokens[$x]['code'] === T_EXTENDS
1542
-                    || $this->tokens[$x]['code'] === T_IMPLEMENTS
1543
-                ) {
1544
-                    $this->tokens[$i]['code'] = T_ANON_CLASS;
1545
-                    $this->tokens[$i]['type'] = 'T_ANON_CLASS';
1546
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1547
-                        $line = $this->tokens[$i]['line'];
1548
-                        echo "\t* token $i on line $line changed from T_CLASS to T_ANON_CLASS".PHP_EOL;
1549
-                    }
1550
-
1551
-                    for ($x = ($this->tokens[$i]['scope_opener'] + 1); $x < $this->tokens[$i]['scope_closer']; $x++) {
1552
-                        if (isset($this->tokens[$x]['conditions'][$i]) === false) {
1553
-                            continue;
1554
-                        }
1555
-
1556
-                        $this->tokens[$x]['conditions'][$i] = T_ANON_CLASS;
1557
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1558
-                            $type = $this->tokens[$x]['type'];
1559
-                            echo "\t\t* cleaned $x ($type) *".PHP_EOL;
1560
-                        }
1561
-                    }
1562
-                }
1563
-
1564
-                continue;
1565
-            } else if ($this->tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) {
1566
-                if (isset($this->tokens[$i]['bracket_closer']) === false) {
1567
-                    continue;
1568
-                }
1569
-
1570
-                // Unless there is a variable or a bracket before this token,
1571
-                // it is the start of an array being defined using the short syntax.
1572
-                $isShortArray = false;
1573
-                $allowed      = [
1574
-                    T_CLOSE_SQUARE_BRACKET     => T_CLOSE_SQUARE_BRACKET,
1575
-                    T_CLOSE_CURLY_BRACKET      => T_CLOSE_CURLY_BRACKET,
1576
-                    T_CLOSE_PARENTHESIS        => T_CLOSE_PARENTHESIS,
1577
-                    T_VARIABLE                 => T_VARIABLE,
1578
-                    T_OBJECT_OPERATOR          => T_OBJECT_OPERATOR,
1579
-                    T_STRING                   => T_STRING,
1580
-                    T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING,
1581
-                ];
1582
-
1583
-                for ($x = ($i - 1); $x >= 0; $x--) {
1584
-                    // If we hit a scope opener, the statement has ended
1585
-                    // without finding anything, so it's probably an array
1586
-                    // using PHP 7.1 short list syntax.
1587
-                    if (isset($this->tokens[$x]['scope_opener']) === true) {
1588
-                        $isShortArray = true;
1589
-                        break;
1590
-                    }
1591
-
1592
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1593
-                        if (isset($allowed[$this->tokens[$x]['code']]) === false) {
1594
-                            $isShortArray = true;
1595
-                        }
1596
-
1597
-                        break;
1598
-                    }
1599
-                }
1600
-
1601
-                if ($isShortArray === true) {
1602
-                    $this->tokens[$i]['code'] = T_OPEN_SHORT_ARRAY;
1603
-                    $this->tokens[$i]['type'] = 'T_OPEN_SHORT_ARRAY';
1604
-
1605
-                    $closer = $this->tokens[$i]['bracket_closer'];
1606
-                    $this->tokens[$closer]['code'] = T_CLOSE_SHORT_ARRAY;
1607
-                    $this->tokens[$closer]['type'] = 'T_CLOSE_SHORT_ARRAY';
1608
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1609
-                        $line = $this->tokens[$i]['line'];
1610
-                        echo "\t* token $i on line $line changed from T_OPEN_SQUARE_BRACKET to T_OPEN_SHORT_ARRAY".PHP_EOL;
1611
-                        $line = $this->tokens[$closer]['line'];
1612
-                        echo "\t* token $closer on line $line changed from T_CLOSE_SQUARE_BRACKET to T_CLOSE_SHORT_ARRAY".PHP_EOL;
1613
-                    }
1614
-                }
1615
-
1616
-                continue;
1617
-            } else if ($this->tokens[$i]['code'] === T_STATIC) {
1618
-                for ($x = ($i - 1); $x > 0; $x--) {
1619
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1620
-                        break;
1621
-                    }
1622
-                }
1623
-
1624
-                if ($this->tokens[$x]['code'] === T_INSTANCEOF) {
1625
-                    $this->tokens[$i]['code'] = T_STRING;
1626
-                    $this->tokens[$i]['type'] = 'T_STRING';
1627
-
1628
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1629
-                        $line = $this->tokens[$i]['line'];
1630
-                        echo "\t* token $i on line $line changed from T_STATIC to T_STRING".PHP_EOL;
1631
-                    }
1632
-                }
1633
-
1634
-                continue;
1635
-            } else if ($this->tokens[$i]['code'] === T_TRUE
1636
-                || $this->tokens[$i]['code'] === T_FALSE
1637
-                || $this->tokens[$i]['code'] === T_NULL
1638
-            ) {
1639
-                for ($x = ($i + 1); $i < $numTokens; $x++) {
1640
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1641
-                        // Non-whitespace content.
1642
-                        break;
1643
-                    }
1644
-                }
1645
-
1646
-                $context = [
1647
-                    T_OBJECT_OPERATOR      => true,
1648
-                    T_NS_SEPARATOR         => true,
1649
-                    T_PAAMAYIM_NEKUDOTAYIM => true,
1650
-                ];
1651
-                if (isset($context[$this->tokens[$x]['code']]) === true) {
1652
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1653
-                        $line = $this->tokens[$i]['line'];
1654
-                        $type = $this->tokens[$i]['type'];
1655
-                        echo "\t* token $i on line $line changed from $type to T_STRING".PHP_EOL;
1656
-                    }
1657
-
1658
-                    $this->tokens[$i]['code'] = T_STRING;
1659
-                    $this->tokens[$i]['type'] = 'T_STRING';
1660
-                }
1661
-            } else if ($this->tokens[$i]['code'] === T_CONST) {
1662
-                // Context sensitive keywords support.
1663
-                for ($x = ($i + 1); $i < $numTokens; $x++) {
1664
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1665
-                        // Non-whitespace content.
1666
-                        break;
1667
-                    }
1668
-                }
1669
-
1670
-                if ($this->tokens[$x]['code'] !== T_STRING) {
1671
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1672
-                        $line = $this->tokens[$x]['line'];
1673
-                        $type = $this->tokens[$x]['type'];
1674
-                        echo "\t* token $x on line $line changed from $type to T_STRING".PHP_EOL;
1675
-                    }
1676
-
1677
-                    $this->tokens[$x]['code'] = T_STRING;
1678
-                    $this->tokens[$x]['type'] = 'T_STRING';
1679
-                }
1680
-            }//end if
1681
-
1682
-            if (($this->tokens[$i]['code'] !== T_CASE
1683
-                && $this->tokens[$i]['code'] !== T_DEFAULT)
1684
-                || isset($this->tokens[$i]['scope_opener']) === false
1685
-            ) {
1686
-                // Only interested in CASE and DEFAULT statements from here on in.
1687
-                continue;
1688
-            }
1689
-
1690
-            $scopeOpener = $this->tokens[$i]['scope_opener'];
1691
-            $scopeCloser = $this->tokens[$i]['scope_closer'];
1692
-
1693
-            // If the first char after the opener is a curly brace
1694
-            // and that brace has been ignored, it is actually
1695
-            // opening this case statement and the opener and closer are
1696
-            // probably set incorrectly.
1697
-            for ($x = ($scopeOpener + 1); $x < $numTokens; $x++) {
1698
-                if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1699
-                    // Non-whitespace content.
1700
-                    break;
1701
-                }
1702
-            }
1703
-
1704
-            if ($this->tokens[$x]['code'] === T_CASE || $this->tokens[$x]['code'] === T_DEFAULT) {
1705
-                // Special case for multiple CASE statements that share the same
1706
-                // closer. Because we are going backwards through the file, this next
1707
-                // CASE statement is already fixed, so just use its closer and don't
1708
-                // worry about fixing anything.
1709
-                $newCloser = $this->tokens[$x]['scope_closer'];
1710
-                $this->tokens[$i]['scope_closer'] = $newCloser;
1711
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1712
-                    $oldType = $this->tokens[$scopeCloser]['type'];
1713
-                    $newType = $this->tokens[$newCloser]['type'];
1714
-                    $line    = $this->tokens[$i]['line'];
1715
-                    echo "\t* token $i (T_CASE) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
1716
-                }
1717
-
1718
-                continue;
1719
-            }
1720
-
1721
-            if ($this->tokens[$x]['code'] !== T_OPEN_CURLY_BRACKET
1722
-                || isset($this->tokens[$x]['scope_condition']) === true
1723
-            ) {
1724
-                // Not a CASE/DEFAULT with a curly brace opener.
1725
-                continue;
1726
-            }
1727
-
1728
-            // The closer for this CASE/DEFAULT should be the closing curly brace and
1729
-            // not whatever it already is. The opener needs to be the opening curly
1730
-            // brace so everything matches up.
1731
-            $newCloser = $this->tokens[$x]['bracket_closer'];
1732
-            foreach ([$i, $x, $newCloser] as $index) {
1733
-                $this->tokens[$index]['scope_condition'] = $i;
1734
-                $this->tokens[$index]['scope_opener']    = $x;
1735
-                $this->tokens[$index]['scope_closer']    = $newCloser;
1736
-            }
1737
-
1738
-            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1739
-                $line      = $this->tokens[$i]['line'];
1740
-                $tokenType = $this->tokens[$i]['type'];
1741
-
1742
-                $oldType = $this->tokens[$scopeOpener]['type'];
1743
-                $newType = $this->tokens[$x]['type'];
1744
-                echo "\t* token $i ($tokenType) on line $line opener changed from $scopeOpener ($oldType) to $x ($newType)".PHP_EOL;
1745
-
1746
-                $oldType = $this->tokens[$scopeCloser]['type'];
1747
-                $newType = $this->tokens[$newCloser]['type'];
1748
-                echo "\t* token $i ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
1749
-            }
1750
-
1751
-            if ($this->tokens[$scopeOpener]['scope_condition'] === $i) {
1752
-                unset($this->tokens[$scopeOpener]['scope_condition']);
1753
-                unset($this->tokens[$scopeOpener]['scope_opener']);
1754
-                unset($this->tokens[$scopeOpener]['scope_closer']);
1755
-            }
1756
-
1757
-            if ($this->tokens[$scopeCloser]['scope_condition'] === $i) {
1758
-                unset($this->tokens[$scopeCloser]['scope_condition']);
1759
-                unset($this->tokens[$scopeCloser]['scope_opener']);
1760
-                unset($this->tokens[$scopeCloser]['scope_closer']);
1761
-            } else {
1762
-                // We were using a shared closer. All tokens that were
1763
-                // sharing this closer with us, except for the scope condition
1764
-                // and it's opener, need to now point to the new closer.
1765
-                $condition = $this->tokens[$scopeCloser]['scope_condition'];
1766
-                $start     = ($this->tokens[$condition]['scope_opener'] + 1);
1767
-                for ($y = $start; $y < $scopeCloser; $y++) {
1768
-                    if (isset($this->tokens[$y]['scope_closer']) === true
1769
-                        && $this->tokens[$y]['scope_closer'] === $scopeCloser
1770
-                    ) {
1771
-                        $this->tokens[$y]['scope_closer'] = $newCloser;
1772
-
1773
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1774
-                            $line      = $this->tokens[$y]['line'];
1775
-                            $tokenType = $this->tokens[$y]['type'];
1776
-                            $oldType   = $this->tokens[$scopeCloser]['type'];
1777
-                            $newType   = $this->tokens[$newCloser]['type'];
1778
-                            echo "\t\t* token $y ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
1779
-                        }
1780
-                    }
1781
-                }
1782
-            }//end if
1783
-
1784
-            unset($this->tokens[$x]['bracket_opener']);
1785
-            unset($this->tokens[$x]['bracket_closer']);
1786
-            unset($this->tokens[$newCloser]['bracket_opener']);
1787
-            unset($this->tokens[$newCloser]['bracket_closer']);
1788
-            $this->tokens[$scopeCloser]['conditions'][] = $i;
1789
-
1790
-            // Now fix up all the tokens that think they are
1791
-            // inside the CASE/DEFAULT statement when they are really outside.
1792
-            for ($x = $newCloser; $x < $scopeCloser; $x++) {
1793
-                foreach ($this->tokens[$x]['conditions'] as $num => $oldCond) {
1794
-                    if ($oldCond === $this->tokens[$i]['code']) {
1795
-                        $oldConditions = $this->tokens[$x]['conditions'];
1796
-                        unset($this->tokens[$x]['conditions'][$num]);
1797
-
1798
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1799
-                            $type     = $this->tokens[$x]['type'];
1800
-                            $oldConds = '';
1801
-                            foreach ($oldConditions as $condition) {
1802
-                                $oldConds .= Util\Tokens::tokenName($condition).',';
1803
-                            }
1804
-
1805
-                            $oldConds = rtrim($oldConds, ',');
1806
-
1807
-                            $newConds = '';
1808
-                            foreach ($this->tokens[$x]['conditions'] as $condition) {
1809
-                                $newConds .= Util\Tokens::tokenName($condition).',';
1810
-                            }
1811
-
1812
-                            $newConds = rtrim($newConds, ',');
1813
-
1814
-                            echo "\t\t* cleaned $x ($type) *".PHP_EOL;
1815
-                            echo "\t\t\t=> conditions changed from $oldConds to $newConds".PHP_EOL;
1816
-                        }
1817
-
1818
-                        break;
1819
-                    }//end if
1820
-                }//end foreach
1821
-            }//end for
1822
-        }//end for
1823
-
1824
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1825
-            echo "\t*** END ADDITIONAL PHP PROCESSING ***".PHP_EOL;
1826
-        }
1827
-
1828
-    }//end processAdditional()
1829
-
1830
-
1831
-    /**
1832
-     * Takes a token produced from <code>token_get_all()</code> and produces a
1833
-     * more uniform token.
1834
-     *
1835
-     * @param string|array $token The token to convert.
1836
-     *
1837
-     * @return array The new token.
1838
-     */
1839
-    public static function standardiseToken($token)
1840
-    {
1841
-        if (isset($token[1]) === false) {
1842
-            if (isset(self::$resolveTokenCache[$token[0]]) === true) {
1843
-                return self::$resolveTokenCache[$token[0]];
1844
-            }
1845
-        } else {
1846
-            $cacheKey = null;
1847
-            if ($token[0] === T_STRING) {
1848
-                $cacheKey = strtolower($token[1]);
1849
-            } else if ($token[0] !== T_CURLY_OPEN) {
1850
-                $cacheKey = $token[0];
1851
-            }
1852
-
1853
-            if ($cacheKey !== null && isset(self::$resolveTokenCache[$cacheKey]) === true) {
1854
-                $newToken            = self::$resolveTokenCache[$cacheKey];
1855
-                $newToken['content'] = $token[1];
1856
-                return $newToken;
1857
-            }
1858
-        }
1859
-
1860
-        if (isset($token[1]) === false) {
1861
-            return self::resolveSimpleToken($token[0]);
1862
-        }
1863
-
1864
-        if ($token[0] === T_STRING) {
1865
-            switch ($cacheKey) {
1866
-            case 'false':
1867
-                $newToken['type'] = 'T_FALSE';
1868
-                break;
1869
-            case 'true':
1870
-                $newToken['type'] = 'T_TRUE';
1871
-                break;
1872
-            case 'null':
1873
-                $newToken['type'] = 'T_NULL';
1874
-                break;
1875
-            case 'self':
1876
-                $newToken['type'] = 'T_SELF';
1877
-                break;
1878
-            case 'parent':
1879
-                $newToken['type'] = 'T_PARENT';
1880
-                break;
1881
-            default:
1882
-                $newToken['type'] = 'T_STRING';
1883
-                break;
1884
-            }
1885
-
1886
-            $newToken['code'] = constant($newToken['type']);
1887
-
1888
-            self::$resolveTokenCache[$cacheKey] = $newToken;
1889
-        } else if ($token[0] === T_CURLY_OPEN) {
1890
-            $newToken = [
1891
-                'code' => T_OPEN_CURLY_BRACKET,
1892
-                'type' => 'T_OPEN_CURLY_BRACKET',
1893
-            ];
1894
-        } else {
1895
-            $newToken = [
1896
-                'code' => $token[0],
1897
-                'type' => Util\Tokens::tokenName($token[0]),
1898
-            ];
1899
-
1900
-            self::$resolveTokenCache[$token[0]] = $newToken;
1901
-        }//end if
1902
-
1903
-        $newToken['content'] = $token[1];
1904
-        return $newToken;
1905
-
1906
-    }//end standardiseToken()
1907
-
1908
-
1909
-    /**
1910
-     * Converts simple tokens into a format that conforms to complex tokens
1911
-     * produced by token_get_all().
1912
-     *
1913
-     * Simple tokens are tokens that are not in array form when produced from
1914
-     * token_get_all().
1915
-     *
1916
-     * @param string $token The simple token to convert.
1917
-     *
1918
-     * @return array The new token in array format.
1919
-     */
1920
-    public static function resolveSimpleToken($token)
1921
-    {
1922
-        $newToken = [];
1923
-
1924
-        switch ($token) {
1925
-        case '{':
1926
-            $newToken['type'] = 'T_OPEN_CURLY_BRACKET';
1927
-            break;
1928
-        case '}':
1929
-            $newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
1930
-            break;
1931
-        case '[':
1932
-            $newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
1933
-            break;
1934
-        case ']':
1935
-            $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
1936
-            break;
1937
-        case '(':
1938
-            $newToken['type'] = 'T_OPEN_PARENTHESIS';
1939
-            break;
1940
-        case ')':
1941
-            $newToken['type'] = 'T_CLOSE_PARENTHESIS';
1942
-            break;
1943
-        case ':':
1944
-            $newToken['type'] = 'T_COLON';
1945
-            break;
1946
-        case '.':
1947
-            $newToken['type'] = 'T_STRING_CONCAT';
1948
-            break;
1949
-        case ';':
1950
-            $newToken['type'] = 'T_SEMICOLON';
1951
-            break;
1952
-        case '=':
1953
-            $newToken['type'] = 'T_EQUAL';
1954
-            break;
1955
-        case '*':
1956
-            $newToken['type'] = 'T_MULTIPLY';
1957
-            break;
1958
-        case '/':
1959
-            $newToken['type'] = 'T_DIVIDE';
1960
-            break;
1961
-        case '+':
1962
-            $newToken['type'] = 'T_PLUS';
1963
-            break;
1964
-        case '-':
1965
-            $newToken['type'] = 'T_MINUS';
1966
-            break;
1967
-        case '%':
1968
-            $newToken['type'] = 'T_MODULUS';
1969
-            break;
1970
-        case '^':
1971
-            $newToken['type'] = 'T_BITWISE_XOR';
1972
-            break;
1973
-        case '&':
1974
-            $newToken['type'] = 'T_BITWISE_AND';
1975
-            break;
1976
-        case '|':
1977
-            $newToken['type'] = 'T_BITWISE_OR';
1978
-            break;
1979
-        case '~':
1980
-            $newToken['type'] = 'T_BITWISE_NOT';
1981
-            break;
1982
-        case '<':
1983
-            $newToken['type'] = 'T_LESS_THAN';
1984
-            break;
1985
-        case '>':
1986
-            $newToken['type'] = 'T_GREATER_THAN';
1987
-            break;
1988
-        case '!':
1989
-            $newToken['type'] = 'T_BOOLEAN_NOT';
1990
-            break;
1991
-        case ',':
1992
-            $newToken['type'] = 'T_COMMA';
1993
-            break;
1994
-        case '@':
1995
-            $newToken['type'] = 'T_ASPERAND';
1996
-            break;
1997
-        case '$':
1998
-            $newToken['type'] = 'T_DOLLAR';
1999
-            break;
2000
-        case '`':
2001
-            $newToken['type'] = 'T_BACKTICK';
2002
-            break;
2003
-        default:
2004
-            $newToken['type'] = 'T_NONE';
2005
-            break;
2006
-        }//end switch
2007
-
2008
-        $newToken['code']    = constant($newToken['type']);
2009
-        $newToken['content'] = $token;
2010
-
2011
-        self::$resolveTokenCache[$token] = $newToken;
2012
-        return $newToken;
2013
-
2014
-    }//end resolveSimpleToken()
1533
+				for ($x = ($i + 1); $x < $numTokens; $x++) {
1534
+					if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1535
+						break;
1536
+					}
1537
+				}
1538
+
1539
+				if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS
1540
+					|| $this->tokens[$x]['code'] === T_OPEN_CURLY_BRACKET
1541
+					|| $this->tokens[$x]['code'] === T_EXTENDS
1542
+					|| $this->tokens[$x]['code'] === T_IMPLEMENTS
1543
+				) {
1544
+					$this->tokens[$i]['code'] = T_ANON_CLASS;
1545
+					$this->tokens[$i]['type'] = 'T_ANON_CLASS';
1546
+					if (PHP_CODESNIFFER_VERBOSITY > 1) {
1547
+						$line = $this->tokens[$i]['line'];
1548
+						echo "\t* token $i on line $line changed from T_CLASS to T_ANON_CLASS".PHP_EOL;
1549
+					}
1550
+
1551
+					for ($x = ($this->tokens[$i]['scope_opener'] + 1); $x < $this->tokens[$i]['scope_closer']; $x++) {
1552
+						if (isset($this->tokens[$x]['conditions'][$i]) === false) {
1553
+							continue;
1554
+						}
1555
+
1556
+						$this->tokens[$x]['conditions'][$i] = T_ANON_CLASS;
1557
+						if (PHP_CODESNIFFER_VERBOSITY > 1) {
1558
+							$type = $this->tokens[$x]['type'];
1559
+							echo "\t\t* cleaned $x ($type) *".PHP_EOL;
1560
+						}
1561
+					}
1562
+				}
1563
+
1564
+				continue;
1565
+			} else if ($this->tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) {
1566
+				if (isset($this->tokens[$i]['bracket_closer']) === false) {
1567
+					continue;
1568
+				}
1569
+
1570
+				// Unless there is a variable or a bracket before this token,
1571
+				// it is the start of an array being defined using the short syntax.
1572
+				$isShortArray = false;
1573
+				$allowed      = [
1574
+					T_CLOSE_SQUARE_BRACKET     => T_CLOSE_SQUARE_BRACKET,
1575
+					T_CLOSE_CURLY_BRACKET      => T_CLOSE_CURLY_BRACKET,
1576
+					T_CLOSE_PARENTHESIS        => T_CLOSE_PARENTHESIS,
1577
+					T_VARIABLE                 => T_VARIABLE,
1578
+					T_OBJECT_OPERATOR          => T_OBJECT_OPERATOR,
1579
+					T_STRING                   => T_STRING,
1580
+					T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING,
1581
+				];
1582
+
1583
+				for ($x = ($i - 1); $x >= 0; $x--) {
1584
+					// If we hit a scope opener, the statement has ended
1585
+					// without finding anything, so it's probably an array
1586
+					// using PHP 7.1 short list syntax.
1587
+					if (isset($this->tokens[$x]['scope_opener']) === true) {
1588
+						$isShortArray = true;
1589
+						break;
1590
+					}
1591
+
1592
+					if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1593
+						if (isset($allowed[$this->tokens[$x]['code']]) === false) {
1594
+							$isShortArray = true;
1595
+						}
1596
+
1597
+						break;
1598
+					}
1599
+				}
1600
+
1601
+				if ($isShortArray === true) {
1602
+					$this->tokens[$i]['code'] = T_OPEN_SHORT_ARRAY;
1603
+					$this->tokens[$i]['type'] = 'T_OPEN_SHORT_ARRAY';
1604
+
1605
+					$closer = $this->tokens[$i]['bracket_closer'];
1606
+					$this->tokens[$closer]['code'] = T_CLOSE_SHORT_ARRAY;
1607
+					$this->tokens[$closer]['type'] = 'T_CLOSE_SHORT_ARRAY';
1608
+					if (PHP_CODESNIFFER_VERBOSITY > 1) {
1609
+						$line = $this->tokens[$i]['line'];
1610
+						echo "\t* token $i on line $line changed from T_OPEN_SQUARE_BRACKET to T_OPEN_SHORT_ARRAY".PHP_EOL;
1611
+						$line = $this->tokens[$closer]['line'];
1612
+						echo "\t* token $closer on line $line changed from T_CLOSE_SQUARE_BRACKET to T_CLOSE_SHORT_ARRAY".PHP_EOL;
1613
+					}
1614
+				}
1615
+
1616
+				continue;
1617
+			} else if ($this->tokens[$i]['code'] === T_STATIC) {
1618
+				for ($x = ($i - 1); $x > 0; $x--) {
1619
+					if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1620
+						break;
1621
+					}
1622
+				}
1623
+
1624
+				if ($this->tokens[$x]['code'] === T_INSTANCEOF) {
1625
+					$this->tokens[$i]['code'] = T_STRING;
1626
+					$this->tokens[$i]['type'] = 'T_STRING';
1627
+
1628
+					if (PHP_CODESNIFFER_VERBOSITY > 1) {
1629
+						$line = $this->tokens[$i]['line'];
1630
+						echo "\t* token $i on line $line changed from T_STATIC to T_STRING".PHP_EOL;
1631
+					}
1632
+				}
1633
+
1634
+				continue;
1635
+			} else if ($this->tokens[$i]['code'] === T_TRUE
1636
+				|| $this->tokens[$i]['code'] === T_FALSE
1637
+				|| $this->tokens[$i]['code'] === T_NULL
1638
+			) {
1639
+				for ($x = ($i + 1); $i < $numTokens; $x++) {
1640
+					if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1641
+						// Non-whitespace content.
1642
+						break;
1643
+					}
1644
+				}
1645
+
1646
+				$context = [
1647
+					T_OBJECT_OPERATOR      => true,
1648
+					T_NS_SEPARATOR         => true,
1649
+					T_PAAMAYIM_NEKUDOTAYIM => true,
1650
+				];
1651
+				if (isset($context[$this->tokens[$x]['code']]) === true) {
1652
+					if (PHP_CODESNIFFER_VERBOSITY > 1) {
1653
+						$line = $this->tokens[$i]['line'];
1654
+						$type = $this->tokens[$i]['type'];
1655
+						echo "\t* token $i on line $line changed from $type to T_STRING".PHP_EOL;
1656
+					}
1657
+
1658
+					$this->tokens[$i]['code'] = T_STRING;
1659
+					$this->tokens[$i]['type'] = 'T_STRING';
1660
+				}
1661
+			} else if ($this->tokens[$i]['code'] === T_CONST) {
1662
+				// Context sensitive keywords support.
1663
+				for ($x = ($i + 1); $i < $numTokens; $x++) {
1664
+					if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1665
+						// Non-whitespace content.
1666
+						break;
1667
+					}
1668
+				}
1669
+
1670
+				if ($this->tokens[$x]['code'] !== T_STRING) {
1671
+					if (PHP_CODESNIFFER_VERBOSITY > 1) {
1672
+						$line = $this->tokens[$x]['line'];
1673
+						$type = $this->tokens[$x]['type'];
1674
+						echo "\t* token $x on line $line changed from $type to T_STRING".PHP_EOL;
1675
+					}
1676
+
1677
+					$this->tokens[$x]['code'] = T_STRING;
1678
+					$this->tokens[$x]['type'] = 'T_STRING';
1679
+				}
1680
+			}//end if
1681
+
1682
+			if (($this->tokens[$i]['code'] !== T_CASE
1683
+				&& $this->tokens[$i]['code'] !== T_DEFAULT)
1684
+				|| isset($this->tokens[$i]['scope_opener']) === false
1685
+			) {
1686
+				// Only interested in CASE and DEFAULT statements from here on in.
1687
+				continue;
1688
+			}
1689
+
1690
+			$scopeOpener = $this->tokens[$i]['scope_opener'];
1691
+			$scopeCloser = $this->tokens[$i]['scope_closer'];
1692
+
1693
+			// If the first char after the opener is a curly brace
1694
+			// and that brace has been ignored, it is actually
1695
+			// opening this case statement and the opener and closer are
1696
+			// probably set incorrectly.
1697
+			for ($x = ($scopeOpener + 1); $x < $numTokens; $x++) {
1698
+				if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1699
+					// Non-whitespace content.
1700
+					break;
1701
+				}
1702
+			}
1703
+
1704
+			if ($this->tokens[$x]['code'] === T_CASE || $this->tokens[$x]['code'] === T_DEFAULT) {
1705
+				// Special case for multiple CASE statements that share the same
1706
+				// closer. Because we are going backwards through the file, this next
1707
+				// CASE statement is already fixed, so just use its closer and don't
1708
+				// worry about fixing anything.
1709
+				$newCloser = $this->tokens[$x]['scope_closer'];
1710
+				$this->tokens[$i]['scope_closer'] = $newCloser;
1711
+				if (PHP_CODESNIFFER_VERBOSITY > 1) {
1712
+					$oldType = $this->tokens[$scopeCloser]['type'];
1713
+					$newType = $this->tokens[$newCloser]['type'];
1714
+					$line    = $this->tokens[$i]['line'];
1715
+					echo "\t* token $i (T_CASE) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
1716
+				}
1717
+
1718
+				continue;
1719
+			}
1720
+
1721
+			if ($this->tokens[$x]['code'] !== T_OPEN_CURLY_BRACKET
1722
+				|| isset($this->tokens[$x]['scope_condition']) === true
1723
+			) {
1724
+				// Not a CASE/DEFAULT with a curly brace opener.
1725
+				continue;
1726
+			}
1727
+
1728
+			// The closer for this CASE/DEFAULT should be the closing curly brace and
1729
+			// not whatever it already is. The opener needs to be the opening curly
1730
+			// brace so everything matches up.
1731
+			$newCloser = $this->tokens[$x]['bracket_closer'];
1732
+			foreach ([$i, $x, $newCloser] as $index) {
1733
+				$this->tokens[$index]['scope_condition'] = $i;
1734
+				$this->tokens[$index]['scope_opener']    = $x;
1735
+				$this->tokens[$index]['scope_closer']    = $newCloser;
1736
+			}
1737
+
1738
+			if (PHP_CODESNIFFER_VERBOSITY > 1) {
1739
+				$line      = $this->tokens[$i]['line'];
1740
+				$tokenType = $this->tokens[$i]['type'];
1741
+
1742
+				$oldType = $this->tokens[$scopeOpener]['type'];
1743
+				$newType = $this->tokens[$x]['type'];
1744
+				echo "\t* token $i ($tokenType) on line $line opener changed from $scopeOpener ($oldType) to $x ($newType)".PHP_EOL;
1745
+
1746
+				$oldType = $this->tokens[$scopeCloser]['type'];
1747
+				$newType = $this->tokens[$newCloser]['type'];
1748
+				echo "\t* token $i ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
1749
+			}
1750
+
1751
+			if ($this->tokens[$scopeOpener]['scope_condition'] === $i) {
1752
+				unset($this->tokens[$scopeOpener]['scope_condition']);
1753
+				unset($this->tokens[$scopeOpener]['scope_opener']);
1754
+				unset($this->tokens[$scopeOpener]['scope_closer']);
1755
+			}
1756
+
1757
+			if ($this->tokens[$scopeCloser]['scope_condition'] === $i) {
1758
+				unset($this->tokens[$scopeCloser]['scope_condition']);
1759
+				unset($this->tokens[$scopeCloser]['scope_opener']);
1760
+				unset($this->tokens[$scopeCloser]['scope_closer']);
1761
+			} else {
1762
+				// We were using a shared closer. All tokens that were
1763
+				// sharing this closer with us, except for the scope condition
1764
+				// and it's opener, need to now point to the new closer.
1765
+				$condition = $this->tokens[$scopeCloser]['scope_condition'];
1766
+				$start     = ($this->tokens[$condition]['scope_opener'] + 1);
1767
+				for ($y = $start; $y < $scopeCloser; $y++) {
1768
+					if (isset($this->tokens[$y]['scope_closer']) === true
1769
+						&& $this->tokens[$y]['scope_closer'] === $scopeCloser
1770
+					) {
1771
+						$this->tokens[$y]['scope_closer'] = $newCloser;
1772
+
1773
+						if (PHP_CODESNIFFER_VERBOSITY > 1) {
1774
+							$line      = $this->tokens[$y]['line'];
1775
+							$tokenType = $this->tokens[$y]['type'];
1776
+							$oldType   = $this->tokens[$scopeCloser]['type'];
1777
+							$newType   = $this->tokens[$newCloser]['type'];
1778
+							echo "\t\t* token $y ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
1779
+						}
1780
+					}
1781
+				}
1782
+			}//end if
1783
+
1784
+			unset($this->tokens[$x]['bracket_opener']);
1785
+			unset($this->tokens[$x]['bracket_closer']);
1786
+			unset($this->tokens[$newCloser]['bracket_opener']);
1787
+			unset($this->tokens[$newCloser]['bracket_closer']);
1788
+			$this->tokens[$scopeCloser]['conditions'][] = $i;
1789
+
1790
+			// Now fix up all the tokens that think they are
1791
+			// inside the CASE/DEFAULT statement when they are really outside.
1792
+			for ($x = $newCloser; $x < $scopeCloser; $x++) {
1793
+				foreach ($this->tokens[$x]['conditions'] as $num => $oldCond) {
1794
+					if ($oldCond === $this->tokens[$i]['code']) {
1795
+						$oldConditions = $this->tokens[$x]['conditions'];
1796
+						unset($this->tokens[$x]['conditions'][$num]);
1797
+
1798
+						if (PHP_CODESNIFFER_VERBOSITY > 1) {
1799
+							$type     = $this->tokens[$x]['type'];
1800
+							$oldConds = '';
1801
+							foreach ($oldConditions as $condition) {
1802
+								$oldConds .= Util\Tokens::tokenName($condition).',';
1803
+							}
1804
+
1805
+							$oldConds = rtrim($oldConds, ',');
1806
+
1807
+							$newConds = '';
1808
+							foreach ($this->tokens[$x]['conditions'] as $condition) {
1809
+								$newConds .= Util\Tokens::tokenName($condition).',';
1810
+							}
1811
+
1812
+							$newConds = rtrim($newConds, ',');
1813
+
1814
+							echo "\t\t* cleaned $x ($type) *".PHP_EOL;
1815
+							echo "\t\t\t=> conditions changed from $oldConds to $newConds".PHP_EOL;
1816
+						}
1817
+
1818
+						break;
1819
+					}//end if
1820
+				}//end foreach
1821
+			}//end for
1822
+		}//end for
1823
+
1824
+		if (PHP_CODESNIFFER_VERBOSITY > 1) {
1825
+			echo "\t*** END ADDITIONAL PHP PROCESSING ***".PHP_EOL;
1826
+		}
1827
+
1828
+	}//end processAdditional()
1829
+
1830
+
1831
+	/**
1832
+	 * Takes a token produced from <code>token_get_all()</code> and produces a
1833
+	 * more uniform token.
1834
+	 *
1835
+	 * @param string|array $token The token to convert.
1836
+	 *
1837
+	 * @return array The new token.
1838
+	 */
1839
+	public static function standardiseToken($token)
1840
+	{
1841
+		if (isset($token[1]) === false) {
1842
+			if (isset(self::$resolveTokenCache[$token[0]]) === true) {
1843
+				return self::$resolveTokenCache[$token[0]];
1844
+			}
1845
+		} else {
1846
+			$cacheKey = null;
1847
+			if ($token[0] === T_STRING) {
1848
+				$cacheKey = strtolower($token[1]);
1849
+			} else if ($token[0] !== T_CURLY_OPEN) {
1850
+				$cacheKey = $token[0];
1851
+			}
1852
+
1853
+			if ($cacheKey !== null && isset(self::$resolveTokenCache[$cacheKey]) === true) {
1854
+				$newToken            = self::$resolveTokenCache[$cacheKey];
1855
+				$newToken['content'] = $token[1];
1856
+				return $newToken;
1857
+			}
1858
+		}
1859
+
1860
+		if (isset($token[1]) === false) {
1861
+			return self::resolveSimpleToken($token[0]);
1862
+		}
1863
+
1864
+		if ($token[0] === T_STRING) {
1865
+			switch ($cacheKey) {
1866
+			case 'false':
1867
+				$newToken['type'] = 'T_FALSE';
1868
+				break;
1869
+			case 'true':
1870
+				$newToken['type'] = 'T_TRUE';
1871
+				break;
1872
+			case 'null':
1873
+				$newToken['type'] = 'T_NULL';
1874
+				break;
1875
+			case 'self':
1876
+				$newToken['type'] = 'T_SELF';
1877
+				break;
1878
+			case 'parent':
1879
+				$newToken['type'] = 'T_PARENT';
1880
+				break;
1881
+			default:
1882
+				$newToken['type'] = 'T_STRING';
1883
+				break;
1884
+			}
1885
+
1886
+			$newToken['code'] = constant($newToken['type']);
1887
+
1888
+			self::$resolveTokenCache[$cacheKey] = $newToken;
1889
+		} else if ($token[0] === T_CURLY_OPEN) {
1890
+			$newToken = [
1891
+				'code' => T_OPEN_CURLY_BRACKET,
1892
+				'type' => 'T_OPEN_CURLY_BRACKET',
1893
+			];
1894
+		} else {
1895
+			$newToken = [
1896
+				'code' => $token[0],
1897
+				'type' => Util\Tokens::tokenName($token[0]),
1898
+			];
1899
+
1900
+			self::$resolveTokenCache[$token[0]] = $newToken;
1901
+		}//end if
1902
+
1903
+		$newToken['content'] = $token[1];
1904
+		return $newToken;
1905
+
1906
+	}//end standardiseToken()
1907
+
1908
+
1909
+	/**
1910
+	 * Converts simple tokens into a format that conforms to complex tokens
1911
+	 * produced by token_get_all().
1912
+	 *
1913
+	 * Simple tokens are tokens that are not in array form when produced from
1914
+	 * token_get_all().
1915
+	 *
1916
+	 * @param string $token The simple token to convert.
1917
+	 *
1918
+	 * @return array The new token in array format.
1919
+	 */
1920
+	public static function resolveSimpleToken($token)
1921
+	{
1922
+		$newToken = [];
1923
+
1924
+		switch ($token) {
1925
+		case '{':
1926
+			$newToken['type'] = 'T_OPEN_CURLY_BRACKET';
1927
+			break;
1928
+		case '}':
1929
+			$newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
1930
+			break;
1931
+		case '[':
1932
+			$newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
1933
+			break;
1934
+		case ']':
1935
+			$newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
1936
+			break;
1937
+		case '(':
1938
+			$newToken['type'] = 'T_OPEN_PARENTHESIS';
1939
+			break;
1940
+		case ')':
1941
+			$newToken['type'] = 'T_CLOSE_PARENTHESIS';
1942
+			break;
1943
+		case ':':
1944
+			$newToken['type'] = 'T_COLON';
1945
+			break;
1946
+		case '.':
1947
+			$newToken['type'] = 'T_STRING_CONCAT';
1948
+			break;
1949
+		case ';':
1950
+			$newToken['type'] = 'T_SEMICOLON';
1951
+			break;
1952
+		case '=':
1953
+			$newToken['type'] = 'T_EQUAL';
1954
+			break;
1955
+		case '*':
1956
+			$newToken['type'] = 'T_MULTIPLY';
1957
+			break;
1958
+		case '/':
1959
+			$newToken['type'] = 'T_DIVIDE';
1960
+			break;
1961
+		case '+':
1962
+			$newToken['type'] = 'T_PLUS';
1963
+			break;
1964
+		case '-':
1965
+			$newToken['type'] = 'T_MINUS';
1966
+			break;
1967
+		case '%':
1968
+			$newToken['type'] = 'T_MODULUS';
1969
+			break;
1970
+		case '^':
1971
+			$newToken['type'] = 'T_BITWISE_XOR';
1972
+			break;
1973
+		case '&':
1974
+			$newToken['type'] = 'T_BITWISE_AND';
1975
+			break;
1976
+		case '|':
1977
+			$newToken['type'] = 'T_BITWISE_OR';
1978
+			break;
1979
+		case '~':
1980
+			$newToken['type'] = 'T_BITWISE_NOT';
1981
+			break;
1982
+		case '<':
1983
+			$newToken['type'] = 'T_LESS_THAN';
1984
+			break;
1985
+		case '>':
1986
+			$newToken['type'] = 'T_GREATER_THAN';
1987
+			break;
1988
+		case '!':
1989
+			$newToken['type'] = 'T_BOOLEAN_NOT';
1990
+			break;
1991
+		case ',':
1992
+			$newToken['type'] = 'T_COMMA';
1993
+			break;
1994
+		case '@':
1995
+			$newToken['type'] = 'T_ASPERAND';
1996
+			break;
1997
+		case '$':
1998
+			$newToken['type'] = 'T_DOLLAR';
1999
+			break;
2000
+		case '`':
2001
+			$newToken['type'] = 'T_BACKTICK';
2002
+			break;
2003
+		default:
2004
+			$newToken['type'] = 'T_NONE';
2005
+			break;
2006
+		}//end switch
2007
+
2008
+		$newToken['code']    = constant($newToken['type']);
2009
+		$newToken['content'] = $token;
2010
+
2011
+		self::$resolveTokenCache[$token] = $newToken;
2012
+		return $newToken;
2013
+
2014
+	}//end resolveSimpleToken()
2015 2015
 
2016 2016
 
2017 2017
 }//end class
Please login to merge, or discard this patch.
Switch Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -1863,24 +1863,24 @@  discard block
 block discarded – undo
1863 1863
 
1864 1864
         if ($token[0] === T_STRING) {
1865 1865
             switch ($cacheKey) {
1866
-            case 'false':
1867
-                $newToken['type'] = 'T_FALSE';
1868
-                break;
1869
-            case 'true':
1870
-                $newToken['type'] = 'T_TRUE';
1871
-                break;
1872
-            case 'null':
1873
-                $newToken['type'] = 'T_NULL';
1874
-                break;
1875
-            case 'self':
1876
-                $newToken['type'] = 'T_SELF';
1877
-                break;
1878
-            case 'parent':
1879
-                $newToken['type'] = 'T_PARENT';
1880
-                break;
1881
-            default:
1882
-                $newToken['type'] = 'T_STRING';
1883
-                break;
1866
+            	case 'false':
1867
+                	$newToken['type'] = 'T_FALSE';
1868
+                	break;
1869
+            	case 'true':
1870
+                	$newToken['type'] = 'T_TRUE';
1871
+                	break;
1872
+            	case 'null':
1873
+                	$newToken['type'] = 'T_NULL';
1874
+                	break;
1875
+            	case 'self':
1876
+                	$newToken['type'] = 'T_SELF';
1877
+                	break;
1878
+            	case 'parent':
1879
+                	$newToken['type'] = 'T_PARENT';
1880
+                	break;
1881
+            	default:
1882
+                	$newToken['type'] = 'T_STRING';
1883
+                	break;
1884 1884
             }
1885 1885
 
1886 1886
             $newToken['code'] = constant($newToken['type']);
@@ -1922,87 +1922,87 @@  discard block
 block discarded – undo
1922 1922
         $newToken = [];
1923 1923
 
1924 1924
         switch ($token) {
1925
-        case '{':
1926
-            $newToken['type'] = 'T_OPEN_CURLY_BRACKET';
1927
-            break;
1928
-        case '}':
1929
-            $newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
1930
-            break;
1931
-        case '[':
1932
-            $newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
1933
-            break;
1934
-        case ']':
1935
-            $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
1936
-            break;
1937
-        case '(':
1938
-            $newToken['type'] = 'T_OPEN_PARENTHESIS';
1939
-            break;
1940
-        case ')':
1941
-            $newToken['type'] = 'T_CLOSE_PARENTHESIS';
1942
-            break;
1943
-        case ':':
1944
-            $newToken['type'] = 'T_COLON';
1945
-            break;
1946
-        case '.':
1947
-            $newToken['type'] = 'T_STRING_CONCAT';
1948
-            break;
1949
-        case ';':
1950
-            $newToken['type'] = 'T_SEMICOLON';
1951
-            break;
1952
-        case '=':
1953
-            $newToken['type'] = 'T_EQUAL';
1954
-            break;
1955
-        case '*':
1956
-            $newToken['type'] = 'T_MULTIPLY';
1957
-            break;
1958
-        case '/':
1959
-            $newToken['type'] = 'T_DIVIDE';
1960
-            break;
1961
-        case '+':
1962
-            $newToken['type'] = 'T_PLUS';
1963
-            break;
1964
-        case '-':
1965
-            $newToken['type'] = 'T_MINUS';
1966
-            break;
1967
-        case '%':
1968
-            $newToken['type'] = 'T_MODULUS';
1969
-            break;
1970
-        case '^':
1971
-            $newToken['type'] = 'T_BITWISE_XOR';
1972
-            break;
1973
-        case '&':
1974
-            $newToken['type'] = 'T_BITWISE_AND';
1975
-            break;
1976
-        case '|':
1977
-            $newToken['type'] = 'T_BITWISE_OR';
1978
-            break;
1979
-        case '~':
1980
-            $newToken['type'] = 'T_BITWISE_NOT';
1981
-            break;
1982
-        case '<':
1983
-            $newToken['type'] = 'T_LESS_THAN';
1984
-            break;
1985
-        case '>':
1986
-            $newToken['type'] = 'T_GREATER_THAN';
1987
-            break;
1988
-        case '!':
1989
-            $newToken['type'] = 'T_BOOLEAN_NOT';
1990
-            break;
1991
-        case ',':
1992
-            $newToken['type'] = 'T_COMMA';
1993
-            break;
1994
-        case '@':
1995
-            $newToken['type'] = 'T_ASPERAND';
1996
-            break;
1997
-        case '$':
1998
-            $newToken['type'] = 'T_DOLLAR';
1999
-            break;
2000
-        case '`':
2001
-            $newToken['type'] = 'T_BACKTICK';
2002
-            break;
2003
-        default:
2004
-            $newToken['type'] = 'T_NONE';
2005
-            break;
1925
+        	case '{':
1926
+            	$newToken['type'] = 'T_OPEN_CURLY_BRACKET';
1927
+            	break;
1928
+        	case '}':
1929
+            	$newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
1930
+            	break;
1931
+        	case '[':
1932
+            	$newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
1933
+            	break;
1934
+        	case ']':
1935
+            	$newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
1936
+            	break;
1937
+        	case '(':
1938
+            	$newToken['type'] = 'T_OPEN_PARENTHESIS';
1939
+            	break;
1940
+        	case ')':
1941
+            	$newToken['type'] = 'T_CLOSE_PARENTHESIS';
1942
+            	break;
1943
+        	case ':':
1944
+            	$newToken['type'] = 'T_COLON';
1945
+            	break;
1946
+        	case '.':
1947
+            	$newToken['type'] = 'T_STRING_CONCAT';
1948
+            	break;
1949
+        	case ';':
1950
+            	$newToken['type'] = 'T_SEMICOLON';
1951
+            	break;
1952
+        	case '=':
1953
+            	$newToken['type'] = 'T_EQUAL';
1954
+            	break;
1955
+        	case '*':
1956
+            	$newToken['type'] = 'T_MULTIPLY';
1957
+            	break;
1958
+        	case '/':
1959
+            	$newToken['type'] = 'T_DIVIDE';
1960
+            	break;
1961
+        	case '+':
1962
+            	$newToken['type'] = 'T_PLUS';
1963
+            	break;
1964
+        	case '-':
1965
+            	$newToken['type'] = 'T_MINUS';
1966
+            	break;
1967
+        	case '%':
1968
+            	$newToken['type'] = 'T_MODULUS';
1969
+            	break;
1970
+        	case '^':
1971
+            	$newToken['type'] = 'T_BITWISE_XOR';
1972
+            	break;
1973
+        	case '&':
1974
+            	$newToken['type'] = 'T_BITWISE_AND';
1975
+            	break;
1976
+        	case '|':
1977
+            	$newToken['type'] = 'T_BITWISE_OR';
1978
+            	break;
1979
+        	case '~':
1980
+            	$newToken['type'] = 'T_BITWISE_NOT';
1981
+            	break;
1982
+        	case '<':
1983
+            	$newToken['type'] = 'T_LESS_THAN';
1984
+            	break;
1985
+        	case '>':
1986
+            	$newToken['type'] = 'T_GREATER_THAN';
1987
+            	break;
1988
+        	case '!':
1989
+            	$newToken['type'] = 'T_BOOLEAN_NOT';
1990
+            	break;
1991
+        	case ',':
1992
+            	$newToken['type'] = 'T_COMMA';
1993
+            	break;
1994
+        	case '@':
1995
+            	$newToken['type'] = 'T_ASPERAND';
1996
+            	break;
1997
+        	case '$':
1998
+            	$newToken['type'] = 'T_DOLLAR';
1999
+            	break;
2000
+        	case '`':
2001
+            	$newToken['type'] = 'T_BACKTICK';
2002
+            	break;
2003
+        	default:
2004
+            	$newToken['type'] = 'T_NONE';
2005
+            	break;
2006 2006
         }//end switch
2007 2007
 
2008 2008
         $newToken['code']    = constant($newToken['type']);
Please login to merge, or discard this patch.
Spacing   +662 added lines, -662 removed lines patch added patch discarded remove patch
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
             ],
46 46
         ],
47 47
         T_TRY           => [
48
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
49
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
48
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
49
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
50 50
             'strict' => true,
51 51
             'shared' => false,
52
-            'with'   => [],
52
+            'with'   => [ ],
53 53
         ],
54 54
         T_CATCH         => [
55
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
56
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
55
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
56
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
57 57
             'strict' => true,
58 58
             'shared' => false,
59
-            'with'   => [],
59
+            'with'   => [ ],
60 60
         ],
61 61
         T_FINALLY       => [
62
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
63
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
62
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
63
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
64 64
             'strict' => true,
65 65
             'shared' => false,
66
-            'with'   => [],
66
+            'with'   => [ ],
67 67
         ],
68 68
         T_ELSE          => [
69 69
             'start'  => [
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             ],
111 111
             'strict' => false,
112 112
             'shared' => false,
113
-            'with'   => [],
113
+            'with'   => [ ],
114 114
         ],
115 115
         T_FOREACH       => [
116 116
             'start'  => [
@@ -123,56 +123,56 @@  discard block
 block discarded – undo
123 123
             ],
124 124
             'strict' => false,
125 125
             'shared' => false,
126
-            'with'   => [],
126
+            'with'   => [ ],
127 127
         ],
128 128
         T_INTERFACE     => [
129
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
130
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
129
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
130
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
131 131
             'strict' => true,
132 132
             'shared' => false,
133
-            'with'   => [],
133
+            'with'   => [ ],
134 134
         ],
135 135
         T_FUNCTION      => [
136
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
137
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
136
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
137
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
138 138
             'strict' => true,
139 139
             'shared' => false,
140
-            'with'   => [],
140
+            'with'   => [ ],
141 141
         ],
142 142
         T_CLASS         => [
143
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
144
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
143
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
144
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
145 145
             'strict' => true,
146 146
             'shared' => false,
147
-            'with'   => [],
147
+            'with'   => [ ],
148 148
         ],
149 149
         T_TRAIT         => [
150
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
151
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
150
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
151
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
152 152
             'strict' => true,
153 153
             'shared' => false,
154
-            'with'   => [],
154
+            'with'   => [ ],
155 155
         ],
156 156
         T_USE           => [
157
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
158
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
157
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
158
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
159 159
             'strict' => false,
160 160
             'shared' => false,
161
-            'with'   => [],
161
+            'with'   => [ ],
162 162
         ],
163 163
         T_DECLARE       => [
164
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
165
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
164
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
165
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
166 166
             'strict' => false,
167 167
             'shared' => false,
168
-            'with'   => [],
168
+            'with'   => [ ],
169 169
         ],
170 170
         T_NAMESPACE     => [
171
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
172
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
171
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
172
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
173 173
             'strict' => false,
174 174
             'shared' => false,
175
-            'with'   => [],
175
+            'with'   => [ ],
176 176
         ],
177 177
         T_WHILE         => [
178 178
             'start'  => [
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
             ],
186 186
             'strict' => false,
187 187
             'shared' => false,
188
-            'with'   => [],
188
+            'with'   => [ ],
189 189
         ],
190 190
         T_DO            => [
191
-            'start'  => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET],
192
-            'end'    => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET],
191
+            'start'  => [ T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET ],
192
+            'end'    => [ T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET ],
193 193
             'strict' => true,
194 194
             'shared' => false,
195
-            'with'   => [],
195
+            'with'   => [ ],
196 196
         ],
197 197
         T_SWITCH        => [
198 198
             'start'  => [
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             ],
206 206
             'strict' => true,
207 207
             'shared' => false,
208
-            'with'   => [],
208
+            'with'   => [ ],
209 209
         ],
210 210
         T_CASE          => [
211 211
             'start'  => [
@@ -247,18 +247,18 @@  discard block
 block discarded – undo
247 247
             ],
248 248
         ],
249 249
         T_START_HEREDOC => [
250
-            'start'  => [T_START_HEREDOC => T_START_HEREDOC],
251
-            'end'    => [T_END_HEREDOC => T_END_HEREDOC],
250
+            'start'  => [ T_START_HEREDOC => T_START_HEREDOC ],
251
+            'end'    => [ T_END_HEREDOC => T_END_HEREDOC ],
252 252
             'strict' => true,
253 253
             'shared' => false,
254
-            'with'   => [],
254
+            'with'   => [ ],
255 255
         ],
256 256
         T_START_NOWDOC  => [
257
-            'start'  => [T_START_NOWDOC => T_START_NOWDOC],
258
-            'end'    => [T_END_NOWDOC => T_END_NOWDOC],
257
+            'start'  => [ T_START_NOWDOC => T_START_NOWDOC ],
258
+            'end'    => [ T_END_NOWDOC => T_END_NOWDOC ],
259 259
             'strict' => true,
260 260
             'shared' => false,
261
-            'with'   => [],
261
+            'with'   => [ ],
262 262
         ],
263 263
     ];
264 264
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
      * @var array
441 441
      * @see standardiseToken()
442 442
      */
443
-    private static $resolveTokenCache = [];
443
+    private static $resolveTokenCache = [ ];
444 444
 
445 445
 
446 446
     /**
@@ -453,49 +453,49 @@  discard block
 block discarded – undo
453 453
      *
454 454
      * @return array
455 455
      */
456
-    protected function tokenize($string)
456
+    protected function tokenize( $string )
457 457
     {
458
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
459
-            echo "\t*** START PHP TOKENIZING ***".PHP_EOL;
458
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
459
+            echo "\t*** START PHP TOKENIZING ***" . PHP_EOL;
460 460
             $isWin = false;
461
-            if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
461
+            if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) {
462 462
                 $isWin = true;
463 463
             }
464 464
         }
465 465
 
466
-        $tokens      = @token_get_all($string);
467
-        $finalTokens = [];
466
+        $tokens      = @token_get_all( $string );
467
+        $finalTokens = [ ];
468 468
 
469 469
         $newStackPtr       = 0;
470
-        $numTokens         = count($tokens);
470
+        $numTokens         = count( $tokens );
471 471
         $lastNotEmptyToken = 0;
472 472
 
473
-        $insideInlineIf = [];
473
+        $insideInlineIf = [ ];
474 474
         $insideUseGroup = false;
475 475
 
476 476
         $commentTokenizer = new Comment();
477 477
 
478
-        for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) {
478
+        for ( $stackPtr = 0; $stackPtr < $numTokens; $stackPtr++ ) {
479 479
             // Special case for tokens we have needed to blank out.
480
-            if ($tokens[$stackPtr] === null) {
480
+            if ( $tokens[ $stackPtr ] === null ) {
481 481
                 continue;
482 482
             }
483 483
 
484
-            $token        = (array) $tokens[$stackPtr];
485
-            $tokenIsArray = isset($token[1]);
484
+            $token        = (array)$tokens[ $stackPtr ];
485
+            $tokenIsArray = isset( $token[ 1 ] );
486 486
 
487
-            if (PHP_CODESNIFFER_VERBOSITY > 1) {
488
-                if ($tokenIsArray === true) {
489
-                    $type    = Util\Tokens::tokenName($token[0]);
490
-                    $content = Util\Common::prepareForOutput($token[1]);
487
+            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
488
+                if ( $tokenIsArray === true ) {
489
+                    $type    = Util\Tokens::tokenName( $token[ 0 ] );
490
+                    $content = Util\Common::prepareForOutput( $token[ 1 ] );
491 491
                 } else {
492
-                    $newToken = self::resolveSimpleToken($token[0]);
493
-                    $type     = $newToken['type'];
494
-                    $content  = Util\Common::prepareForOutput($token[0]);
492
+                    $newToken = self::resolveSimpleToken( $token[ 0 ] );
493
+                    $type     = $newToken[ 'type' ];
494
+                    $content  = Util\Common::prepareForOutput( $token[ 0 ] );
495 495
                 }
496 496
 
497 497
                 echo "\tProcess token ";
498
-                if ($tokenIsArray === true) {
498
+                if ( $tokenIsArray === true ) {
499 499
                     echo "[$stackPtr]";
500 500
                 } else {
501 501
                     echo " $stackPtr ";
@@ -504,10 +504,10 @@  discard block
 block discarded – undo
504 504
                 echo ": $type => $content";
505 505
             }//end if
506 506
 
507
-            if ($newStackPtr > 0
508
-                && isset(Util\Tokens::$emptyTokens[$finalTokens[($newStackPtr - 1)]['code']]) === false
507
+            if ( $newStackPtr > 0
508
+                && isset( Util\Tokens::$emptyTokens[ $finalTokens[ ( $newStackPtr - 1 ) ][ 'code' ] ] ) === false
509 509
             ) {
510
-                $lastNotEmptyToken = ($newStackPtr - 1);
510
+                $lastNotEmptyToken = ( $newStackPtr - 1 );
511 511
             }
512 512
 
513 513
             /*
@@ -517,31 +517,31 @@  discard block
 block discarded – undo
517 517
                 consistent for all lines.
518 518
             */
519 519
 
520
-            if ($tokenIsArray === true && substr($token[1], -1) === "\r") {
521
-                if (isset($tokens[($stackPtr + 1)]) === true
522
-                    && is_array($tokens[($stackPtr + 1)]) === true
523
-                    && $tokens[($stackPtr + 1)][1][0] === "\n"
520
+            if ( $tokenIsArray === true && substr( $token[ 1 ], -1 ) === "\r" ) {
521
+                if ( isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
522
+                    && is_array( $tokens[ ( $stackPtr + 1 ) ] ) === true
523
+                    && $tokens[ ( $stackPtr + 1 ) ][ 1 ][ 0 ] === "\n"
524 524
                 ) {
525
-                    $token[1] .= "\n";
526
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
527
-                        if ($isWin === true) {
525
+                    $token[ 1 ] .= "\n";
526
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
527
+                        if ( $isWin === true ) {
528 528
                             echo '\n';
529 529
                         } else {
530 530
                             echo "\033[30;1m\\n\033[0m";
531 531
                         }
532 532
                     }
533 533
 
534
-                    if ($tokens[($stackPtr + 1)][1] === "\n") {
534
+                    if ( $tokens[ ( $stackPtr + 1 ) ][ 1 ] === "\n" ) {
535 535
                         // This token's content has been merged into the previous,
536 536
                         // so we can skip it.
537
-                        $tokens[($stackPtr + 1)] = '';
537
+                        $tokens[ ( $stackPtr + 1 ) ] = '';
538 538
                     } else {
539
-                        $tokens[($stackPtr + 1)][1] = substr($tokens[($stackPtr + 1)][1], 1);
539
+                        $tokens[ ( $stackPtr + 1 ) ][ 1 ] = substr( $tokens[ ( $stackPtr + 1 ) ][ 1 ], 1 );
540 540
                     }
541 541
                 }
542 542
             }//end if
543 543
 
544
-            if (PHP_CODESNIFFER_VERBOSITY > 1) {
544
+            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
545 545
                 echo PHP_EOL;
546 546
             }
547 547
 
@@ -549,13 +549,13 @@  discard block
 block discarded – undo
549 549
                 Parse doc blocks into something that can be easily iterated over.
550 550
             */
551 551
 
552
-            if ($tokenIsArray === true
553
-                && ($token[0] === T_DOC_COMMENT
554
-                || ($token[0] === T_COMMENT && strpos($token[1], '/**') === 0))
552
+            if ( $tokenIsArray === true
553
+                && ( $token[ 0 ] === T_DOC_COMMENT
554
+                || ( $token[ 0 ] === T_COMMENT && strpos( $token[ 1 ], '/**' ) === 0 ) )
555 555
             ) {
556
-                $commentTokens = $commentTokenizer->tokenizeString($token[1], $this->eolChar, $newStackPtr);
557
-                foreach ($commentTokens as $commentToken) {
558
-                    $finalTokens[$newStackPtr] = $commentToken;
556
+                $commentTokens = $commentTokenizer->tokenizeString( $token[ 1 ], $this->eolChar, $newStackPtr );
557
+                foreach ( $commentTokens as $commentToken ) {
558
+                    $finalTokens[ $newStackPtr ] = $commentToken;
559 559
                     $newStackPtr++;
560 560
                 }
561 561
 
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
                 provide a single string.
570 570
             */
571 571
 
572
-            if ($tokenIsArray === false && ($token[0] === '"' || $token[0] === 'b"')) {
572
+            if ( $tokenIsArray === false && ( $token[ 0 ] === '"' || $token[ 0 ] === 'b"' ) ) {
573 573
                 // Binary casts need a special token.
574
-                if ($token[0] === 'b"') {
575
-                    $finalTokens[$newStackPtr] = [
574
+                if ( $token[ 0 ] === 'b"' ) {
575
+                    $finalTokens[ $newStackPtr ] = [
576 576
                         'code'    => T_BINARY_CAST,
577 577
                         'type'    => 'T_BINARY_CAST',
578 578
                         'content' => 'b',
@@ -581,28 +581,28 @@  discard block
 block discarded – undo
581 581
                 }
582 582
 
583 583
                 $tokenContent = '"';
584
-                $nestedVars   = [];
585
-                for ($i = ($stackPtr + 1); $i < $numTokens; $i++) {
586
-                    $subToken        = (array) $tokens[$i];
587
-                    $subTokenIsArray = isset($subToken[1]);
588
-
589
-                    if ($subTokenIsArray === true) {
590
-                        $tokenContent .= $subToken[1];
591
-                        if ($subToken[1] === '{'
592
-                            && $subToken[0] !== T_ENCAPSED_AND_WHITESPACE
584
+                $nestedVars   = [ ];
585
+                for ( $i = ( $stackPtr + 1 ); $i < $numTokens; $i++ ) {
586
+                    $subToken        = (array)$tokens[ $i ];
587
+                    $subTokenIsArray = isset( $subToken[ 1 ] );
588
+
589
+                    if ( $subTokenIsArray === true ) {
590
+                        $tokenContent .= $subToken[ 1 ];
591
+                        if ( $subToken[ 1 ] === '{'
592
+                            && $subToken[ 0 ] !== T_ENCAPSED_AND_WHITESPACE
593 593
                         ) {
594
-                            $nestedVars[] = $i;
594
+                            $nestedVars[ ] = $i;
595 595
                         }
596 596
                     } else {
597
-                        $tokenContent .= $subToken[0];
598
-                        if ($subToken[0] === '}') {
599
-                            array_pop($nestedVars);
597
+                        $tokenContent .= $subToken[ 0 ];
598
+                        if ( $subToken[ 0 ] === '}' ) {
599
+                            array_pop( $nestedVars );
600 600
                         }
601 601
                     }
602 602
 
603
-                    if ($subTokenIsArray === false
604
-                        && $subToken[0] === '"'
605
-                        && empty($nestedVars) === true
603
+                    if ( $subTokenIsArray === false
604
+                        && $subToken[ 0 ] === '"'
605
+                        && empty( $nestedVars ) === true
606 606
                     ) {
607 607
                         // We found the other end of the double quoted string.
608 608
                         break;
@@ -613,23 +613,23 @@  discard block
 block discarded – undo
613 613
 
614 614
                 // Convert each line within the double quoted string to a
615 615
                 // new token, so it conforms with other multiple line tokens.
616
-                $tokenLines = explode($this->eolChar, $tokenContent);
617
-                $numLines   = count($tokenLines);
618
-                $newToken   = [];
619
-
620
-                for ($j = 0; $j < $numLines; $j++) {
621
-                    $newToken['content'] = $tokenLines[$j];
622
-                    if ($j === ($numLines - 1)) {
623
-                        if ($tokenLines[$j] === '') {
616
+                $tokenLines = explode( $this->eolChar, $tokenContent );
617
+                $numLines   = count( $tokenLines );
618
+                $newToken   = [ ];
619
+
620
+                for ( $j = 0; $j < $numLines; $j++ ) {
621
+                    $newToken[ 'content' ] = $tokenLines[ $j ];
622
+                    if ( $j === ( $numLines - 1 ) ) {
623
+                        if ( $tokenLines[ $j ] === '' ) {
624 624
                             break;
625 625
                         }
626 626
                     } else {
627
-                        $newToken['content'] .= $this->eolChar;
627
+                        $newToken[ 'content' ] .= $this->eolChar;
628 628
                     }
629 629
 
630
-                    $newToken['code']          = T_DOUBLE_QUOTED_STRING;
631
-                    $newToken['type']          = 'T_DOUBLE_QUOTED_STRING';
632
-                    $finalTokens[$newStackPtr] = $newToken;
630
+                    $newToken[ 'code' ]          = T_DOUBLE_QUOTED_STRING;
631
+                    $newToken[ 'type' ]          = 'T_DOUBLE_QUOTED_STRING';
632
+                    $finalTokens[ $newStackPtr ] = $newToken;
633 633
                     $newStackPtr++;
634 634
                 }
635 635
 
@@ -641,28 +641,28 @@  discard block
 block discarded – undo
641 641
                 Detect binary casting and assign the casts their own token.
642 642
             */
643 643
 
644
-            if ($tokenIsArray === true
645
-                && $token[0] === T_CONSTANT_ENCAPSED_STRING
646
-                && (substr($token[1], 0, 2) === 'b"'
647
-                || substr($token[1], 0, 2) === "b'")
644
+            if ( $tokenIsArray === true
645
+                && $token[ 0 ] === T_CONSTANT_ENCAPSED_STRING
646
+                && ( substr( $token[ 1 ], 0, 2 ) === 'b"'
647
+                || substr( $token[ 1 ], 0, 2 ) === "b'" )
648 648
             ) {
649
-                $finalTokens[$newStackPtr] = [
649
+                $finalTokens[ $newStackPtr ] = [
650 650
                     'code'    => T_BINARY_CAST,
651 651
                     'type'    => 'T_BINARY_CAST',
652 652
                     'content' => 'b',
653 653
                 ];
654 654
                 $newStackPtr++;
655
-                $token[1] = substr($token[1], 1);
655
+                $token[ 1 ] = substr( $token[ 1 ], 1 );
656 656
             }
657 657
 
658
-            if ($tokenIsArray === true
659
-                && $token[0] === T_STRING_CAST
660
-                && preg_match('`^\(\s*binary\s*\)$`i', $token[1]) === 1
658
+            if ( $tokenIsArray === true
659
+                && $token[ 0 ] === T_STRING_CAST
660
+                && preg_match( '`^\(\s*binary\s*\)$`i', $token[ 1 ] ) === 1
661 661
             ) {
662
-                $finalTokens[$newStackPtr] = [
662
+                $finalTokens[ $newStackPtr ] = [
663 663
                     'code'    => T_BINARY_CAST,
664 664
                     'type'    => 'T_BINARY_CAST',
665
-                    'content' => $token[1],
665
+                    'content' => $token[ 1 ],
666 666
                 ];
667 667
                 $newStackPtr++;
668 668
                 continue;
@@ -676,48 +676,48 @@  discard block
 block discarded – undo
676 676
                 alone though.
677 677
             */
678 678
 
679
-            if ($tokenIsArray === true && $token[0] === T_START_HEREDOC) {
679
+            if ( $tokenIsArray === true && $token[ 0 ] === T_START_HEREDOC ) {
680 680
                 // Add the start heredoc token to the final array.
681
-                $finalTokens[$newStackPtr] = self::standardiseToken($token);
681
+                $finalTokens[ $newStackPtr ] = self::standardiseToken( $token );
682 682
 
683 683
                 // Check if this is actually a nowdoc and use a different token
684 684
                 // to help the sniffs.
685 685
                 $nowdoc = false;
686
-                if (strpos($token[1], "'") !== false) {
687
-                    $finalTokens[$newStackPtr]['code'] = T_START_NOWDOC;
688
-                    $finalTokens[$newStackPtr]['type'] = 'T_START_NOWDOC';
686
+                if ( strpos( $token[ 1 ], "'" ) !== false ) {
687
+                    $finalTokens[ $newStackPtr ][ 'code' ] = T_START_NOWDOC;
688
+                    $finalTokens[ $newStackPtr ][ 'type' ] = 'T_START_NOWDOC';
689 689
                     $nowdoc = true;
690 690
                 }
691 691
 
692 692
                 $tokenContent = '';
693
-                for ($i = ($stackPtr + 1); $i < $numTokens; $i++) {
694
-                    $subTokenIsArray = is_array($tokens[$i]);
695
-                    if ($subTokenIsArray === true
696
-                        && $tokens[$i][0] === T_END_HEREDOC
693
+                for ( $i = ( $stackPtr + 1 ); $i < $numTokens; $i++ ) {
694
+                    $subTokenIsArray = is_array( $tokens[ $i ] );
695
+                    if ( $subTokenIsArray === true
696
+                        && $tokens[ $i ][ 0 ] === T_END_HEREDOC
697 697
                     ) {
698 698
                         // We found the other end of the heredoc.
699 699
                         break;
700 700
                     }
701 701
 
702
-                    if ($subTokenIsArray === true) {
703
-                        $tokenContent .= $tokens[$i][1];
702
+                    if ( $subTokenIsArray === true ) {
703
+                        $tokenContent .= $tokens[ $i ][ 1 ];
704 704
                     } else {
705
-                        $tokenContent .= $tokens[$i];
705
+                        $tokenContent .= $tokens[ $i ];
706 706
                     }
707 707
                 }
708 708
 
709
-                if ($i === $numTokens) {
709
+                if ( $i === $numTokens ) {
710 710
                     // We got to the end of the file and never
711 711
                     // found the closing token, so this probably wasn't
712 712
                     // a heredoc.
713
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
714
-                        $type = $finalTokens[$newStackPtr]['type'];
715
-                        echo "\t\t* failed to find the end of the here/nowdoc".PHP_EOL;
716
-                        echo "\t\t* token $stackPtr changed from $type to T_STRING".PHP_EOL;
713
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
714
+                        $type = $finalTokens[ $newStackPtr ][ 'type' ];
715
+                        echo "\t\t* failed to find the end of the here/nowdoc" . PHP_EOL;
716
+                        echo "\t\t* token $stackPtr changed from $type to T_STRING" . PHP_EOL;
717 717
                     }
718 718
 
719
-                    $finalTokens[$newStackPtr]['code'] = T_STRING;
720
-                    $finalTokens[$newStackPtr]['type'] = 'T_STRING';
719
+                    $finalTokens[ $newStackPtr ][ 'code' ] = T_STRING;
720
+                    $finalTokens[ $newStackPtr ][ 'type' ] = 'T_STRING';
721 721
                     $newStackPtr++;
722 722
                     continue;
723 723
                 }
@@ -727,38 +727,38 @@  discard block
 block discarded – undo
727 727
 
728 728
                 // Convert each line within the heredoc to a
729 729
                 // new token, so it conforms with other multiple line tokens.
730
-                $tokenLines = explode($this->eolChar, $tokenContent);
731
-                $numLines   = count($tokenLines);
732
-                $newToken   = [];
733
-
734
-                for ($j = 0; $j < $numLines; $j++) {
735
-                    $newToken['content'] = $tokenLines[$j];
736
-                    if ($j === ($numLines - 1)) {
737
-                        if ($tokenLines[$j] === '') {
730
+                $tokenLines = explode( $this->eolChar, $tokenContent );
731
+                $numLines   = count( $tokenLines );
732
+                $newToken   = [ ];
733
+
734
+                for ( $j = 0; $j < $numLines; $j++ ) {
735
+                    $newToken[ 'content' ] = $tokenLines[ $j ];
736
+                    if ( $j === ( $numLines - 1 ) ) {
737
+                        if ( $tokenLines[ $j ] === '' ) {
738 738
                             break;
739 739
                         }
740 740
                     } else {
741
-                        $newToken['content'] .= $this->eolChar;
741
+                        $newToken[ 'content' ] .= $this->eolChar;
742 742
                     }
743 743
 
744
-                    if ($nowdoc === true) {
745
-                        $newToken['code'] = T_NOWDOC;
746
-                        $newToken['type'] = 'T_NOWDOC';
744
+                    if ( $nowdoc === true ) {
745
+                        $newToken[ 'code' ] = T_NOWDOC;
746
+                        $newToken[ 'type' ] = 'T_NOWDOC';
747 747
                     } else {
748
-                        $newToken['code'] = T_HEREDOC;
749
-                        $newToken['type'] = 'T_HEREDOC';
748
+                        $newToken[ 'code' ] = T_HEREDOC;
749
+                        $newToken[ 'type' ] = 'T_HEREDOC';
750 750
                     }
751 751
 
752
-                    $finalTokens[$newStackPtr] = $newToken;
752
+                    $finalTokens[ $newStackPtr ] = $newToken;
753 753
                     $newStackPtr++;
754 754
                 }//end for
755 755
 
756 756
                 // Add the end heredoc token to the final array.
757
-                $finalTokens[$newStackPtr] = self::standardiseToken($tokens[$stackPtr]);
757
+                $finalTokens[ $newStackPtr ] = self::standardiseToken( $tokens[ $stackPtr ] );
758 758
 
759
-                if ($nowdoc === true) {
760
-                    $finalTokens[$newStackPtr]['code'] = T_END_NOWDOC;
761
-                    $finalTokens[$newStackPtr]['type'] = 'T_END_NOWDOC';
759
+                if ( $nowdoc === true ) {
760
+                    $finalTokens[ $newStackPtr ][ 'code' ] = T_END_NOWDOC;
761
+                    $finalTokens[ $newStackPtr ][ 'type' ] = 'T_END_NOWDOC';
762 762
                 }
763 763
 
764 764
                 $newStackPtr++;
@@ -773,30 +773,30 @@  discard block
 block discarded – undo
773 773
                 and change this token in earlier versions.
774 774
             */
775 775
 
776
-            if (PHP_VERSION_ID < 70000
776
+            if ( PHP_VERSION_ID < 70000
777 777
                 && PHP_VERSION_ID >= 50500
778 778
                 && $tokenIsArray === true
779
-                && $token[0] === T_YIELD
780
-                && isset($tokens[($stackPtr + 1)]) === true
781
-                && isset($tokens[($stackPtr + 2)]) === true
782
-                && $tokens[($stackPtr + 1)][0] === T_WHITESPACE
783
-                && $tokens[($stackPtr + 2)][0] === T_STRING
784
-                && strtolower($tokens[($stackPtr + 2)][1]) === 'from'
779
+                && $token[ 0 ] === T_YIELD
780
+                && isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
781
+                && isset( $tokens[ ( $stackPtr + 2 ) ] ) === true
782
+                && $tokens[ ( $stackPtr + 1 ) ][ 0 ] === T_WHITESPACE
783
+                && $tokens[ ( $stackPtr + 2 ) ][ 0 ] === T_STRING
784
+                && strtolower( $tokens[ ( $stackPtr + 2 ) ][ 1 ] ) === 'from'
785 785
             ) {
786 786
                 // Could be multi-line, so just the token stack.
787
-                $token[0]  = T_YIELD_FROM;
788
-                $token[1] .= $tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
789
-
790
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
791
-                    for ($i = ($stackPtr + 1); $i <= ($stackPtr + 2); $i++) {
792
-                        $type    = Util\Tokens::tokenName($tokens[$i][0]);
793
-                        $content = Util\Common::prepareForOutput($tokens[$i][1]);
794
-                        echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content".PHP_EOL;
787
+                $token[ 0 ]  = T_YIELD_FROM;
788
+                $token[ 1 ] .= $tokens[ ( $stackPtr + 1 ) ][ 1 ] . $tokens[ ( $stackPtr + 2 ) ][ 1 ];
789
+
790
+                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
791
+                    for ( $i = ( $stackPtr + 1 ); $i <= ( $stackPtr + 2 ); $i++ ) {
792
+                        $type    = Util\Tokens::tokenName( $tokens[ $i ][ 0 ] );
793
+                        $content = Util\Common::prepareForOutput( $tokens[ $i ][ 1 ] );
794
+                        echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content" . PHP_EOL;
795 795
                     }
796 796
                 }
797 797
 
798
-                $tokens[($stackPtr + 1)] = null;
799
-                $tokens[($stackPtr + 2)] = null;
798
+                $tokens[ ( $stackPtr + 1 ) ] = null;
799
+                $tokens[ ( $stackPtr + 2 ) ] = null;
800 800
             }
801 801
 
802 802
             /*
@@ -806,37 +806,37 @@  discard block
 block discarded – undo
806 806
                 Checks also if it is just "yield" or "yield from".
807 807
             */
808 808
 
809
-            if (PHP_VERSION_ID < 50500
809
+            if ( PHP_VERSION_ID < 50500
810 810
                 && $tokenIsArray === true
811
-                && $token[0] === T_STRING
812
-                && strtolower($token[1]) === 'yield'
811
+                && $token[ 0 ] === T_STRING
812
+                && strtolower( $token[ 1 ] ) === 'yield'
813 813
             ) {
814
-                if (isset($tokens[($stackPtr + 1)]) === true
815
-                    && isset($tokens[($stackPtr + 2)]) === true
816
-                    && $tokens[($stackPtr + 1)][0] === T_WHITESPACE
817
-                    && $tokens[($stackPtr + 2)][0] === T_STRING
818
-                    && strtolower($tokens[($stackPtr + 2)][1]) === 'from'
814
+                if ( isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
815
+                    && isset( $tokens[ ( $stackPtr + 2 ) ] ) === true
816
+                    && $tokens[ ( $stackPtr + 1 ) ][ 0 ] === T_WHITESPACE
817
+                    && $tokens[ ( $stackPtr + 2 ) ][ 0 ] === T_STRING
818
+                    && strtolower( $tokens[ ( $stackPtr + 2 ) ][ 1 ] ) === 'from'
819 819
                 ) {
820 820
                     // Could be multi-line, so just just the token stack.
821
-                    $token[0]  = T_YIELD_FROM;
822
-                    $token[1] .= $tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
823
-
824
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
825
-                        for ($i = ($stackPtr + 1); $i <= ($stackPtr + 2); $i++) {
826
-                            $type    = Util\Tokens::tokenName($tokens[$i][0]);
827
-                            $content = Util\Common::prepareForOutput($tokens[$i][1]);
828
-                            echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content".PHP_EOL;
821
+                    $token[ 0 ]  = T_YIELD_FROM;
822
+                    $token[ 1 ] .= $tokens[ ( $stackPtr + 1 ) ][ 1 ] . $tokens[ ( $stackPtr + 2 ) ][ 1 ];
823
+
824
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
825
+                        for ( $i = ( $stackPtr + 1 ); $i <= ( $stackPtr + 2 ); $i++ ) {
826
+                            $type    = Util\Tokens::tokenName( $tokens[ $i ][ 0 ] );
827
+                            $content = Util\Common::prepareForOutput( $tokens[ $i ][ 1 ] );
828
+                            echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content" . PHP_EOL;
829 829
                         }
830 830
                     }
831 831
 
832
-                    $tokens[($stackPtr + 1)] = null;
833
-                    $tokens[($stackPtr + 2)] = null;
832
+                    $tokens[ ( $stackPtr + 1 ) ] = null;
833
+                    $tokens[ ( $stackPtr + 2 ) ] = null;
834 834
                 } else {
835
-                    $newToken            = [];
836
-                    $newToken['code']    = T_YIELD;
837
-                    $newToken['type']    = 'T_YIELD';
838
-                    $newToken['content'] = $token[1];
839
-                    $finalTokens[$newStackPtr] = $newToken;
835
+                    $newToken            = [ ];
836
+                    $newToken[ 'code' ]    = T_YIELD;
837
+                    $newToken[ 'type' ]    = 'T_YIELD';
838
+                    $newToken[ 'content' ] = $token[ 1 ];
839
+                    $finalTokens[ $newStackPtr ] = $newToken;
840 840
 
841 841
                     $newStackPtr++;
842 842
                     continue;
@@ -849,18 +849,18 @@  discard block
 block discarded – undo
849 849
                 these tokens in earlier versions.
850 850
             */
851 851
 
852
-            if ($tokenIsArray === false
853
-                && $token[0] === '.'
854
-                && isset($tokens[($stackPtr + 1)]) === true
855
-                && isset($tokens[($stackPtr + 2)]) === true
856
-                && $tokens[($stackPtr + 1)] === '.'
857
-                && $tokens[($stackPtr + 2)] === '.'
852
+            if ( $tokenIsArray === false
853
+                && $token[ 0 ] === '.'
854
+                && isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
855
+                && isset( $tokens[ ( $stackPtr + 2 ) ] ) === true
856
+                && $tokens[ ( $stackPtr + 1 ) ] === '.'
857
+                && $tokens[ ( $stackPtr + 2 ) ] === '.'
858 858
             ) {
859
-                $newToken            = [];
860
-                $newToken['code']    = T_ELLIPSIS;
861
-                $newToken['type']    = 'T_ELLIPSIS';
862
-                $newToken['content'] = '...';
863
-                $finalTokens[$newStackPtr] = $newToken;
859
+                $newToken            = [ ];
860
+                $newToken[ 'code' ]    = T_ELLIPSIS;
861
+                $newToken[ 'type' ]    = 'T_ELLIPSIS';
862
+                $newToken[ 'content' ] = '...';
863
+                $finalTokens[ $newStackPtr ] = $newToken;
864 864
 
865 865
                 $newStackPtr++;
866 866
                 $stackPtr += 2;
@@ -873,16 +873,16 @@  discard block
 block discarded – undo
873 873
                 these tokens in earlier versions.
874 874
             */
875 875
 
876
-            if ($tokenIsArray === false
877
-                && $token[0] === '*'
878
-                && isset($tokens[($stackPtr + 1)]) === true
879
-                && $tokens[($stackPtr + 1)] === '*'
876
+            if ( $tokenIsArray === false
877
+                && $token[ 0 ] === '*'
878
+                && isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
879
+                && $tokens[ ( $stackPtr + 1 ) ] === '*'
880 880
             ) {
881
-                $newToken            = [];
882
-                $newToken['code']    = T_POW;
883
-                $newToken['type']    = 'T_POW';
884
-                $newToken['content'] = '**';
885
-                $finalTokens[$newStackPtr] = $newToken;
881
+                $newToken            = [ ];
882
+                $newToken[ 'code' ]    = T_POW;
883
+                $newToken[ 'type' ]    = 'T_POW';
884
+                $newToken[ 'content' ] = '**';
885
+                $finalTokens[ $newStackPtr ] = $newToken;
886 886
 
887 887
                 $newStackPtr++;
888 888
                 $stackPtr++;
@@ -895,17 +895,17 @@  discard block
 block discarded – undo
895 895
                 these tokens in earlier versions.
896 896
             */
897 897
 
898
-            if ($tokenIsArray === false
899
-                && $token[0] === '*'
900
-                && isset($tokens[($stackPtr + 1)]) === true
901
-                && is_array($tokens[($stackPtr + 1)]) === true
902
-                && $tokens[($stackPtr + 1)][1] === '*='
898
+            if ( $tokenIsArray === false
899
+                && $token[ 0 ] === '*'
900
+                && isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
901
+                && is_array( $tokens[ ( $stackPtr + 1 ) ] ) === true
902
+                && $tokens[ ( $stackPtr + 1 ) ][ 1 ] === '*='
903 903
             ) {
904
-                $newToken            = [];
905
-                $newToken['code']    = T_POW_EQUAL;
906
-                $newToken['type']    = 'T_POW_EQUAL';
907
-                $newToken['content'] = '**=';
908
-                $finalTokens[$newStackPtr] = $newToken;
904
+                $newToken            = [ ];
905
+                $newToken[ 'code' ]    = T_POW_EQUAL;
906
+                $newToken[ 'type' ]    = 'T_POW_EQUAL';
907
+                $newToken[ 'content' ] = '**=';
908
+                $finalTokens[ $newStackPtr ] = $newToken;
909 909
 
910 910
                 $newStackPtr++;
911 911
                 $stackPtr++;
@@ -920,27 +920,27 @@  discard block
 block discarded – undo
920 920
                 So look for and combine these tokens in earlier versions.
921 921
             */
922 922
 
923
-            if (($tokenIsArray === false
924
-                && $token[0] === '?'
925
-                && isset($tokens[($stackPtr + 1)]) === true
926
-                && $tokens[($stackPtr + 1)][0] === '?'
927
-                && isset($tokens[($stackPtr + 2)]) === true
928
-                && $tokens[($stackPtr + 2)][0] === '=')
929
-                || ($tokenIsArray === true
930
-                && $token[0] === T_COALESCE
931
-                && isset($tokens[($stackPtr + 1)]) === true
932
-                && $tokens[($stackPtr + 1)][0] === '=')
923
+            if ( ( $tokenIsArray === false
924
+                && $token[ 0 ] === '?'
925
+                && isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
926
+                && $tokens[ ( $stackPtr + 1 ) ][ 0 ] === '?'
927
+                && isset( $tokens[ ( $stackPtr + 2 ) ] ) === true
928
+                && $tokens[ ( $stackPtr + 2 ) ][ 0 ] === '=' )
929
+                || ( $tokenIsArray === true
930
+                && $token[ 0 ] === T_COALESCE
931
+                && isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
932
+                && $tokens[ ( $stackPtr + 1 ) ][ 0 ] === '=' )
933 933
             ) {
934
-                $newToken            = [];
935
-                $newToken['code']    = T_COALESCE_EQUAL;
936
-                $newToken['type']    = 'T_COALESCE_EQUAL';
937
-                $newToken['content'] = '??=';
938
-                $finalTokens[$newStackPtr] = $newToken;
934
+                $newToken            = [ ];
935
+                $newToken[ 'code' ]    = T_COALESCE_EQUAL;
936
+                $newToken[ 'type' ]    = 'T_COALESCE_EQUAL';
937
+                $newToken[ 'content' ] = '??=';
938
+                $finalTokens[ $newStackPtr ] = $newToken;
939 939
 
940 940
                 $newStackPtr++;
941 941
                 $stackPtr++;
942 942
 
943
-                if ($tokenIsArray === false) {
943
+                if ( $tokenIsArray === false ) {
944 944
                     // Pre PHP 7.
945 945
                     $stackPtr++;
946 946
                 }
@@ -954,16 +954,16 @@  discard block
 block discarded – undo
954 954
                 So look for and combine these tokens in earlier versions.
955 955
             */
956 956
 
957
-            if ($tokenIsArray === false
958
-                && $token[0] === '?'
959
-                && isset($tokens[($stackPtr + 1)]) === true
960
-                && $tokens[($stackPtr + 1)][0] === '?'
957
+            if ( $tokenIsArray === false
958
+                && $token[ 0 ] === '?'
959
+                && isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
960
+                && $tokens[ ( $stackPtr + 1 ) ][ 0 ] === '?'
961 961
             ) {
962
-                $newToken            = [];
963
-                $newToken['code']    = T_COALESCE;
964
-                $newToken['type']    = 'T_COALESCE';
965
-                $newToken['content'] = '??';
966
-                $finalTokens[$newStackPtr] = $newToken;
962
+                $newToken            = [ ];
963
+                $newToken[ 'code' ]    = T_COALESCE;
964
+                $newToken[ 'type' ]    = 'T_COALESCE';
965
+                $newToken[ 'content' ] = '??';
966
+                $finalTokens[ $newStackPtr ] = $newToken;
967 967
 
968 968
                 $newStackPtr++;
969 969
                 $stackPtr++;
@@ -974,45 +974,45 @@  discard block
 block discarded – undo
974 974
                 Convert ? to T_NULLABLE OR T_INLINE_THEN
975 975
             */
976 976
 
977
-            if ($tokenIsArray === false && $token[0] === '?') {
978
-                $newToken            = [];
979
-                $newToken['content'] = '?';
977
+            if ( $tokenIsArray === false && $token[ 0 ] === '?' ) {
978
+                $newToken            = [ ];
979
+                $newToken[ 'content' ] = '?';
980 980
 
981 981
                 $prevNonEmpty = null;
982
-                for ($i = ($stackPtr - 1); $i >= 0; $i--) {
983
-                    if (is_array($tokens[$i]) === true) {
984
-                        $tokenType = $tokens[$i][0];
982
+                for ( $i = ( $stackPtr - 1 ); $i >= 0; $i-- ) {
983
+                    if ( is_array( $tokens[ $i ] ) === true ) {
984
+                        $tokenType = $tokens[ $i ][ 0 ];
985 985
                     } else {
986
-                        $tokenType = $tokens[$i];
986
+                        $tokenType = $tokens[ $i ];
987 987
                     }
988 988
 
989
-                    if ($prevNonEmpty === null
990
-                        && isset(Util\Tokens::$emptyTokens[$tokenType]) === false
989
+                    if ( $prevNonEmpty === null
990
+                        && isset( Util\Tokens::$emptyTokens[ $tokenType ] ) === false
991 991
                     ) {
992 992
                         // Found the previous non-empty token.
993
-                        if ($tokenType === ':' || $tokenType === ',') {
994
-                            $newToken['code'] = T_NULLABLE;
995
-                            $newToken['type'] = 'T_NULLABLE';
993
+                        if ( $tokenType === ':' || $tokenType === ',' ) {
994
+                            $newToken[ 'code' ] = T_NULLABLE;
995
+                            $newToken[ 'type' ] = 'T_NULLABLE';
996 996
                             break;
997 997
                         }
998 998
 
999 999
                         $prevNonEmpty = $tokenType;
1000 1000
                     }
1001 1001
 
1002
-                    if ($tokenType === T_FUNCTION) {
1003
-                        $newToken['code'] = T_NULLABLE;
1004
-                        $newToken['type'] = 'T_NULLABLE';
1002
+                    if ( $tokenType === T_FUNCTION ) {
1003
+                        $newToken[ 'code' ] = T_NULLABLE;
1004
+                        $newToken[ 'type' ] = 'T_NULLABLE';
1005 1005
                         break;
1006
-                    } else if (in_array($tokenType, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';'], true) === true) {
1007
-                        $newToken['code'] = T_INLINE_THEN;
1008
-                        $newToken['type'] = 'T_INLINE_THEN';
1006
+                    } else if ( in_array( $tokenType, [ T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';' ], true ) === true ) {
1007
+                        $newToken[ 'code' ] = T_INLINE_THEN;
1008
+                        $newToken[ 'type' ] = 'T_INLINE_THEN';
1009 1009
 
1010
-                        $insideInlineIf[] = $stackPtr;
1010
+                        $insideInlineIf[ ] = $stackPtr;
1011 1011
                         break;
1012 1012
                     }
1013 1013
                 }//end for
1014 1014
 
1015
-                $finalTokens[$newStackPtr] = $newToken;
1015
+                $finalTokens[ $newStackPtr ] = $newToken;
1016 1016
                 $newStackPtr++;
1017 1017
                 continue;
1018 1018
             }//end if
@@ -1023,20 +1023,20 @@  discard block
 block discarded – undo
1023 1023
                 only ever variables or strings.
1024 1024
             */
1025 1025
 
1026
-            if ($stackPtr > 1
1027
-                && (is_array($tokens[($stackPtr - 1)]) === true
1028
-                && $tokens[($stackPtr - 1)][0] === T_PAAMAYIM_NEKUDOTAYIM)
1026
+            if ( $stackPtr > 1
1027
+                && ( is_array( $tokens[ ( $stackPtr - 1 ) ] ) === true
1028
+                && $tokens[ ( $stackPtr - 1 ) ][ 0 ] === T_PAAMAYIM_NEKUDOTAYIM )
1029 1029
                 && $tokenIsArray === true
1030
-                && $token[0] !== T_STRING
1031
-                && $token[0] !== T_VARIABLE
1032
-                && $token[0] !== T_DOLLAR
1033
-                && isset(Util\Tokens::$emptyTokens[$token[0]]) === false
1030
+                && $token[ 0 ] !== T_STRING
1031
+                && $token[ 0 ] !== T_VARIABLE
1032
+                && $token[ 0 ] !== T_DOLLAR
1033
+                && isset( Util\Tokens::$emptyTokens[ $token[ 0 ] ] ) === false
1034 1034
             ) {
1035
-                $newToken            = [];
1036
-                $newToken['code']    = T_STRING;
1037
-                $newToken['type']    = 'T_STRING';
1038
-                $newToken['content'] = $token[1];
1039
-                $finalTokens[$newStackPtr] = $newToken;
1035
+                $newToken            = [ ];
1036
+                $newToken[ 'code' ]    = T_STRING;
1037
+                $newToken[ 'type' ]    = 'T_STRING';
1038
+                $newToken[ 'content' ] = $token[ 1 ];
1039
+                $finalTokens[ $newStackPtr ] = $newToken;
1040 1040
 
1041 1041
                 $newStackPtr++;
1042 1042
                 continue;
@@ -1049,21 +1049,21 @@  discard block
 block discarded – undo
1049 1049
                 so go forward and change the token type before it is processed.
1050 1050
             */
1051 1051
 
1052
-            if ($tokenIsArray === true
1053
-                && $token[0] === T_FUNCTION
1054
-                && $finalTokens[$lastNotEmptyToken]['code'] !== T_USE
1052
+            if ( $tokenIsArray === true
1053
+                && $token[ 0 ] === T_FUNCTION
1054
+                && $finalTokens[ $lastNotEmptyToken ][ 'code' ] !== T_USE
1055 1055
             ) {
1056
-                for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
1057
-                    if (is_array($tokens[$x]) === false
1058
-                        || isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === false
1056
+                for ( $x = ( $stackPtr + 1 ); $x < $numTokens; $x++ ) {
1057
+                    if ( is_array( $tokens[ $x ] ) === false
1058
+                        || isset( Util\Tokens::$emptyTokens[ $tokens[ $x ][ 0 ] ] ) === false
1059 1059
                     ) {
1060 1060
                         // Non-empty content.
1061 1061
                         break;
1062 1062
                     }
1063 1063
                 }
1064 1064
 
1065
-                if ($x < $numTokens && is_array($tokens[$x]) === true) {
1066
-                    $tokens[$x][0] = T_STRING;
1065
+                if ( $x < $numTokens && is_array( $tokens[ $x ] ) === true ) {
1066
+                    $tokens[ $x ][ 0 ] = T_STRING;
1067 1067
                 }
1068 1068
 
1069 1069
                 /*
@@ -1074,31 +1074,31 @@  discard block
 block discarded – undo
1074 1074
 
1075 1075
                 // Go looking for the colon to start the return type hint.
1076 1076
                 // Start by finding the closing parenthesis of the function.
1077
-                $parenthesisStack  = [];
1077
+                $parenthesisStack  = [ ];
1078 1078
                 $parenthesisCloser = false;
1079
-                for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
1080
-                    if (is_array($tokens[$x]) === false && $tokens[$x] === '(') {
1081
-                        $parenthesisStack[] = $x;
1082
-                    } else if (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
1083
-                        array_pop($parenthesisStack);
1084
-                        if (empty($parenthesisStack) === true) {
1079
+                for ( $x = ( $stackPtr + 1 ); $x < $numTokens; $x++ ) {
1080
+                    if ( is_array( $tokens[ $x ] ) === false && $tokens[ $x ] === '(' ) {
1081
+                        $parenthesisStack[ ] = $x;
1082
+                    } else if ( is_array( $tokens[ $x ] ) === false && $tokens[ $x ] === ')' ) {
1083
+                        array_pop( $parenthesisStack );
1084
+                        if ( empty( $parenthesisStack ) === true ) {
1085 1085
                             $parenthesisCloser = $x;
1086 1086
                             break;
1087 1087
                         }
1088 1088
                     }
1089 1089
                 }
1090 1090
 
1091
-                if ($parenthesisCloser !== false) {
1092
-                    for ($x = ($parenthesisCloser + 1); $x < $numTokens; $x++) {
1093
-                        if (is_array($tokens[$x]) === false
1094
-                            || isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === false
1091
+                if ( $parenthesisCloser !== false ) {
1092
+                    for ( $x = ( $parenthesisCloser + 1 ); $x < $numTokens; $x++ ) {
1093
+                        if ( is_array( $tokens[ $x ] ) === false
1094
+                            || isset( Util\Tokens::$emptyTokens[ $tokens[ $x ][ 0 ] ] ) === false
1095 1095
                         ) {
1096 1096
                             // Non-empty content.
1097
-                            if (is_array($tokens[$x]) === true && $tokens[$x][0] === T_USE) {
1097
+                            if ( is_array( $tokens[ $x ] ) === true && $tokens[ $x ][ 0 ] === T_USE ) {
1098 1098
                                 // Found a use statements, so search ahead for the closing parenthesis.
1099
-                                for ($x += 1; $x < $numTokens; $x++) {
1100
-                                    if (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
1101
-                                        continue(2);
1099
+                                for ( $x += 1; $x < $numTokens; $x++ ) {
1100
+                                    if ( is_array( $tokens[ $x ] ) === false && $tokens[ $x ] === ')' ) {
1101
+                                        continue( 2 );
1102 1102
                                     }
1103 1103
                                 }
1104 1104
                             }
@@ -1107,9 +1107,9 @@  discard block
 block discarded – undo
1107 1107
                         }
1108 1108
                     }
1109 1109
 
1110
-                    if (isset($tokens[$x]) === true
1111
-                        && is_array($tokens[$x]) === false
1112
-                        && $tokens[$x] === ':'
1110
+                    if ( isset( $tokens[ $x ] ) === true
1111
+                        && is_array( $tokens[ $x ] ) === false
1112
+                        && $tokens[ $x ] === ':'
1113 1113
                     ) {
1114 1114
                         $allowed = [
1115 1115
                             T_STRING       => T_STRING,
@@ -1123,25 +1123,25 @@  discard block
 block discarded – undo
1123 1123
                         $allowed += Util\Tokens::$emptyTokens;
1124 1124
 
1125 1125
                         // Find the start of the return type.
1126
-                        for ($x += 1; $x < $numTokens; $x++) {
1127
-                            if (is_array($tokens[$x]) === true
1128
-                                && isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === true
1126
+                        for ( $x += 1; $x < $numTokens; $x++ ) {
1127
+                            if ( is_array( $tokens[ $x ] ) === true
1128
+                                && isset( Util\Tokens::$emptyTokens[ $tokens[ $x ][ 0 ] ] ) === true
1129 1129
                             ) {
1130 1130
                                 // Whitespace or comments before the return type.
1131 1131
                                 continue;
1132 1132
                             }
1133 1133
 
1134
-                            if (is_array($tokens[$x]) === false && $tokens[$x] === '?') {
1134
+                            if ( is_array( $tokens[ $x ] ) === false && $tokens[ $x ] === '?' ) {
1135 1135
                                 // Found a nullable operator, so skip it.
1136 1136
                                 // But also covert the token to save the tokenizer
1137 1137
                                 // a bit of time later on.
1138
-                                $tokens[$x] = [
1138
+                                $tokens[ $x ] = [
1139 1139
                                     T_NULLABLE,
1140 1140
                                     '?',
1141 1141
                                 ];
1142 1142
 
1143
-                                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1144
-                                    echo "\t\t* token $x changed from ? to T_NULLABLE".PHP_EOL;
1143
+                                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1144
+                                    echo "\t\t* token $x changed from ? to T_NULLABLE" . PHP_EOL;
1145 1145
                                 }
1146 1146
 
1147 1147
                                 continue;
@@ -1153,14 +1153,14 @@  discard block
 block discarded – undo
1153 1153
                         // Any T_ARRAY tokens we find between here and the next
1154 1154
                         // token that can't be part of the return type need to be
1155 1155
                         // converted to T_STRING tokens.
1156
-                        for ($x; $x < $numTokens; $x++) {
1157
-                            if (is_array($tokens[$x]) === false || isset($allowed[$tokens[$x][0]]) === false) {
1156
+                        for ( $x; $x < $numTokens; $x++ ) {
1157
+                            if ( is_array( $tokens[ $x ] ) === false || isset( $allowed[ $tokens[ $x ][ 0 ] ] ) === false ) {
1158 1158
                                 break;
1159
-                            } else if ($tokens[$x][0] === T_ARRAY) {
1160
-                                $tokens[$x][0] = T_STRING;
1159
+                            } else if ( $tokens[ $x ][ 0 ] === T_ARRAY ) {
1160
+                                $tokens[ $x ][ 0 ] = T_STRING;
1161 1161
 
1162
-                                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1163
-                                    echo "\t\t* token $x changed from T_ARRAY to T_STRING".PHP_EOL;
1162
+                                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1163
+                                    echo "\t\t* token $x changed from T_ARRAY to T_STRING" . PHP_EOL;
1164 1164
                                 }
1165 1165
                             }
1166 1166
                         }
@@ -1174,16 +1174,16 @@  discard block
 block discarded – undo
1174 1174
                 So look for and combine these tokens in earlier versions.
1175 1175
             */
1176 1176
 
1177
-            if ($tokenIsArray === true
1178
-                && $token[0] === T_IS_SMALLER_OR_EQUAL
1179
-                && isset($tokens[($stackPtr + 1)]) === true
1180
-                && $tokens[($stackPtr + 1)][0] === '>'
1177
+            if ( $tokenIsArray === true
1178
+                && $token[ 0 ] === T_IS_SMALLER_OR_EQUAL
1179
+                && isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
1180
+                && $tokens[ ( $stackPtr + 1 ) ][ 0 ] === '>'
1181 1181
             ) {
1182
-                $newToken            = [];
1183
-                $newToken['code']    = T_SPACESHIP;
1184
-                $newToken['type']    = 'T_SPACESHIP';
1185
-                $newToken['content'] = '<=>';
1186
-                $finalTokens[$newStackPtr] = $newToken;
1182
+                $newToken            = [ ];
1183
+                $newToken[ 'code' ]    = T_SPACESHIP;
1184
+                $newToken[ 'type' ]    = 'T_SPACESHIP';
1185
+                $newToken[ 'content' ] = '<=>';
1186
+                $finalTokens[ $newStackPtr ] = $newToken;
1187 1187
 
1188 1188
                 $newStackPtr++;
1189 1189
                 $stackPtr++;
@@ -1198,11 +1198,11 @@  discard block
 block discarded – undo
1198 1198
                 goto labels.
1199 1199
             */
1200 1200
 
1201
-            if ($tokenIsArray === true
1202
-                && $token[0] === T_STRING
1203
-                && isset($tokens[($stackPtr + 1)]) === true
1204
-                && $tokens[($stackPtr + 1)] === ':'
1205
-                && $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM
1201
+            if ( $tokenIsArray === true
1202
+                && $token[ 0 ] === T_STRING
1203
+                && isset( $tokens[ ( $stackPtr + 1 ) ] ) === true
1204
+                && $tokens[ ( $stackPtr + 1 ) ] === ':'
1205
+                && $tokens[ ( $stackPtr - 1 ) ][ 0 ] !== T_PAAMAYIM_NEKUDOTAYIM
1206 1206
             ) {
1207 1207
                 $stopTokens = [
1208 1208
                     T_CASE               => true,
@@ -1211,24 +1211,24 @@  discard block
 block discarded – undo
1211 1211
                     T_INLINE_THEN        => true,
1212 1212
                 ];
1213 1213
 
1214
-                for ($x = ($newStackPtr - 1); $x > 0; $x--) {
1215
-                    if (isset($stopTokens[$finalTokens[$x]['code']]) === true) {
1214
+                for ( $x = ( $newStackPtr - 1 ); $x > 0; $x-- ) {
1215
+                    if ( isset( $stopTokens[ $finalTokens[ $x ][ 'code' ] ] ) === true ) {
1216 1216
                         break;
1217 1217
                     }
1218 1218
                 }
1219 1219
 
1220
-                if ($finalTokens[$x]['code'] !== T_CASE
1221
-                    && $finalTokens[$x]['code'] !== T_INLINE_THEN
1220
+                if ( $finalTokens[ $x ][ 'code' ] !== T_CASE
1221
+                    && $finalTokens[ $x ][ 'code' ] !== T_INLINE_THEN
1222 1222
                 ) {
1223
-                    $finalTokens[$newStackPtr] = [
1224
-                        'content' => $token[1].':',
1223
+                    $finalTokens[ $newStackPtr ] = [
1224
+                        'content' => $token[ 1 ] . ':',
1225 1225
                         'code'    => T_GOTO_LABEL,
1226 1226
                         'type'    => 'T_GOTO_LABEL',
1227 1227
                     ];
1228 1228
 
1229
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1230
-                        echo "\t\t* token $stackPtr changed from T_STRING to T_GOTO_LABEL".PHP_EOL;
1231
-                        echo "\t\t* skipping T_COLON token ".($stackPtr + 1).PHP_EOL;
1229
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1230
+                        echo "\t\t* token $stackPtr changed from T_STRING to T_GOTO_LABEL" . PHP_EOL;
1231
+                        echo "\t\t* skipping T_COLON token " . ( $stackPtr + 1 ) . PHP_EOL;
1232 1232
                     }
1233 1233
 
1234 1234
                     $newStackPtr++;
@@ -1244,30 +1244,30 @@  discard block
 block discarded – undo
1244 1244
                 Note that $token[1] is the token's content.
1245 1245
             */
1246 1246
 
1247
-            if ($tokenIsArray === true && strpos($token[1], $this->eolChar) !== false) {
1248
-                $tokenLines = explode($this->eolChar, $token[1]);
1249
-                $numLines   = count($tokenLines);
1247
+            if ( $tokenIsArray === true && strpos( $token[ 1 ], $this->eolChar ) !== false ) {
1248
+                $tokenLines = explode( $this->eolChar, $token[ 1 ] );
1249
+                $numLines   = count( $tokenLines );
1250 1250
                 $newToken   = [
1251
-                    'type'    => Util\Tokens::tokenName($token[0]),
1252
-                    'code'    => $token[0],
1251
+                    'type'    => Util\Tokens::tokenName( $token[ 0 ] ),
1252
+                    'code'    => $token[ 0 ],
1253 1253
                     'content' => '',
1254 1254
                 ];
1255 1255
 
1256
-                for ($i = 0; $i < $numLines; $i++) {
1257
-                    $newToken['content'] = $tokenLines[$i];
1258
-                    if ($i === ($numLines - 1)) {
1259
-                        if ($tokenLines[$i] === '') {
1256
+                for ( $i = 0; $i < $numLines; $i++ ) {
1257
+                    $newToken[ 'content' ] = $tokenLines[ $i ];
1258
+                    if ( $i === ( $numLines - 1 ) ) {
1259
+                        if ( $tokenLines[ $i ] === '' ) {
1260 1260
                             break;
1261 1261
                         }
1262 1262
                     } else {
1263
-                        $newToken['content'] .= $this->eolChar;
1263
+                        $newToken[ 'content' ] .= $this->eolChar;
1264 1264
                     }
1265 1265
 
1266
-                    $finalTokens[$newStackPtr] = $newToken;
1266
+                    $finalTokens[ $newStackPtr ] = $newToken;
1267 1267
                     $newStackPtr++;
1268 1268
                 }
1269 1269
             } else {
1270
-                if ($tokenIsArray === true && $token[0] === T_STRING) {
1270
+                if ( $tokenIsArray === true && $token[ 0 ] === T_STRING ) {
1271 1271
                     // Some T_STRING tokens should remain that way
1272 1272
                     // due to their context.
1273 1273
                     $context = [
@@ -1284,20 +1284,20 @@  discard block
 block discarded – undo
1284 1284
                         T_PAAMAYIM_NEKUDOTAYIM => true,
1285 1285
                     ];
1286 1286
 
1287
-                    if (isset($context[$finalTokens[$lastNotEmptyToken]['code']]) === true) {
1287
+                    if ( isset( $context[ $finalTokens[ $lastNotEmptyToken ][ 'code' ] ] ) === true ) {
1288 1288
                         // Special case for syntax like: return new self
1289 1289
                         // where self should not be a string.
1290
-                        if ($finalTokens[$lastNotEmptyToken]['code'] === T_NEW
1291
-                            && strtolower($token[1]) === 'self'
1290
+                        if ( $finalTokens[ $lastNotEmptyToken ][ 'code' ] === T_NEW
1291
+                            && strtolower( $token[ 1 ] ) === 'self'
1292 1292
                         ) {
1293
-                            $finalTokens[$newStackPtr] = [
1294
-                                'content' => $token[1],
1293
+                            $finalTokens[ $newStackPtr ] = [
1294
+                                'content' => $token[ 1 ],
1295 1295
                                 'code'    => T_SELF,
1296 1296
                                 'type'    => 'T_SELF',
1297 1297
                             ];
1298 1298
                         } else {
1299
-                            $finalTokens[$newStackPtr] = [
1300
-                                'content' => $token[1],
1299
+                            $finalTokens[ $newStackPtr ] = [
1300
+                                'content' => $token[ 1 ],
1301 1301
                                 'code'    => T_STRING,
1302 1302
                                 'type'    => 'T_STRING',
1303 1303
                             ];
@@ -1309,77 +1309,77 @@  discard block
 block discarded – undo
1309 1309
                 }//end if
1310 1310
 
1311 1311
                 $newToken = null;
1312
-                if ($tokenIsArray === false) {
1313
-                    if (isset(self::$resolveTokenCache[$token[0]]) === true) {
1314
-                        $newToken = self::$resolveTokenCache[$token[0]];
1312
+                if ( $tokenIsArray === false ) {
1313
+                    if ( isset( self::$resolveTokenCache[ $token[ 0 ] ] ) === true ) {
1314
+                        $newToken = self::$resolveTokenCache[ $token[ 0 ] ];
1315 1315
                     }
1316 1316
                 } else {
1317 1317
                     $cacheKey = null;
1318
-                    if ($token[0] === T_STRING) {
1319
-                        $cacheKey = strtolower($token[1]);
1320
-                    } else if ($token[0] !== T_CURLY_OPEN) {
1321
-                        $cacheKey = $token[0];
1318
+                    if ( $token[ 0 ] === T_STRING ) {
1319
+                        $cacheKey = strtolower( $token[ 1 ] );
1320
+                    } else if ( $token[ 0 ] !== T_CURLY_OPEN ) {
1321
+                        $cacheKey = $token[ 0 ];
1322 1322
                     }
1323 1323
 
1324
-                    if ($cacheKey !== null && isset(self::$resolveTokenCache[$cacheKey]) === true) {
1325
-                        $newToken            = self::$resolveTokenCache[$cacheKey];
1326
-                        $newToken['content'] = $token[1];
1324
+                    if ( $cacheKey !== null && isset( self::$resolveTokenCache[ $cacheKey ] ) === true ) {
1325
+                        $newToken            = self::$resolveTokenCache[ $cacheKey ];
1326
+                        $newToken[ 'content' ] = $token[ 1 ];
1327 1327
                     }
1328 1328
                 }
1329 1329
 
1330
-                if ($newToken === null) {
1331
-                    $newToken = self::standardiseToken($token);
1330
+                if ( $newToken === null ) {
1331
+                    $newToken = self::standardiseToken( $token );
1332 1332
                 }
1333 1333
 
1334 1334
                 // Convert colons that are actually the ELSE component of an
1335 1335
                 // inline IF statement.
1336
-                if (empty($insideInlineIf) === false && $newToken['code'] === T_COLON) {
1336
+                if ( empty( $insideInlineIf ) === false && $newToken[ 'code' ] === T_COLON ) {
1337 1337
                     // Make sure this isn't the return type separator of a closure.
1338 1338
                     $isReturnType = false;
1339
-                    for ($i = ($stackPtr - 1); $i > 0; $i--) {
1340
-                        if (is_array($tokens[$i]) === false
1341
-                            || ($tokens[$i][0] !== T_DOC_COMMENT
1342
-                            && $tokens[$i][0] !== T_COMMENT
1343
-                            && $tokens[$i][0] !== T_WHITESPACE)
1339
+                    for ( $i = ( $stackPtr - 1 ); $i > 0; $i-- ) {
1340
+                        if ( is_array( $tokens[ $i ] ) === false
1341
+                            || ( $tokens[ $i ][ 0 ] !== T_DOC_COMMENT
1342
+                            && $tokens[ $i ][ 0 ] !== T_COMMENT
1343
+                            && $tokens[ $i ][ 0 ] !== T_WHITESPACE )
1344 1344
                         ) {
1345 1345
                             break;
1346 1346
                         }
1347 1347
                     }
1348 1348
 
1349
-                    if ($tokens[$i] === ')') {
1349
+                    if ( $tokens[ $i ] === ')' ) {
1350 1350
                         $parenCount = 1;
1351
-                        for ($i--; $i > 0; $i--) {
1352
-                            if ($tokens[$i] === '(') {
1351
+                        for ( $i--; $i > 0; $i-- ) {
1352
+                            if ( $tokens[ $i ] === '(' ) {
1353 1353
                                 $parenCount--;
1354
-                                if ($parenCount === 0) {
1354
+                                if ( $parenCount === 0 ) {
1355 1355
                                     break;
1356 1356
                                 }
1357
-                            } else if ($tokens[$i] === ')') {
1357
+                            } else if ( $tokens[ $i ] === ')' ) {
1358 1358
                                 $parenCount++;
1359 1359
                             }
1360 1360
                         }
1361 1361
 
1362 1362
                         // We've found the open parenthesis, so if the previous
1363 1363
                         // non-empty token is FUNCTION or USE, this is a closure.
1364
-                        for ($i--; $i > 0; $i--) {
1365
-                            if (is_array($tokens[$i]) === false
1366
-                                || ($tokens[$i][0] !== T_DOC_COMMENT
1367
-                                && $tokens[$i][0] !== T_COMMENT
1368
-                                && $tokens[$i][0] !== T_WHITESPACE)
1364
+                        for ( $i--; $i > 0; $i-- ) {
1365
+                            if ( is_array( $tokens[ $i ] ) === false
1366
+                                || ( $tokens[ $i ][ 0 ] !== T_DOC_COMMENT
1367
+                                && $tokens[ $i ][ 0 ] !== T_COMMENT
1368
+                                && $tokens[ $i ][ 0 ] !== T_WHITESPACE )
1369 1369
                             ) {
1370 1370
                                 break;
1371 1371
                             }
1372 1372
                         }
1373 1373
 
1374
-                        if ($tokens[$i][0] === T_FUNCTION || $tokens[$i][0] === T_USE) {
1374
+                        if ( $tokens[ $i ][ 0 ] === T_FUNCTION || $tokens[ $i ][ 0 ] === T_USE ) {
1375 1375
                             $isReturnType = true;
1376 1376
                         }
1377 1377
                     }//end if
1378 1378
 
1379
-                    if ($isReturnType === false) {
1380
-                        array_pop($insideInlineIf);
1381
-                        $newToken['code'] = T_INLINE_ELSE;
1382
-                        $newToken['type'] = 'T_INLINE_ELSE';
1379
+                    if ( $isReturnType === false ) {
1380
+                        array_pop( $insideInlineIf );
1381
+                        $newToken[ 'code' ] = T_INLINE_ELSE;
1382
+                        $newToken[ 'type' ] = 'T_INLINE_ELSE';
1383 1383
                     }
1384 1384
                 }//end if
1385 1385
 
@@ -1387,13 +1387,13 @@  discard block
 block discarded – undo
1387 1387
                 // type hinting function arguments as being arrays. We want to keep
1388 1388
                 // the parenthesis map clean, so let's tag these tokens as
1389 1389
                 // T_STRING.
1390
-                if ($newToken['code'] === T_ARRAY) {
1391
-                    for ($i = $stackPtr; $i < $numTokens; $i++) {
1392
-                        if ($tokens[$i] === '(') {
1390
+                if ( $newToken[ 'code' ] === T_ARRAY ) {
1391
+                    for ( $i = $stackPtr; $i < $numTokens; $i++ ) {
1392
+                        if ( $tokens[ $i ] === '(' ) {
1393 1393
                             break;
1394
-                        } else if ($tokens[$i][0] === T_VARIABLE) {
1395
-                            $newToken['code'] = T_STRING;
1396
-                            $newToken['type'] = 'T_STRING';
1394
+                        } else if ( $tokens[ $i ][ 0 ] === T_VARIABLE ) {
1395
+                            $newToken[ 'code' ] = T_STRING;
1396
+                            $newToken[ 'type' ] = 'T_STRING';
1397 1397
                             break;
1398 1398
                         }
1399 1399
                     }
@@ -1401,58 +1401,58 @@  discard block
 block discarded – undo
1401 1401
 
1402 1402
                 // This is a special case when checking PHP 5.5+ code in PHP < 5.5
1403 1403
                 // where "finally" should be T_FINALLY instead of T_STRING.
1404
-                if ($newToken['code'] === T_STRING
1405
-                    && strtolower($newToken['content']) === 'finally'
1404
+                if ( $newToken[ 'code' ] === T_STRING
1405
+                    && strtolower( $newToken[ 'content' ] ) === 'finally'
1406 1406
                 ) {
1407
-                    $newToken['code'] = T_FINALLY;
1408
-                    $newToken['type'] = 'T_FINALLY';
1407
+                    $newToken[ 'code' ] = T_FINALLY;
1408
+                    $newToken[ 'type' ] = 'T_FINALLY';
1409 1409
                 }
1410 1410
 
1411 1411
                 // This is a special case for the PHP 5.5 classname::class syntax
1412 1412
                 // where "class" should be T_STRING instead of T_CLASS.
1413
-                if (($newToken['code'] === T_CLASS
1414
-                    || $newToken['code'] === T_FUNCTION)
1415
-                    && $finalTokens[$lastNotEmptyToken]['code'] === T_DOUBLE_COLON
1413
+                if ( ( $newToken[ 'code' ] === T_CLASS
1414
+                    || $newToken[ 'code' ] === T_FUNCTION )
1415
+                    && $finalTokens[ $lastNotEmptyToken ][ 'code' ] === T_DOUBLE_COLON
1416 1416
                 ) {
1417
-                    $newToken['code'] = T_STRING;
1418
-                    $newToken['type'] = 'T_STRING';
1417
+                    $newToken[ 'code' ] = T_STRING;
1418
+                    $newToken[ 'type' ] = 'T_STRING';
1419 1419
                 }
1420 1420
 
1421 1421
                 // This is a special case for PHP 5.6 use function and use const
1422 1422
                 // where "function" and "const" should be T_STRING instead of T_FUNCTION
1423 1423
                 // and T_CONST.
1424
-                if (($newToken['code'] === T_FUNCTION
1425
-                    || $newToken['code'] === T_CONST)
1426
-                    && ($finalTokens[$lastNotEmptyToken]['code'] === T_USE || $insideUseGroup === true)
1424
+                if ( ( $newToken[ 'code' ] === T_FUNCTION
1425
+                    || $newToken[ 'code' ] === T_CONST )
1426
+                    && ( $finalTokens[ $lastNotEmptyToken ][ 'code' ] === T_USE || $insideUseGroup === true )
1427 1427
                 ) {
1428
-                    $newToken['code'] = T_STRING;
1429
-                    $newToken['type'] = 'T_STRING';
1428
+                    $newToken[ 'code' ] = T_STRING;
1429
+                    $newToken[ 'type' ] = 'T_STRING';
1430 1430
                 }
1431 1431
 
1432 1432
                 // This is a special case for use groups in PHP 7+ where leaving
1433 1433
                 // the curly braces as their normal tokens would confuse
1434 1434
                 // the scope map and sniffs.
1435
-                if ($newToken['code'] === T_OPEN_CURLY_BRACKET
1436
-                    && $finalTokens[$lastNotEmptyToken]['code'] === T_NS_SEPARATOR
1435
+                if ( $newToken[ 'code' ] === T_OPEN_CURLY_BRACKET
1436
+                    && $finalTokens[ $lastNotEmptyToken ][ 'code' ] === T_NS_SEPARATOR
1437 1437
                 ) {
1438
-                    $newToken['code'] = T_OPEN_USE_GROUP;
1439
-                    $newToken['type'] = 'T_OPEN_USE_GROUP';
1438
+                    $newToken[ 'code' ] = T_OPEN_USE_GROUP;
1439
+                    $newToken[ 'type' ] = 'T_OPEN_USE_GROUP';
1440 1440
                     $insideUseGroup   = true;
1441 1441
                 }
1442 1442
 
1443
-                if ($insideUseGroup === true && $newToken['code'] === T_CLOSE_CURLY_BRACKET) {
1444
-                    $newToken['code'] = T_CLOSE_USE_GROUP;
1445
-                    $newToken['type'] = 'T_CLOSE_USE_GROUP';
1443
+                if ( $insideUseGroup === true && $newToken[ 'code' ] === T_CLOSE_CURLY_BRACKET ) {
1444
+                    $newToken[ 'code' ] = T_CLOSE_USE_GROUP;
1445
+                    $newToken[ 'type' ] = 'T_CLOSE_USE_GROUP';
1446 1446
                     $insideUseGroup   = false;
1447 1447
                 }
1448 1448
 
1449
-                $finalTokens[$newStackPtr] = $newToken;
1449
+                $finalTokens[ $newStackPtr ] = $newToken;
1450 1450
                 $newStackPtr++;
1451 1451
             }//end if
1452 1452
         }//end for
1453 1453
 
1454
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1455
-            echo "\t*** END PHP TOKENIZING ***".PHP_EOL;
1454
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1455
+            echo "\t*** END PHP TOKENIZING ***" . PHP_EOL;
1456 1456
         }
1457 1457
 
1458 1458
         return $finalTokens;
@@ -1474,96 +1474,96 @@  discard block
 block discarded – undo
1474 1474
      */
1475 1475
     protected function processAdditional()
1476 1476
     {
1477
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1478
-            echo "\t*** START ADDITIONAL PHP PROCESSING ***".PHP_EOL;
1477
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1478
+            echo "\t*** START ADDITIONAL PHP PROCESSING ***" . PHP_EOL;
1479 1479
         }
1480 1480
 
1481
-        $numTokens = count($this->tokens);
1482
-        for ($i = ($numTokens - 1); $i >= 0; $i--) {
1481
+        $numTokens = count( $this->tokens );
1482
+        for ( $i = ( $numTokens - 1 ); $i >= 0; $i-- ) {
1483 1483
             // Check for any unset scope conditions due to alternate IF/ENDIF syntax.
1484
-            if (isset($this->tokens[$i]['scope_opener']) === true
1485
-                && isset($this->tokens[$i]['scope_condition']) === false
1484
+            if ( isset( $this->tokens[ $i ][ 'scope_opener' ] ) === true
1485
+                && isset( $this->tokens[ $i ][ 'scope_condition' ] ) === false
1486 1486
             ) {
1487
-                $this->tokens[$i]['scope_condition'] = $this->tokens[$this->tokens[$i]['scope_opener']]['scope_condition'];
1487
+                $this->tokens[ $i ][ 'scope_condition' ] = $this->tokens[ $this->tokens[ $i ][ 'scope_opener' ] ][ 'scope_condition' ];
1488 1488
             }
1489 1489
 
1490
-            if ($this->tokens[$i]['code'] === T_FUNCTION) {
1490
+            if ( $this->tokens[ $i ][ 'code' ] === T_FUNCTION ) {
1491 1491
                 /*
1492 1492
                     Detect functions that are actually closures and
1493 1493
                     assign them a different token.
1494 1494
                 */
1495 1495
 
1496
-                if (isset($this->tokens[$i]['scope_opener']) === true) {
1497
-                    for ($x = ($i + 1); $x < $numTokens; $x++) {
1498
-                        if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false
1499
-                            && $this->tokens[$x]['code'] !== T_BITWISE_AND
1496
+                if ( isset( $this->tokens[ $i ][ 'scope_opener' ] ) === true ) {
1497
+                    for ( $x = ( $i + 1 ); $x < $numTokens; $x++ ) {
1498
+                        if ( isset( Util\Tokens::$emptyTokens[ $this->tokens[ $x ][ 'code' ] ] ) === false
1499
+                            && $this->tokens[ $x ][ 'code' ] !== T_BITWISE_AND
1500 1500
                         ) {
1501 1501
                             break;
1502 1502
                         }
1503 1503
                     }
1504 1504
 
1505
-                    if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) {
1506
-                        $this->tokens[$i]['code'] = T_CLOSURE;
1507
-                        $this->tokens[$i]['type'] = 'T_CLOSURE';
1508
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1509
-                            $line = $this->tokens[$i]['line'];
1510
-                            echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE".PHP_EOL;
1505
+                    if ( $this->tokens[ $x ][ 'code' ] === T_OPEN_PARENTHESIS ) {
1506
+                        $this->tokens[ $i ][ 'code' ] = T_CLOSURE;
1507
+                        $this->tokens[ $i ][ 'type' ] = 'T_CLOSURE';
1508
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1509
+                            $line = $this->tokens[ $i ][ 'line' ];
1510
+                            echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE" . PHP_EOL;
1511 1511
                         }
1512 1512
 
1513
-                        for ($x = ($this->tokens[$i]['scope_opener'] + 1); $x < $this->tokens[$i]['scope_closer']; $x++) {
1514
-                            if (isset($this->tokens[$x]['conditions'][$i]) === false) {
1513
+                        for ( $x = ( $this->tokens[ $i ][ 'scope_opener' ] + 1 ); $x < $this->tokens[ $i ][ 'scope_closer' ]; $x++ ) {
1514
+                            if ( isset( $this->tokens[ $x ][ 'conditions' ][ $i ] ) === false ) {
1515 1515
                                 continue;
1516 1516
                             }
1517 1517
 
1518
-                            $this->tokens[$x]['conditions'][$i] = T_CLOSURE;
1519
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1520
-                                $type = $this->tokens[$x]['type'];
1521
-                                echo "\t\t* cleaned $x ($type) *".PHP_EOL;
1518
+                            $this->tokens[ $x ][ 'conditions' ][ $i ] = T_CLOSURE;
1519
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1520
+                                $type = $this->tokens[ $x ][ 'type' ];
1521
+                                echo "\t\t* cleaned $x ($type) *" . PHP_EOL;
1522 1522
                             }
1523 1523
                         }
1524 1524
                     }
1525 1525
                 }//end if
1526 1526
 
1527 1527
                 continue;
1528
-            } else if ($this->tokens[$i]['code'] === T_CLASS && isset($this->tokens[$i]['scope_opener']) === true) {
1528
+            } else if ( $this->tokens[ $i ][ 'code' ] === T_CLASS && isset( $this->tokens[ $i ][ 'scope_opener' ] ) === true ) {
1529 1529
                 /*
1530 1530
                     Detect anonymous classes and assign them a different token.
1531 1531
                 */
1532 1532
 
1533
-                for ($x = ($i + 1); $x < $numTokens; $x++) {
1534
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1533
+                for ( $x = ( $i + 1 ); $x < $numTokens; $x++ ) {
1534
+                    if ( isset( Util\Tokens::$emptyTokens[ $this->tokens[ $x ][ 'code' ] ] ) === false ) {
1535 1535
                         break;
1536 1536
                     }
1537 1537
                 }
1538 1538
 
1539
-                if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS
1540
-                    || $this->tokens[$x]['code'] === T_OPEN_CURLY_BRACKET
1541
-                    || $this->tokens[$x]['code'] === T_EXTENDS
1542
-                    || $this->tokens[$x]['code'] === T_IMPLEMENTS
1539
+                if ( $this->tokens[ $x ][ 'code' ] === T_OPEN_PARENTHESIS
1540
+                    || $this->tokens[ $x ][ 'code' ] === T_OPEN_CURLY_BRACKET
1541
+                    || $this->tokens[ $x ][ 'code' ] === T_EXTENDS
1542
+                    || $this->tokens[ $x ][ 'code' ] === T_IMPLEMENTS
1543 1543
                 ) {
1544
-                    $this->tokens[$i]['code'] = T_ANON_CLASS;
1545
-                    $this->tokens[$i]['type'] = 'T_ANON_CLASS';
1546
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1547
-                        $line = $this->tokens[$i]['line'];
1548
-                        echo "\t* token $i on line $line changed from T_CLASS to T_ANON_CLASS".PHP_EOL;
1544
+                    $this->tokens[ $i ][ 'code' ] = T_ANON_CLASS;
1545
+                    $this->tokens[ $i ][ 'type' ] = 'T_ANON_CLASS';
1546
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1547
+                        $line = $this->tokens[ $i ][ 'line' ];
1548
+                        echo "\t* token $i on line $line changed from T_CLASS to T_ANON_CLASS" . PHP_EOL;
1549 1549
                     }
1550 1550
 
1551
-                    for ($x = ($this->tokens[$i]['scope_opener'] + 1); $x < $this->tokens[$i]['scope_closer']; $x++) {
1552
-                        if (isset($this->tokens[$x]['conditions'][$i]) === false) {
1551
+                    for ( $x = ( $this->tokens[ $i ][ 'scope_opener' ] + 1 ); $x < $this->tokens[ $i ][ 'scope_closer' ]; $x++ ) {
1552
+                        if ( isset( $this->tokens[ $x ][ 'conditions' ][ $i ] ) === false ) {
1553 1553
                             continue;
1554 1554
                         }
1555 1555
 
1556
-                        $this->tokens[$x]['conditions'][$i] = T_ANON_CLASS;
1557
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1558
-                            $type = $this->tokens[$x]['type'];
1559
-                            echo "\t\t* cleaned $x ($type) *".PHP_EOL;
1556
+                        $this->tokens[ $x ][ 'conditions' ][ $i ] = T_ANON_CLASS;
1557
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1558
+                            $type = $this->tokens[ $x ][ 'type' ];
1559
+                            echo "\t\t* cleaned $x ($type) *" . PHP_EOL;
1560 1560
                         }
1561 1561
                     }
1562 1562
                 }
1563 1563
 
1564 1564
                 continue;
1565
-            } else if ($this->tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) {
1566
-                if (isset($this->tokens[$i]['bracket_closer']) === false) {
1565
+            } else if ( $this->tokens[ $i ][ 'code' ] === T_OPEN_SQUARE_BRACKET ) {
1566
+                if ( isset( $this->tokens[ $i ][ 'bracket_closer' ] ) === false ) {
1567 1567
                     continue;
1568 1568
                 }
1569 1569
 
@@ -1580,17 +1580,17 @@  discard block
 block discarded – undo
1580 1580
                     T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING,
1581 1581
                 ];
1582 1582
 
1583
-                for ($x = ($i - 1); $x >= 0; $x--) {
1583
+                for ( $x = ( $i - 1 ); $x >= 0; $x-- ) {
1584 1584
                     // If we hit a scope opener, the statement has ended
1585 1585
                     // without finding anything, so it's probably an array
1586 1586
                     // using PHP 7.1 short list syntax.
1587
-                    if (isset($this->tokens[$x]['scope_opener']) === true) {
1587
+                    if ( isset( $this->tokens[ $x ][ 'scope_opener' ] ) === true ) {
1588 1588
                         $isShortArray = true;
1589 1589
                         break;
1590 1590
                     }
1591 1591
 
1592
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1593
-                        if (isset($allowed[$this->tokens[$x]['code']]) === false) {
1592
+                    if ( isset( Util\Tokens::$emptyTokens[ $this->tokens[ $x ][ 'code' ] ] ) === false ) {
1593
+                        if ( isset( $allowed[ $this->tokens[ $x ][ 'code' ] ] ) === false ) {
1594 1594
                             $isShortArray = true;
1595 1595
                         }
1596 1596
 
@@ -1598,46 +1598,46 @@  discard block
 block discarded – undo
1598 1598
                     }
1599 1599
                 }
1600 1600
 
1601
-                if ($isShortArray === true) {
1602
-                    $this->tokens[$i]['code'] = T_OPEN_SHORT_ARRAY;
1603
-                    $this->tokens[$i]['type'] = 'T_OPEN_SHORT_ARRAY';
1604
-
1605
-                    $closer = $this->tokens[$i]['bracket_closer'];
1606
-                    $this->tokens[$closer]['code'] = T_CLOSE_SHORT_ARRAY;
1607
-                    $this->tokens[$closer]['type'] = 'T_CLOSE_SHORT_ARRAY';
1608
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1609
-                        $line = $this->tokens[$i]['line'];
1610
-                        echo "\t* token $i on line $line changed from T_OPEN_SQUARE_BRACKET to T_OPEN_SHORT_ARRAY".PHP_EOL;
1611
-                        $line = $this->tokens[$closer]['line'];
1612
-                        echo "\t* token $closer on line $line changed from T_CLOSE_SQUARE_BRACKET to T_CLOSE_SHORT_ARRAY".PHP_EOL;
1601
+                if ( $isShortArray === true ) {
1602
+                    $this->tokens[ $i ][ 'code' ] = T_OPEN_SHORT_ARRAY;
1603
+                    $this->tokens[ $i ][ 'type' ] = 'T_OPEN_SHORT_ARRAY';
1604
+
1605
+                    $closer = $this->tokens[ $i ][ 'bracket_closer' ];
1606
+                    $this->tokens[ $closer ][ 'code' ] = T_CLOSE_SHORT_ARRAY;
1607
+                    $this->tokens[ $closer ][ 'type' ] = 'T_CLOSE_SHORT_ARRAY';
1608
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1609
+                        $line = $this->tokens[ $i ][ 'line' ];
1610
+                        echo "\t* token $i on line $line changed from T_OPEN_SQUARE_BRACKET to T_OPEN_SHORT_ARRAY" . PHP_EOL;
1611
+                        $line = $this->tokens[ $closer ][ 'line' ];
1612
+                        echo "\t* token $closer on line $line changed from T_CLOSE_SQUARE_BRACKET to T_CLOSE_SHORT_ARRAY" . PHP_EOL;
1613 1613
                     }
1614 1614
                 }
1615 1615
 
1616 1616
                 continue;
1617
-            } else if ($this->tokens[$i]['code'] === T_STATIC) {
1618
-                for ($x = ($i - 1); $x > 0; $x--) {
1619
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1617
+            } else if ( $this->tokens[ $i ][ 'code' ] === T_STATIC ) {
1618
+                for ( $x = ( $i - 1 ); $x > 0; $x-- ) {
1619
+                    if ( isset( Util\Tokens::$emptyTokens[ $this->tokens[ $x ][ 'code' ] ] ) === false ) {
1620 1620
                         break;
1621 1621
                     }
1622 1622
                 }
1623 1623
 
1624
-                if ($this->tokens[$x]['code'] === T_INSTANCEOF) {
1625
-                    $this->tokens[$i]['code'] = T_STRING;
1626
-                    $this->tokens[$i]['type'] = 'T_STRING';
1624
+                if ( $this->tokens[ $x ][ 'code' ] === T_INSTANCEOF ) {
1625
+                    $this->tokens[ $i ][ 'code' ] = T_STRING;
1626
+                    $this->tokens[ $i ][ 'type' ] = 'T_STRING';
1627 1627
 
1628
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1629
-                        $line = $this->tokens[$i]['line'];
1630
-                        echo "\t* token $i on line $line changed from T_STATIC to T_STRING".PHP_EOL;
1628
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1629
+                        $line = $this->tokens[ $i ][ 'line' ];
1630
+                        echo "\t* token $i on line $line changed from T_STATIC to T_STRING" . PHP_EOL;
1631 1631
                     }
1632 1632
                 }
1633 1633
 
1634 1634
                 continue;
1635
-            } else if ($this->tokens[$i]['code'] === T_TRUE
1636
-                || $this->tokens[$i]['code'] === T_FALSE
1637
-                || $this->tokens[$i]['code'] === T_NULL
1635
+            } else if ( $this->tokens[ $i ][ 'code' ] === T_TRUE
1636
+                || $this->tokens[ $i ][ 'code' ] === T_FALSE
1637
+                || $this->tokens[ $i ][ 'code' ] === T_NULL
1638 1638
             ) {
1639
-                for ($x = ($i + 1); $i < $numTokens; $x++) {
1640
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1639
+                for ( $x = ( $i + 1 ); $i < $numTokens; $x++ ) {
1640
+                    if ( isset( Util\Tokens::$emptyTokens[ $this->tokens[ $x ][ 'code' ] ] ) === false ) {
1641 1641
                         // Non-whitespace content.
1642 1642
                         break;
1643 1643
                     }
@@ -1648,78 +1648,78 @@  discard block
 block discarded – undo
1648 1648
                     T_NS_SEPARATOR         => true,
1649 1649
                     T_PAAMAYIM_NEKUDOTAYIM => true,
1650 1650
                 ];
1651
-                if (isset($context[$this->tokens[$x]['code']]) === true) {
1652
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1653
-                        $line = $this->tokens[$i]['line'];
1654
-                        $type = $this->tokens[$i]['type'];
1655
-                        echo "\t* token $i on line $line changed from $type to T_STRING".PHP_EOL;
1651
+                if ( isset( $context[ $this->tokens[ $x ][ 'code' ] ] ) === true ) {
1652
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1653
+                        $line = $this->tokens[ $i ][ 'line' ];
1654
+                        $type = $this->tokens[ $i ][ 'type' ];
1655
+                        echo "\t* token $i on line $line changed from $type to T_STRING" . PHP_EOL;
1656 1656
                     }
1657 1657
 
1658
-                    $this->tokens[$i]['code'] = T_STRING;
1659
-                    $this->tokens[$i]['type'] = 'T_STRING';
1658
+                    $this->tokens[ $i ][ 'code' ] = T_STRING;
1659
+                    $this->tokens[ $i ][ 'type' ] = 'T_STRING';
1660 1660
                 }
1661
-            } else if ($this->tokens[$i]['code'] === T_CONST) {
1661
+            } else if ( $this->tokens[ $i ][ 'code' ] === T_CONST ) {
1662 1662
                 // Context sensitive keywords support.
1663
-                for ($x = ($i + 1); $i < $numTokens; $x++) {
1664
-                    if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1663
+                for ( $x = ( $i + 1 ); $i < $numTokens; $x++ ) {
1664
+                    if ( isset( Util\Tokens::$emptyTokens[ $this->tokens[ $x ][ 'code' ] ] ) === false ) {
1665 1665
                         // Non-whitespace content.
1666 1666
                         break;
1667 1667
                     }
1668 1668
                 }
1669 1669
 
1670
-                if ($this->tokens[$x]['code'] !== T_STRING) {
1671
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1672
-                        $line = $this->tokens[$x]['line'];
1673
-                        $type = $this->tokens[$x]['type'];
1674
-                        echo "\t* token $x on line $line changed from $type to T_STRING".PHP_EOL;
1670
+                if ( $this->tokens[ $x ][ 'code' ] !== T_STRING ) {
1671
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1672
+                        $line = $this->tokens[ $x ][ 'line' ];
1673
+                        $type = $this->tokens[ $x ][ 'type' ];
1674
+                        echo "\t* token $x on line $line changed from $type to T_STRING" . PHP_EOL;
1675 1675
                     }
1676 1676
 
1677
-                    $this->tokens[$x]['code'] = T_STRING;
1678
-                    $this->tokens[$x]['type'] = 'T_STRING';
1677
+                    $this->tokens[ $x ][ 'code' ] = T_STRING;
1678
+                    $this->tokens[ $x ][ 'type' ] = 'T_STRING';
1679 1679
                 }
1680 1680
             }//end if
1681 1681
 
1682
-            if (($this->tokens[$i]['code'] !== T_CASE
1683
-                && $this->tokens[$i]['code'] !== T_DEFAULT)
1684
-                || isset($this->tokens[$i]['scope_opener']) === false
1682
+            if ( ( $this->tokens[ $i ][ 'code' ] !== T_CASE
1683
+                && $this->tokens[ $i ][ 'code' ] !== T_DEFAULT )
1684
+                || isset( $this->tokens[ $i ][ 'scope_opener' ] ) === false
1685 1685
             ) {
1686 1686
                 // Only interested in CASE and DEFAULT statements from here on in.
1687 1687
                 continue;
1688 1688
             }
1689 1689
 
1690
-            $scopeOpener = $this->tokens[$i]['scope_opener'];
1691
-            $scopeCloser = $this->tokens[$i]['scope_closer'];
1690
+            $scopeOpener = $this->tokens[ $i ][ 'scope_opener' ];
1691
+            $scopeCloser = $this->tokens[ $i ][ 'scope_closer' ];
1692 1692
 
1693 1693
             // If the first char after the opener is a curly brace
1694 1694
             // and that brace has been ignored, it is actually
1695 1695
             // opening this case statement and the opener and closer are
1696 1696
             // probably set incorrectly.
1697
-            for ($x = ($scopeOpener + 1); $x < $numTokens; $x++) {
1698
-                if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1697
+            for ( $x = ( $scopeOpener + 1 ); $x < $numTokens; $x++ ) {
1698
+                if ( isset( Util\Tokens::$emptyTokens[ $this->tokens[ $x ][ 'code' ] ] ) === false ) {
1699 1699
                     // Non-whitespace content.
1700 1700
                     break;
1701 1701
                 }
1702 1702
             }
1703 1703
 
1704
-            if ($this->tokens[$x]['code'] === T_CASE || $this->tokens[$x]['code'] === T_DEFAULT) {
1704
+            if ( $this->tokens[ $x ][ 'code' ] === T_CASE || $this->tokens[ $x ][ 'code' ] === T_DEFAULT ) {
1705 1705
                 // Special case for multiple CASE statements that share the same
1706 1706
                 // closer. Because we are going backwards through the file, this next
1707 1707
                 // CASE statement is already fixed, so just use its closer and don't
1708 1708
                 // worry about fixing anything.
1709
-                $newCloser = $this->tokens[$x]['scope_closer'];
1710
-                $this->tokens[$i]['scope_closer'] = $newCloser;
1711
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1712
-                    $oldType = $this->tokens[$scopeCloser]['type'];
1713
-                    $newType = $this->tokens[$newCloser]['type'];
1714
-                    $line    = $this->tokens[$i]['line'];
1715
-                    echo "\t* token $i (T_CASE) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
1709
+                $newCloser = $this->tokens[ $x ][ 'scope_closer' ];
1710
+                $this->tokens[ $i ][ 'scope_closer' ] = $newCloser;
1711
+                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1712
+                    $oldType = $this->tokens[ $scopeCloser ][ 'type' ];
1713
+                    $newType = $this->tokens[ $newCloser ][ 'type' ];
1714
+                    $line    = $this->tokens[ $i ][ 'line' ];
1715
+                    echo "\t* token $i (T_CASE) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)" . PHP_EOL;
1716 1716
                 }
1717 1717
 
1718 1718
                 continue;
1719 1719
             }
1720 1720
 
1721
-            if ($this->tokens[$x]['code'] !== T_OPEN_CURLY_BRACKET
1722
-                || isset($this->tokens[$x]['scope_condition']) === true
1721
+            if ( $this->tokens[ $x ][ 'code' ] !== T_OPEN_CURLY_BRACKET
1722
+                || isset( $this->tokens[ $x ][ 'scope_condition' ] ) === true
1723 1723
             ) {
1724 1724
                 // Not a CASE/DEFAULT with a curly brace opener.
1725 1725
                 continue;
@@ -1728,91 +1728,91 @@  discard block
 block discarded – undo
1728 1728
             // The closer for this CASE/DEFAULT should be the closing curly brace and
1729 1729
             // not whatever it already is. The opener needs to be the opening curly
1730 1730
             // brace so everything matches up.
1731
-            $newCloser = $this->tokens[$x]['bracket_closer'];
1732
-            foreach ([$i, $x, $newCloser] as $index) {
1733
-                $this->tokens[$index]['scope_condition'] = $i;
1734
-                $this->tokens[$index]['scope_opener']    = $x;
1735
-                $this->tokens[$index]['scope_closer']    = $newCloser;
1731
+            $newCloser = $this->tokens[ $x ][ 'bracket_closer' ];
1732
+            foreach ( [ $i, $x, $newCloser ] as $index ) {
1733
+                $this->tokens[ $index ][ 'scope_condition' ] = $i;
1734
+                $this->tokens[ $index ][ 'scope_opener' ]    = $x;
1735
+                $this->tokens[ $index ][ 'scope_closer' ]    = $newCloser;
1736 1736
             }
1737 1737
 
1738
-            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1739
-                $line      = $this->tokens[$i]['line'];
1740
-                $tokenType = $this->tokens[$i]['type'];
1738
+            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1739
+                $line      = $this->tokens[ $i ][ 'line' ];
1740
+                $tokenType = $this->tokens[ $i ][ 'type' ];
1741 1741
 
1742
-                $oldType = $this->tokens[$scopeOpener]['type'];
1743
-                $newType = $this->tokens[$x]['type'];
1744
-                echo "\t* token $i ($tokenType) on line $line opener changed from $scopeOpener ($oldType) to $x ($newType)".PHP_EOL;
1742
+                $oldType = $this->tokens[ $scopeOpener ][ 'type' ];
1743
+                $newType = $this->tokens[ $x ][ 'type' ];
1744
+                echo "\t* token $i ($tokenType) on line $line opener changed from $scopeOpener ($oldType) to $x ($newType)" . PHP_EOL;
1745 1745
 
1746
-                $oldType = $this->tokens[$scopeCloser]['type'];
1747
-                $newType = $this->tokens[$newCloser]['type'];
1748
-                echo "\t* token $i ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
1746
+                $oldType = $this->tokens[ $scopeCloser ][ 'type' ];
1747
+                $newType = $this->tokens[ $newCloser ][ 'type' ];
1748
+                echo "\t* token $i ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)" . PHP_EOL;
1749 1749
             }
1750 1750
 
1751
-            if ($this->tokens[$scopeOpener]['scope_condition'] === $i) {
1752
-                unset($this->tokens[$scopeOpener]['scope_condition']);
1753
-                unset($this->tokens[$scopeOpener]['scope_opener']);
1754
-                unset($this->tokens[$scopeOpener]['scope_closer']);
1751
+            if ( $this->tokens[ $scopeOpener ][ 'scope_condition' ] === $i ) {
1752
+                unset( $this->tokens[ $scopeOpener ][ 'scope_condition' ] );
1753
+                unset( $this->tokens[ $scopeOpener ][ 'scope_opener' ] );
1754
+                unset( $this->tokens[ $scopeOpener ][ 'scope_closer' ] );
1755 1755
             }
1756 1756
 
1757
-            if ($this->tokens[$scopeCloser]['scope_condition'] === $i) {
1758
-                unset($this->tokens[$scopeCloser]['scope_condition']);
1759
-                unset($this->tokens[$scopeCloser]['scope_opener']);
1760
-                unset($this->tokens[$scopeCloser]['scope_closer']);
1757
+            if ( $this->tokens[ $scopeCloser ][ 'scope_condition' ] === $i ) {
1758
+                unset( $this->tokens[ $scopeCloser ][ 'scope_condition' ] );
1759
+                unset( $this->tokens[ $scopeCloser ][ 'scope_opener' ] );
1760
+                unset( $this->tokens[ $scopeCloser ][ 'scope_closer' ] );
1761 1761
             } else {
1762 1762
                 // We were using a shared closer. All tokens that were
1763 1763
                 // sharing this closer with us, except for the scope condition
1764 1764
                 // and it's opener, need to now point to the new closer.
1765
-                $condition = $this->tokens[$scopeCloser]['scope_condition'];
1766
-                $start     = ($this->tokens[$condition]['scope_opener'] + 1);
1767
-                for ($y = $start; $y < $scopeCloser; $y++) {
1768
-                    if (isset($this->tokens[$y]['scope_closer']) === true
1769
-                        && $this->tokens[$y]['scope_closer'] === $scopeCloser
1765
+                $condition = $this->tokens[ $scopeCloser ][ 'scope_condition' ];
1766
+                $start     = ( $this->tokens[ $condition ][ 'scope_opener' ] + 1 );
1767
+                for ( $y = $start; $y < $scopeCloser; $y++ ) {
1768
+                    if ( isset( $this->tokens[ $y ][ 'scope_closer' ] ) === true
1769
+                        && $this->tokens[ $y ][ 'scope_closer' ] === $scopeCloser
1770 1770
                     ) {
1771
-                        $this->tokens[$y]['scope_closer'] = $newCloser;
1772
-
1773
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1774
-                            $line      = $this->tokens[$y]['line'];
1775
-                            $tokenType = $this->tokens[$y]['type'];
1776
-                            $oldType   = $this->tokens[$scopeCloser]['type'];
1777
-                            $newType   = $this->tokens[$newCloser]['type'];
1778
-                            echo "\t\t* token $y ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
1771
+                        $this->tokens[ $y ][ 'scope_closer' ] = $newCloser;
1772
+
1773
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1774
+                            $line      = $this->tokens[ $y ][ 'line' ];
1775
+                            $tokenType = $this->tokens[ $y ][ 'type' ];
1776
+                            $oldType   = $this->tokens[ $scopeCloser ][ 'type' ];
1777
+                            $newType   = $this->tokens[ $newCloser ][ 'type' ];
1778
+                            echo "\t\t* token $y ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)" . PHP_EOL;
1779 1779
                         }
1780 1780
                     }
1781 1781
                 }
1782 1782
             }//end if
1783 1783
 
1784
-            unset($this->tokens[$x]['bracket_opener']);
1785
-            unset($this->tokens[$x]['bracket_closer']);
1786
-            unset($this->tokens[$newCloser]['bracket_opener']);
1787
-            unset($this->tokens[$newCloser]['bracket_closer']);
1788
-            $this->tokens[$scopeCloser]['conditions'][] = $i;
1784
+            unset( $this->tokens[ $x ][ 'bracket_opener' ] );
1785
+            unset( $this->tokens[ $x ][ 'bracket_closer' ] );
1786
+            unset( $this->tokens[ $newCloser ][ 'bracket_opener' ] );
1787
+            unset( $this->tokens[ $newCloser ][ 'bracket_closer' ] );
1788
+            $this->tokens[ $scopeCloser ][ 'conditions' ][ ] = $i;
1789 1789
 
1790 1790
             // Now fix up all the tokens that think they are
1791 1791
             // inside the CASE/DEFAULT statement when they are really outside.
1792
-            for ($x = $newCloser; $x < $scopeCloser; $x++) {
1793
-                foreach ($this->tokens[$x]['conditions'] as $num => $oldCond) {
1794
-                    if ($oldCond === $this->tokens[$i]['code']) {
1795
-                        $oldConditions = $this->tokens[$x]['conditions'];
1796
-                        unset($this->tokens[$x]['conditions'][$num]);
1797
-
1798
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1799
-                            $type     = $this->tokens[$x]['type'];
1792
+            for ( $x = $newCloser; $x < $scopeCloser; $x++ ) {
1793
+                foreach ( $this->tokens[ $x ][ 'conditions' ] as $num => $oldCond ) {
1794
+                    if ( $oldCond === $this->tokens[ $i ][ 'code' ] ) {
1795
+                        $oldConditions = $this->tokens[ $x ][ 'conditions' ];
1796
+                        unset( $this->tokens[ $x ][ 'conditions' ][ $num ] );
1797
+
1798
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1799
+                            $type     = $this->tokens[ $x ][ 'type' ];
1800 1800
                             $oldConds = '';
1801
-                            foreach ($oldConditions as $condition) {
1802
-                                $oldConds .= Util\Tokens::tokenName($condition).',';
1801
+                            foreach ( $oldConditions as $condition ) {
1802
+                                $oldConds .= Util\Tokens::tokenName( $condition ) . ',';
1803 1803
                             }
1804 1804
 
1805
-                            $oldConds = rtrim($oldConds, ',');
1805
+                            $oldConds = rtrim( $oldConds, ',' );
1806 1806
 
1807 1807
                             $newConds = '';
1808
-                            foreach ($this->tokens[$x]['conditions'] as $condition) {
1809
-                                $newConds .= Util\Tokens::tokenName($condition).',';
1808
+                            foreach ( $this->tokens[ $x ][ 'conditions' ] as $condition ) {
1809
+                                $newConds .= Util\Tokens::tokenName( $condition ) . ',';
1810 1810
                             }
1811 1811
 
1812
-                            $newConds = rtrim($newConds, ',');
1812
+                            $newConds = rtrim( $newConds, ',' );
1813 1813
 
1814
-                            echo "\t\t* cleaned $x ($type) *".PHP_EOL;
1815
-                            echo "\t\t\t=> conditions changed from $oldConds to $newConds".PHP_EOL;
1814
+                            echo "\t\t* cleaned $x ($type) *" . PHP_EOL;
1815
+                            echo "\t\t\t=> conditions changed from $oldConds to $newConds" . PHP_EOL;
1816 1816
                         }
1817 1817
 
1818 1818
                         break;
@@ -1821,8 +1821,8 @@  discard block
 block discarded – undo
1821 1821
             }//end for
1822 1822
         }//end for
1823 1823
 
1824
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1825
-            echo "\t*** END ADDITIONAL PHP PROCESSING ***".PHP_EOL;
1824
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1825
+            echo "\t*** END ADDITIONAL PHP PROCESSING ***" . PHP_EOL;
1826 1826
         }
1827 1827
 
1828 1828
     }//end processAdditional()
@@ -1836,71 +1836,71 @@  discard block
 block discarded – undo
1836 1836
      *
1837 1837
      * @return array The new token.
1838 1838
      */
1839
-    public static function standardiseToken($token)
1839
+    public static function standardiseToken( $token )
1840 1840
     {
1841
-        if (isset($token[1]) === false) {
1842
-            if (isset(self::$resolveTokenCache[$token[0]]) === true) {
1843
-                return self::$resolveTokenCache[$token[0]];
1841
+        if ( isset( $token[ 1 ] ) === false ) {
1842
+            if ( isset( self::$resolveTokenCache[ $token[ 0 ] ] ) === true ) {
1843
+                return self::$resolveTokenCache[ $token[ 0 ] ];
1844 1844
             }
1845 1845
         } else {
1846 1846
             $cacheKey = null;
1847
-            if ($token[0] === T_STRING) {
1848
-                $cacheKey = strtolower($token[1]);
1849
-            } else if ($token[0] !== T_CURLY_OPEN) {
1850
-                $cacheKey = $token[0];
1847
+            if ( $token[ 0 ] === T_STRING ) {
1848
+                $cacheKey = strtolower( $token[ 1 ] );
1849
+            } else if ( $token[ 0 ] !== T_CURLY_OPEN ) {
1850
+                $cacheKey = $token[ 0 ];
1851 1851
             }
1852 1852
 
1853
-            if ($cacheKey !== null && isset(self::$resolveTokenCache[$cacheKey]) === true) {
1854
-                $newToken            = self::$resolveTokenCache[$cacheKey];
1855
-                $newToken['content'] = $token[1];
1853
+            if ( $cacheKey !== null && isset( self::$resolveTokenCache[ $cacheKey ] ) === true ) {
1854
+                $newToken            = self::$resolveTokenCache[ $cacheKey ];
1855
+                $newToken[ 'content' ] = $token[ 1 ];
1856 1856
                 return $newToken;
1857 1857
             }
1858 1858
         }
1859 1859
 
1860
-        if (isset($token[1]) === false) {
1861
-            return self::resolveSimpleToken($token[0]);
1860
+        if ( isset( $token[ 1 ] ) === false ) {
1861
+            return self::resolveSimpleToken( $token[ 0 ] );
1862 1862
         }
1863 1863
 
1864
-        if ($token[0] === T_STRING) {
1865
-            switch ($cacheKey) {
1864
+        if ( $token[ 0 ] === T_STRING ) {
1865
+            switch ( $cacheKey ) {
1866 1866
             case 'false':
1867
-                $newToken['type'] = 'T_FALSE';
1867
+                $newToken[ 'type' ] = 'T_FALSE';
1868 1868
                 break;
1869 1869
             case 'true':
1870
-                $newToken['type'] = 'T_TRUE';
1870
+                $newToken[ 'type' ] = 'T_TRUE';
1871 1871
                 break;
1872 1872
             case 'null':
1873
-                $newToken['type'] = 'T_NULL';
1873
+                $newToken[ 'type' ] = 'T_NULL';
1874 1874
                 break;
1875 1875
             case 'self':
1876
-                $newToken['type'] = 'T_SELF';
1876
+                $newToken[ 'type' ] = 'T_SELF';
1877 1877
                 break;
1878 1878
             case 'parent':
1879
-                $newToken['type'] = 'T_PARENT';
1879
+                $newToken[ 'type' ] = 'T_PARENT';
1880 1880
                 break;
1881 1881
             default:
1882
-                $newToken['type'] = 'T_STRING';
1882
+                $newToken[ 'type' ] = 'T_STRING';
1883 1883
                 break;
1884 1884
             }
1885 1885
 
1886
-            $newToken['code'] = constant($newToken['type']);
1886
+            $newToken[ 'code' ] = constant( $newToken[ 'type' ] );
1887 1887
 
1888
-            self::$resolveTokenCache[$cacheKey] = $newToken;
1889
-        } else if ($token[0] === T_CURLY_OPEN) {
1888
+            self::$resolveTokenCache[ $cacheKey ] = $newToken;
1889
+        } else if ( $token[ 0 ] === T_CURLY_OPEN ) {
1890 1890
             $newToken = [
1891 1891
                 'code' => T_OPEN_CURLY_BRACKET,
1892 1892
                 'type' => 'T_OPEN_CURLY_BRACKET',
1893 1893
             ];
1894 1894
         } else {
1895 1895
             $newToken = [
1896
-                'code' => $token[0],
1897
-                'type' => Util\Tokens::tokenName($token[0]),
1896
+                'code' => $token[ 0 ],
1897
+                'type' => Util\Tokens::tokenName( $token[ 0 ] ),
1898 1898
             ];
1899 1899
 
1900
-            self::$resolveTokenCache[$token[0]] = $newToken;
1900
+            self::$resolveTokenCache[ $token[ 0 ] ] = $newToken;
1901 1901
         }//end if
1902 1902
 
1903
-        $newToken['content'] = $token[1];
1903
+        $newToken[ 'content' ] = $token[ 1 ];
1904 1904
         return $newToken;
1905 1905
 
1906 1906
     }//end standardiseToken()
@@ -1917,98 +1917,98 @@  discard block
 block discarded – undo
1917 1917
      *
1918 1918
      * @return array The new token in array format.
1919 1919
      */
1920
-    public static function resolveSimpleToken($token)
1920
+    public static function resolveSimpleToken( $token )
1921 1921
     {
1922
-        $newToken = [];
1922
+        $newToken = [ ];
1923 1923
 
1924
-        switch ($token) {
1924
+        switch ( $token ) {
1925 1925
         case '{':
1926
-            $newToken['type'] = 'T_OPEN_CURLY_BRACKET';
1926
+            $newToken[ 'type' ] = 'T_OPEN_CURLY_BRACKET';
1927 1927
             break;
1928 1928
         case '}':
1929
-            $newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
1929
+            $newToken[ 'type' ] = 'T_CLOSE_CURLY_BRACKET';
1930 1930
             break;
1931 1931
         case '[':
1932
-            $newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
1932
+            $newToken[ 'type' ] = 'T_OPEN_SQUARE_BRACKET';
1933 1933
             break;
1934 1934
         case ']':
1935
-            $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
1935
+            $newToken[ 'type' ] = 'T_CLOSE_SQUARE_BRACKET';
1936 1936
             break;
1937 1937
         case '(':
1938
-            $newToken['type'] = 'T_OPEN_PARENTHESIS';
1938
+            $newToken[ 'type' ] = 'T_OPEN_PARENTHESIS';
1939 1939
             break;
1940 1940
         case ')':
1941
-            $newToken['type'] = 'T_CLOSE_PARENTHESIS';
1941
+            $newToken[ 'type' ] = 'T_CLOSE_PARENTHESIS';
1942 1942
             break;
1943 1943
         case ':':
1944
-            $newToken['type'] = 'T_COLON';
1944
+            $newToken[ 'type' ] = 'T_COLON';
1945 1945
             break;
1946 1946
         case '.':
1947
-            $newToken['type'] = 'T_STRING_CONCAT';
1947
+            $newToken[ 'type' ] = 'T_STRING_CONCAT';
1948 1948
             break;
1949 1949
         case ';':
1950
-            $newToken['type'] = 'T_SEMICOLON';
1950
+            $newToken[ 'type' ] = 'T_SEMICOLON';
1951 1951
             break;
1952 1952
         case '=':
1953
-            $newToken['type'] = 'T_EQUAL';
1953
+            $newToken[ 'type' ] = 'T_EQUAL';
1954 1954
             break;
1955 1955
         case '*':
1956
-            $newToken['type'] = 'T_MULTIPLY';
1956
+            $newToken[ 'type' ] = 'T_MULTIPLY';
1957 1957
             break;
1958 1958
         case '/':
1959
-            $newToken['type'] = 'T_DIVIDE';
1959
+            $newToken[ 'type' ] = 'T_DIVIDE';
1960 1960
             break;
1961 1961
         case '+':
1962
-            $newToken['type'] = 'T_PLUS';
1962
+            $newToken[ 'type' ] = 'T_PLUS';
1963 1963
             break;
1964 1964
         case '-':
1965
-            $newToken['type'] = 'T_MINUS';
1965
+            $newToken[ 'type' ] = 'T_MINUS';
1966 1966
             break;
1967 1967
         case '%':
1968
-            $newToken['type'] = 'T_MODULUS';
1968
+            $newToken[ 'type' ] = 'T_MODULUS';
1969 1969
             break;
1970 1970
         case '^':
1971
-            $newToken['type'] = 'T_BITWISE_XOR';
1971
+            $newToken[ 'type' ] = 'T_BITWISE_XOR';
1972 1972
             break;
1973 1973
         case '&':
1974
-            $newToken['type'] = 'T_BITWISE_AND';
1974
+            $newToken[ 'type' ] = 'T_BITWISE_AND';
1975 1975
             break;
1976 1976
         case '|':
1977
-            $newToken['type'] = 'T_BITWISE_OR';
1977
+            $newToken[ 'type' ] = 'T_BITWISE_OR';
1978 1978
             break;
1979 1979
         case '~':
1980
-            $newToken['type'] = 'T_BITWISE_NOT';
1980
+            $newToken[ 'type' ] = 'T_BITWISE_NOT';
1981 1981
             break;
1982 1982
         case '<':
1983
-            $newToken['type'] = 'T_LESS_THAN';
1983
+            $newToken[ 'type' ] = 'T_LESS_THAN';
1984 1984
             break;
1985 1985
         case '>':
1986
-            $newToken['type'] = 'T_GREATER_THAN';
1986
+            $newToken[ 'type' ] = 'T_GREATER_THAN';
1987 1987
             break;
1988 1988
         case '!':
1989
-            $newToken['type'] = 'T_BOOLEAN_NOT';
1989
+            $newToken[ 'type' ] = 'T_BOOLEAN_NOT';
1990 1990
             break;
1991 1991
         case ',':
1992
-            $newToken['type'] = 'T_COMMA';
1992
+            $newToken[ 'type' ] = 'T_COMMA';
1993 1993
             break;
1994 1994
         case '@':
1995
-            $newToken['type'] = 'T_ASPERAND';
1995
+            $newToken[ 'type' ] = 'T_ASPERAND';
1996 1996
             break;
1997 1997
         case '$':
1998
-            $newToken['type'] = 'T_DOLLAR';
1998
+            $newToken[ 'type' ] = 'T_DOLLAR';
1999 1999
             break;
2000 2000
         case '`':
2001
-            $newToken['type'] = 'T_BACKTICK';
2001
+            $newToken[ 'type' ] = 'T_BACKTICK';
2002 2002
             break;
2003 2003
         default:
2004
-            $newToken['type'] = 'T_NONE';
2004
+            $newToken[ 'type' ] = 'T_NONE';
2005 2005
             break;
2006 2006
         }//end switch
2007 2007
 
2008
-        $newToken['code']    = constant($newToken['type']);
2009
-        $newToken['content'] = $token;
2008
+        $newToken[ 'code' ]    = constant( $newToken[ 'type' ] );
2009
+        $newToken[ 'content' ] = $token;
2010 2010
 
2011
-        self::$resolveTokenCache[$token] = $newToken;
2011
+        self::$resolveTokenCache[ $token ] = $newToken;
2012 2012
         return $newToken;
2013 2013
 
2014 2014
     }//end resolveSimpleToken()
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 use PHP_CodeSniffer\Util;
13 13
 
14
-class PHP extends Tokenizer
15
-{
14
+class PHP extends Tokenizer {
16 15
 
17 16
 
18 17
     /**
@@ -453,8 +452,7 @@  discard block
 block discarded – undo
453 452
      *
454 453
      * @return array
455 454
      */
456
-    protected function tokenize($string)
457
-    {
455
+    protected function tokenize($string) {
458 456
         if (PHP_CODESNIFFER_VERBOSITY > 1) {
459 457
             echo "\t*** START PHP TOKENIZING ***".PHP_EOL;
460 458
             $isWin = false;
@@ -1472,8 +1470,7 @@  discard block
 block discarded – undo
1472 1470
      *
1473 1471
      * @return void
1474 1472
      */
1475
-    protected function processAdditional()
1476
-    {
1473
+    protected function processAdditional() {
1477 1474
         if (PHP_CODESNIFFER_VERBOSITY > 1) {
1478 1475
             echo "\t*** START ADDITIONAL PHP PROCESSING ***".PHP_EOL;
1479 1476
         }
@@ -1836,8 +1833,7 @@  discard block
 block discarded – undo
1836 1833
      *
1837 1834
      * @return array The new token.
1838 1835
      */
1839
-    public static function standardiseToken($token)
1840
-    {
1836
+    public static function standardiseToken($token) {
1841 1837
         if (isset($token[1]) === false) {
1842 1838
             if (isset(self::$resolveTokenCache[$token[0]]) === true) {
1843 1839
                 return self::$resolveTokenCache[$token[0]];
@@ -1917,8 +1913,7 @@  discard block
 block discarded – undo
1917 1913
      *
1918 1914
      * @return array The new token in array format.
1919 1915
      */
1920
-    public static function resolveSimpleToken($token)
1921
-    {
1916
+    public static function resolveSimpleToken($token) {
1922 1917
         $newToken = [];
1923 1918
 
1924 1919
         switch ($token) {
Please login to merge, or discard this patch.