Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
vendor/squizlabs/php_codesniffer/scripts/ValidatePEAR/FileList.php 1 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.
vendor/squizlabs/php_codesniffer/scripts/build-phar.php 1 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.
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 1 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.
vendor/squizlabs/php_codesniffer/src/Filters/ExactMatch.php 1 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.
vendor/squizlabs/php_codesniffer/src/Filters/GitModified.php 1 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.
vendor/squizlabs/php_codesniffer/src/Reporter.php 1 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.
vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php 1 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.
vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php 1 patch
Spacing   +649 added lines, -649 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @var string
29 29
      */
30
-    protected $eolChar = [];
30
+    protected $eolChar = [ ];
31 31
 
32 32
     /**
33 33
      * A token-based representation of the content.
34 34
      *
35 35
      * @var array
36 36
      */
37
-    protected $tokens = [];
37
+    protected $tokens = [ ];
38 38
 
39 39
     /**
40 40
      * The number of tokens in the tokens array.
@@ -48,28 +48,28 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @var array
50 50
      */
51
-    public $scopeOpeners = [];
51
+    public $scopeOpeners = [ ];
52 52
 
53 53
     /**
54 54
      * A list of tokens that end the scope.
55 55
      *
56 56
      * @var array
57 57
      */
58
-    public $endScopeTokens = [];
58
+    public $endScopeTokens = [ ];
59 59
 
60 60
     /**
61 61
      * Known lengths of tokens.
62 62
      *
63 63
      * @var array<int, int>
64 64
      */
65
-    public $knownLengths = [];
65
+    public $knownLengths = [ ];
66 66
 
67 67
     /**
68 68
      * A list of lines being ignored due to error suppression comments.
69 69
      *
70 70
      * @var array
71 71
      */
72
-    public $ignoredLines = [];
72
+    public $ignoredLines = [ ];
73 73
 
74 74
 
75 75
     /**
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
      * @return void
83 83
      * @throws \PHP_CodeSniffer\Exceptions\TokenizerException If the file appears to be minified.
84 84
      */
85
-    public function __construct($content, $config, $eolChar='\n')
85
+    public function __construct( $content, $config, $eolChar = '\n' )
86 86
     {
87 87
         $this->eolChar = $eolChar;
88 88
 
89 89
         $this->config = $config;
90
-        $this->tokens = $this->tokenize($content);
90
+        $this->tokens = $this->tokenize( $content );
91 91
 
92
-        if ($config === null) {
92
+        if ( $config === null ) {
93 93
             return;
94 94
         }
95 95
 
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @return boolean
115 115
      */
116
-    protected function isMinifiedContent($content, $eolChar='\n')
116
+    protected function isMinifiedContent( $content, $eolChar = '\n' )
117 117
     {
118 118
         // Minified files often have a very large number of characters per line
119 119
         // and cause issues when tokenizing.
120
-        $numChars = strlen($content);
121
-        $numLines = (substr_count($content, $eolChar) + 1);
122
-        $average  = ($numChars / $numLines);
123
-        if ($average > 100) {
120
+        $numChars = strlen( $content );
121
+        $numLines = ( substr_count( $content, $eolChar ) + 1 );
122
+        $average  = ( $numChars / $numLines );
123
+        if ( $average > 100 ) {
124 124
             return true;
125 125
         }
126 126
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      *
149 149
      * @return array
150 150
      */
151
-    abstract protected function tokenize($string);
151
+    abstract protected function tokenize( $string );
152 152
 
153 153
 
154 154
     /**
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
     {
172 172
         $currColumn = 1;
173 173
         $lineNumber = 1;
174
-        $eolLen     = strlen($this->eolChar);
174
+        $eolLen     = strlen( $this->eolChar );
175 175
         $ignoring   = null;
176
-        $inTests    = defined('PHP_CODESNIFFER_IN_TESTS');
176
+        $inTests    = defined( 'PHP_CODESNIFFER_IN_TESTS' );
177 177
 
178 178
         $checkEncoding = false;
179
-        if (function_exists('iconv_strlen') === true) {
179
+        if ( function_exists( 'iconv_strlen' ) === true ) {
180 180
             $checkEncoding = true;
181 181
         }
182 182
 
@@ -197,126 +197,126 @@  discard block
 block discarded – undo
197 197
             T_INLINE_HTML              => true,
198 198
         ];
199 199
 
200
-        $this->numTokens = count($this->tokens);
201
-        for ($i = 0; $i < $this->numTokens; $i++) {
202
-            $this->tokens[$i]['line']   = $lineNumber;
203
-            $this->tokens[$i]['column'] = $currColumn;
200
+        $this->numTokens = count( $this->tokens );
201
+        for ( $i = 0; $i < $this->numTokens; $i++ ) {
202
+            $this->tokens[ $i ][ 'line' ]   = $lineNumber;
203
+            $this->tokens[ $i ][ 'column' ] = $currColumn;
204 204
 
205
-            if (isset($this->knownLengths[$this->tokens[$i]['code']]) === true) {
205
+            if ( isset( $this->knownLengths[ $this->tokens[ $i ][ 'code' ] ] ) === true ) {
206 206
                 // There are no tabs in the tokens we know the length of.
207
-                $length      = $this->knownLengths[$this->tokens[$i]['code']];
207
+                $length      = $this->knownLengths[ $this->tokens[ $i ][ 'code' ] ];
208 208
                 $currColumn += $length;
209
-            } else if ($tabWidth === 0
210
-                || isset($tokensWithTabs[$this->tokens[$i]['code']]) === false
211
-                || strpos($this->tokens[$i]['content'], "\t") === false
209
+            } else if ( $tabWidth === 0
210
+                || isset( $tokensWithTabs[ $this->tokens[ $i ][ 'code' ] ] ) === false
211
+                || strpos( $this->tokens[ $i ][ 'content' ], "\t" ) === false
212 212
             ) {
213 213
                 // There are no tabs in this content, or we aren't replacing them.
214
-                if ($checkEncoding === true) {
214
+                if ( $checkEncoding === true ) {
215 215
                     // Not using the default encoding, so take a bit more care.
216 216
                     $oldLevel = error_reporting();
217
-                    error_reporting(0);
218
-                    $length = iconv_strlen($this->tokens[$i]['content'], $encoding);
219
-                    error_reporting($oldLevel);
217
+                    error_reporting( 0 );
218
+                    $length = iconv_strlen( $this->tokens[ $i ][ 'content' ], $encoding );
219
+                    error_reporting( $oldLevel );
220 220
 
221
-                    if ($length === false) {
221
+                    if ( $length === false ) {
222 222
                         // String contained invalid characters, so revert to default.
223
-                        $length = strlen($this->tokens[$i]['content']);
223
+                        $length = strlen( $this->tokens[ $i ][ 'content' ] );
224 224
                     }
225 225
                 } else {
226
-                    $length = strlen($this->tokens[$i]['content']);
226
+                    $length = strlen( $this->tokens[ $i ][ 'content' ] );
227 227
                 }
228 228
 
229 229
                 $currColumn += $length;
230 230
             } else {
231
-                $this->replaceTabsInToken($this->tokens[$i]);
232
-                $length      = $this->tokens[$i]['length'];
231
+                $this->replaceTabsInToken( $this->tokens[ $i ] );
232
+                $length      = $this->tokens[ $i ][ 'length' ];
233 233
                 $currColumn += $length;
234 234
             }//end if
235 235
 
236
-            $this->tokens[$i]['length'] = $length;
236
+            $this->tokens[ $i ][ 'length' ] = $length;
237 237
 
238
-            if (isset($this->knownLengths[$this->tokens[$i]['code']]) === false
239
-                && strpos($this->tokens[$i]['content'], $this->eolChar) !== false
238
+            if ( isset( $this->knownLengths[ $this->tokens[ $i ][ 'code' ] ] ) === false
239
+                && strpos( $this->tokens[ $i ][ 'content' ], $this->eolChar ) !== false
240 240
             ) {
241 241
                 $lineNumber++;
242 242
                 $currColumn = 1;
243 243
 
244 244
                 // Newline chars are not counted in the token length.
245
-                $this->tokens[$i]['length'] -= $eolLen;
245
+                $this->tokens[ $i ][ 'length' ] -= $eolLen;
246 246
             }
247 247
 
248
-            if ($this->tokens[$i]['code'] === T_COMMENT
249
-                || $this->tokens[$i]['code'] === T_DOC_COMMENT_STRING
250
-                || $this->tokens[$i]['code'] === T_DOC_COMMENT_TAG
251
-                || ($inTests === true && $this->tokens[$i]['code'] === T_INLINE_HTML)
248
+            if ( $this->tokens[ $i ][ 'code' ] === T_COMMENT
249
+                || $this->tokens[ $i ][ 'code' ] === T_DOC_COMMENT_STRING
250
+                || $this->tokens[ $i ][ 'code' ] === T_DOC_COMMENT_TAG
251
+                || ( $inTests === true && $this->tokens[ $i ][ 'code' ] === T_INLINE_HTML )
252 252
             ) {
253
-                $commentText      = ltrim($this->tokens[$i]['content'], " \t/*");
254
-                $commentText      = rtrim($commentText, " */\t\r\n");
255
-                $commentTextLower = strtolower($commentText);
256
-                if (strpos($commentText, '@codingStandards') !== false) {
253
+                $commentText      = ltrim( $this->tokens[ $i ][ 'content' ], " \t/*" );
254
+                $commentText      = rtrim( $commentText, " */\t\r\n" );
255
+                $commentTextLower = strtolower( $commentText );
256
+                if ( strpos( $commentText, '@codingStandards' ) !== false ) {
257 257
                     // If this comment is the only thing on the line, it tells us
258 258
                     // to ignore the following line. If the line contains other content
259 259
                     // then we are just ignoring this one single line.
260 260
                     $ownLine = false;
261
-                    if ($i > 0) {
262
-                        for ($prev = ($i - 1); $prev >= 0; $prev--) {
263
-                            if ($this->tokens[$prev]['code'] === T_WHITESPACE) {
261
+                    if ( $i > 0 ) {
262
+                        for ( $prev = ( $i - 1 ); $prev >= 0; $prev-- ) {
263
+                            if ( $this->tokens[ $prev ][ 'code' ] === T_WHITESPACE ) {
264 264
                                 continue;
265 265
                             }
266 266
 
267 267
                             break;
268 268
                         }
269 269
 
270
-                        if ($this->tokens[$prev]['line'] !== $this->tokens[$i]['line']) {
270
+                        if ( $this->tokens[ $prev ][ 'line' ] !== $this->tokens[ $i ][ 'line' ] ) {
271 271
                             $ownLine = true;
272 272
                         }
273 273
                     }
274 274
 
275
-                    if ($ignoring === null
276
-                        && strpos($commentText, '@codingStandardsIgnoreStart') !== false
275
+                    if ( $ignoring === null
276
+                        && strpos( $commentText, '@codingStandardsIgnoreStart' ) !== false
277 277
                     ) {
278
-                        $ignoring = ['.all' => true];
279
-                        if ($ownLine === true) {
280
-                            $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
278
+                        $ignoring = [ '.all' => true ];
279
+                        if ( $ownLine === true ) {
280
+                            $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = $ignoring;
281 281
                         }
282
-                    } else if ($ignoring !== null
283
-                        && strpos($commentText, '@codingStandardsIgnoreEnd') !== false
282
+                    } else if ( $ignoring !== null
283
+                        && strpos( $commentText, '@codingStandardsIgnoreEnd' ) !== false
284 284
                     ) {
285
-                        if ($ownLine === true) {
286
-                            $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true];
285
+                        if ( $ownLine === true ) {
286
+                            $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = [ '.all' => true ];
287 287
                         } else {
288
-                            $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
288
+                            $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = $ignoring;
289 289
                         }
290 290
 
291 291
                         $ignoring = null;
292
-                    } else if ($ignoring === null
293
-                        && strpos($commentText, '@codingStandardsIgnoreLine') !== false
292
+                    } else if ( $ignoring === null
293
+                        && strpos( $commentText, '@codingStandardsIgnoreLine' ) !== false
294 294
                     ) {
295
-                        $ignoring = ['.all' => true];
296
-                        if ($ownLine === true) {
297
-                            $this->ignoredLines[$this->tokens[$i]['line']]       = $ignoring;
298
-                            $this->ignoredLines[($this->tokens[$i]['line'] + 1)] = $ignoring;
295
+                        $ignoring = [ '.all' => true ];
296
+                        if ( $ownLine === true ) {
297
+                            $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ]       = $ignoring;
298
+                            $this->ignoredLines[ ( $this->tokens[ $i ][ 'line' ] + 1 ) ] = $ignoring;
299 299
                         } else {
300
-                            $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
300
+                            $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = $ignoring;
301 301
                         }
302 302
 
303 303
                         $ignoring = null;
304 304
                     }//end if
305
-                } else if (substr($commentTextLower, 0, 6) === 'phpcs:'
306
-                    || substr($commentTextLower, 0, 7) === '@phpcs:'
305
+                } else if ( substr( $commentTextLower, 0, 6 ) === 'phpcs:'
306
+                    || substr( $commentTextLower, 0, 7 ) === '@phpcs:'
307 307
                 ) {
308 308
                     // If the @phpcs: syntax is being used, strip the @ to make
309 309
                     // comparisons easier.
310
-                    if ($commentText[0] === '@') {
311
-                        $commentText      = substr($commentText, 1);
312
-                        $commentTextLower = strtolower($commentText);
310
+                    if ( $commentText[ 0 ] === '@' ) {
311
+                        $commentText      = substr( $commentText, 1 );
312
+                        $commentTextLower = strtolower( $commentText );
313 313
                     }
314 314
 
315 315
                     // If there is a comment on the end, strip it off.
316
-                    $commentStart = strpos($commentTextLower, ' --');
317
-                    if ($commentStart !== false) {
318
-                        $commentText      = substr($commentText, 0, $commentStart);
319
-                        $commentTextLower = strtolower($commentText);
316
+                    $commentStart = strpos( $commentTextLower, ' --' );
317
+                    if ( $commentStart !== false ) {
318
+                        $commentText      = substr( $commentText, 0, $commentStart );
319
+                        $commentTextLower = strtolower( $commentText );
320 320
                     }
321 321
 
322 322
                     // If this comment is the only thing on the line, it tells us
@@ -324,23 +324,23 @@  discard block
 block discarded – undo
324 324
                     // then we are just ignoring this one single line.
325 325
                     $lineHasOtherContent = false;
326 326
                     $lineHasOtherTokens  = false;
327
-                    if ($i > 0) {
328
-                        for ($prev = ($i - 1); $prev > 0; $prev--) {
329
-                            if ($this->tokens[$prev]['line'] !== $this->tokens[$i]['line']) {
327
+                    if ( $i > 0 ) {
328
+                        for ( $prev = ( $i - 1 ); $prev > 0; $prev-- ) {
329
+                            if ( $this->tokens[ $prev ][ 'line' ] !== $this->tokens[ $i ][ 'line' ] ) {
330 330
                                 // Changed lines.
331 331
                                 break;
332 332
                             }
333 333
 
334
-                            if ($this->tokens[$prev]['code'] === T_WHITESPACE
335
-                                || ($this->tokens[$prev]['code'] === T_INLINE_HTML
336
-                                && trim($this->tokens[$prev]['content']) === '')
334
+                            if ( $this->tokens[ $prev ][ 'code' ] === T_WHITESPACE
335
+                                || ( $this->tokens[ $prev ][ 'code' ] === T_INLINE_HTML
336
+                                && trim( $this->tokens[ $prev ][ 'content' ] ) === '' )
337 337
                             ) {
338 338
                                 continue;
339 339
                             }
340 340
 
341 341
                             $lineHasOtherTokens = true;
342 342
 
343
-                            if ($this->tokens[$prev]['code'] === T_OPEN_TAG) {
343
+                            if ( $this->tokens[ $prev ][ 'code' ] === T_OPEN_TAG ) {
344 344
                                 continue;
345 345
                             }
346 346
 
@@ -349,33 +349,33 @@  discard block
 block discarded – undo
349 349
                         }//end for
350 350
 
351 351
                         $changedLines = false;
352
-                        for ($next = $i; $next < $this->numTokens; $next++) {
353
-                            if ($changedLines === true) {
352
+                        for ( $next = $i; $next < $this->numTokens; $next++ ) {
353
+                            if ( $changedLines === true ) {
354 354
                                 // Changed lines.
355 355
                                 break;
356 356
                             }
357 357
 
358
-                            if (isset($this->knownLengths[$this->tokens[$next]['code']]) === false
359
-                                && strpos($this->tokens[$next]['content'], $this->eolChar) !== false
358
+                            if ( isset( $this->knownLengths[ $this->tokens[ $next ][ 'code' ] ] ) === false
359
+                                && strpos( $this->tokens[ $next ][ 'content' ], $this->eolChar ) !== false
360 360
                             ) {
361 361
                                 // Last token on the current line.
362 362
                                 $changedLines = true;
363 363
                             }
364 364
 
365
-                            if ($next === $i) {
365
+                            if ( $next === $i ) {
366 366
                                 continue;
367 367
                             }
368 368
 
369
-                            if ($this->tokens[$next]['code'] === T_WHITESPACE
370
-                                || ($this->tokens[$next]['code'] === T_INLINE_HTML
371
-                                && trim($this->tokens[$next]['content']) === '')
369
+                            if ( $this->tokens[ $next ][ 'code' ] === T_WHITESPACE
370
+                                || ( $this->tokens[ $next ][ 'code' ] === T_INLINE_HTML
371
+                                && trim( $this->tokens[ $next ][ 'content' ] ) === '' )
372 372
                             ) {
373 373
                                 continue;
374 374
                             }
375 375
 
376 376
                             $lineHasOtherTokens = true;
377 377
 
378
-                            if ($this->tokens[$next]['code'] === T_CLOSE_TAG) {
378
+                            if ( $this->tokens[ $next ][ 'code' ] === T_CLOSE_TAG ) {
379 379
                                 continue;
380 380
                             }
381 381
 
@@ -384,178 +384,178 @@  discard block
 block discarded – undo
384 384
                         }//end for
385 385
                     }//end if
386 386
 
387
-                    if (substr($commentTextLower, 0, 9) === 'phpcs:set') {
387
+                    if ( substr( $commentTextLower, 0, 9 ) === 'phpcs:set' ) {
388 388
                         // Ignore standards for complete lines that change sniff settings.
389
-                        if ($lineHasOtherTokens === false) {
390
-                            $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true];
389
+                        if ( $lineHasOtherTokens === false ) {
390
+                            $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = [ '.all' => true ];
391 391
                         }
392 392
 
393 393
                         // Need to maintain case here, to get the correct sniff code.
394
-                        $parts = explode(' ', substr($commentText, 10));
395
-                        if (count($parts) >= 2) {
396
-                            $sniffParts = explode('.', $parts[0]);
397
-                            if (count($sniffParts) >= 3) {
398
-                                $this->tokens[$i]['sniffCode']          = array_shift($parts);
399
-                                $this->tokens[$i]['sniffProperty']      = array_shift($parts);
400
-                                $this->tokens[$i]['sniffPropertyValue'] = rtrim(implode(' ', $parts), " */\r\n");
394
+                        $parts = explode( ' ', substr( $commentText, 10 ) );
395
+                        if ( count( $parts ) >= 2 ) {
396
+                            $sniffParts = explode( '.', $parts[ 0 ] );
397
+                            if ( count( $sniffParts ) >= 3 ) {
398
+                                $this->tokens[ $i ][ 'sniffCode' ]          = array_shift( $parts );
399
+                                $this->tokens[ $i ][ 'sniffProperty' ]      = array_shift( $parts );
400
+                                $this->tokens[ $i ][ 'sniffPropertyValue' ] = rtrim( implode( ' ', $parts ), " */\r\n" );
401 401
                             }
402 402
                         }
403 403
 
404
-                        $this->tokens[$i]['code'] = T_PHPCS_SET;
405
-                        $this->tokens[$i]['type'] = 'T_PHPCS_SET';
406
-                    } else if (substr($commentTextLower, 0, 16) === 'phpcs:ignorefile') {
404
+                        $this->tokens[ $i ][ 'code' ] = T_PHPCS_SET;
405
+                        $this->tokens[ $i ][ 'type' ] = 'T_PHPCS_SET';
406
+                    } else if ( substr( $commentTextLower, 0, 16 ) === 'phpcs:ignorefile' ) {
407 407
                         // The whole file will be ignored, but at least set the correct token.
408
-                        $this->tokens[$i]['code'] = T_PHPCS_IGNORE_FILE;
409
-                        $this->tokens[$i]['type'] = 'T_PHPCS_IGNORE_FILE';
410
-                    } else if (substr($commentTextLower, 0, 13) === 'phpcs:disable') {
411
-                        if ($lineHasOtherContent === false) {
408
+                        $this->tokens[ $i ][ 'code' ] = T_PHPCS_IGNORE_FILE;
409
+                        $this->tokens[ $i ][ 'type' ] = 'T_PHPCS_IGNORE_FILE';
410
+                    } else if ( substr( $commentTextLower, 0, 13 ) === 'phpcs:disable' ) {
411
+                        if ( $lineHasOtherContent === false ) {
412 412
                             // Completely ignore the comment line.
413
-                            $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true];
413
+                            $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = [ '.all' => true ];
414 414
                         }
415 415
 
416
-                        if ($ignoring === null) {
417
-                            $ignoring = [];
416
+                        if ( $ignoring === null ) {
417
+                            $ignoring = [ ];
418 418
                         }
419 419
 
420
-                        $disabledSniffs = [];
420
+                        $disabledSniffs = [ ];
421 421
 
422
-                        $additionalText = substr($commentText, 14);
423
-                        if ($additionalText === false) {
424
-                            $ignoring = ['.all' => true];
422
+                        $additionalText = substr( $commentText, 14 );
423
+                        if ( $additionalText === false ) {
424
+                            $ignoring = [ '.all' => true ];
425 425
                         } else {
426
-                            $parts = explode(',', substr($commentText, 13));
427
-                            foreach ($parts as $sniffCode) {
428
-                                $sniffCode = trim($sniffCode);
429
-                                $disabledSniffs[$sniffCode] = true;
430
-                                $ignoring[$sniffCode]       = true;
426
+                            $parts = explode( ',', substr( $commentText, 13 ) );
427
+                            foreach ( $parts as $sniffCode ) {
428
+                                $sniffCode = trim( $sniffCode );
429
+                                $disabledSniffs[ $sniffCode ] = true;
430
+                                $ignoring[ $sniffCode ]       = true;
431 431
 
432 432
                                 // This newly disabled sniff might be disabling an existing
433 433
                                 // enabled exception that we are tracking.
434
-                                if (isset($ignoring['.except']) === true) {
435
-                                    foreach (array_keys($ignoring['.except']) as $ignoredSniffCode) {
436
-                                        if ($ignoredSniffCode === $sniffCode
437
-                                            || strpos($ignoredSniffCode, $sniffCode.'.') === 0
434
+                                if ( isset( $ignoring[ '.except' ] ) === true ) {
435
+                                    foreach ( array_keys( $ignoring[ '.except' ] ) as $ignoredSniffCode ) {
436
+                                        if ( $ignoredSniffCode === $sniffCode
437
+                                            || strpos( $ignoredSniffCode, $sniffCode . '.' ) === 0
438 438
                                         ) {
439
-                                            unset($ignoring['.except'][$ignoredSniffCode]);
439
+                                            unset( $ignoring[ '.except' ][ $ignoredSniffCode ] );
440 440
                                         }
441 441
                                     }
442 442
 
443
-                                    if (empty($ignoring['.except']) === true) {
444
-                                        unset($ignoring['.except']);
443
+                                    if ( empty( $ignoring[ '.except' ] ) === true ) {
444
+                                        unset( $ignoring[ '.except' ] );
445 445
                                     }
446 446
                                 }
447 447
                             }//end foreach
448 448
                         }//end if
449 449
 
450
-                        $this->tokens[$i]['code']       = T_PHPCS_DISABLE;
451
-                        $this->tokens[$i]['type']       = 'T_PHPCS_DISABLE';
452
-                        $this->tokens[$i]['sniffCodes'] = $disabledSniffs;
453
-                    } else if (substr($commentTextLower, 0, 12) === 'phpcs:enable') {
454
-                        if ($ignoring !== null) {
455
-                            $enabledSniffs = [];
450
+                        $this->tokens[ $i ][ 'code' ]       = T_PHPCS_DISABLE;
451
+                        $this->tokens[ $i ][ 'type' ]       = 'T_PHPCS_DISABLE';
452
+                        $this->tokens[ $i ][ 'sniffCodes' ] = $disabledSniffs;
453
+                    } else if ( substr( $commentTextLower, 0, 12 ) === 'phpcs:enable' ) {
454
+                        if ( $ignoring !== null ) {
455
+                            $enabledSniffs = [ ];
456 456
 
457
-                            $additionalText = substr($commentText, 13);
458
-                            if ($additionalText === false) {
457
+                            $additionalText = substr( $commentText, 13 );
458
+                            if ( $additionalText === false ) {
459 459
                                 $ignoring = null;
460 460
                             } else {
461
-                                $parts = explode(',', substr($commentText, 13));
462
-                                foreach ($parts as $sniffCode) {
463
-                                    $sniffCode = trim($sniffCode);
464
-                                    $enabledSniffs[$sniffCode] = true;
461
+                                $parts = explode( ',', substr( $commentText, 13 ) );
462
+                                foreach ( $parts as $sniffCode ) {
463
+                                    $sniffCode = trim( $sniffCode );
464
+                                    $enabledSniffs[ $sniffCode ] = true;
465 465
 
466 466
                                     // This new enabled sniff might remove previously disabled
467 467
                                     // sniffs if it is actually a standard or category of sniffs.
468
-                                    foreach (array_keys($ignoring) as $ignoredSniffCode) {
469
-                                        if ($ignoredSniffCode === $sniffCode
470
-                                            || strpos($ignoredSniffCode, $sniffCode.'.') === 0
468
+                                    foreach ( array_keys( $ignoring ) as $ignoredSniffCode ) {
469
+                                        if ( $ignoredSniffCode === $sniffCode
470
+                                            || strpos( $ignoredSniffCode, $sniffCode . '.' ) === 0
471 471
                                         ) {
472
-                                            unset($ignoring[$ignoredSniffCode]);
472
+                                            unset( $ignoring[ $ignoredSniffCode ] );
473 473
                                         }
474 474
                                     }
475 475
 
476 476
                                     // This new enabled sniff might be able to clear up
477 477
                                     // previously enabled sniffs if it is actually a standard or
478 478
                                     // category of sniffs.
479
-                                    if (isset($ignoring['.except']) === true) {
480
-                                        foreach (array_keys($ignoring['.except']) as $ignoredSniffCode) {
481
-                                            if ($ignoredSniffCode === $sniffCode
482
-                                                || strpos($ignoredSniffCode, $sniffCode.'.') === 0
479
+                                    if ( isset( $ignoring[ '.except' ] ) === true ) {
480
+                                        foreach ( array_keys( $ignoring[ '.except' ] ) as $ignoredSniffCode ) {
481
+                                            if ( $ignoredSniffCode === $sniffCode
482
+                                                || strpos( $ignoredSniffCode, $sniffCode . '.' ) === 0
483 483
                                             ) {
484
-                                                unset($ignoring['.except'][$ignoredSniffCode]);
484
+                                                unset( $ignoring[ '.except' ][ $ignoredSniffCode ] );
485 485
                                             }
486 486
                                         }
487 487
                                     }
488 488
                                 }//end foreach
489 489
 
490
-                                if (empty($ignoring) === true) {
490
+                                if ( empty( $ignoring ) === true ) {
491 491
                                     $ignoring = null;
492 492
                                 } else {
493
-                                    if (isset($ignoring['.except']) === true) {
494
-                                        $ignoring['.except'] += $enabledSniffs;
493
+                                    if ( isset( $ignoring[ '.except' ] ) === true ) {
494
+                                        $ignoring[ '.except' ] += $enabledSniffs;
495 495
                                     } else {
496
-                                        $ignoring['.except'] = $enabledSniffs;
496
+                                        $ignoring[ '.except' ] = $enabledSniffs;
497 497
                                     }
498 498
                                 }
499 499
                             }//end if
500 500
 
501
-                            if ($lineHasOtherContent === false) {
501
+                            if ( $lineHasOtherContent === false ) {
502 502
                                 // Completely ignore the comment line.
503
-                                $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true];
503
+                                $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = [ '.all' => true ];
504 504
                             } else {
505 505
                                 // The comment is on the same line as the code it is ignoring,
506 506
                                 // so respect the new ignore rules.
507
-                                $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
507
+                                $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = $ignoring;
508 508
                             }
509 509
 
510
-                            $this->tokens[$i]['sniffCodes'] = $enabledSniffs;
510
+                            $this->tokens[ $i ][ 'sniffCodes' ] = $enabledSniffs;
511 511
                         }//end if
512 512
 
513
-                        $this->tokens[$i]['code'] = T_PHPCS_ENABLE;
514
-                        $this->tokens[$i]['type'] = 'T_PHPCS_ENABLE';
515
-                    } else if (substr($commentTextLower, 0, 12) === 'phpcs:ignore') {
516
-                        $ignoreRules = [];
513
+                        $this->tokens[ $i ][ 'code' ] = T_PHPCS_ENABLE;
514
+                        $this->tokens[ $i ][ 'type' ] = 'T_PHPCS_ENABLE';
515
+                    } else if ( substr( $commentTextLower, 0, 12 ) === 'phpcs:ignore' ) {
516
+                        $ignoreRules = [ ];
517 517
 
518
-                        $additionalText = substr($commentText, 13);
519
-                        if ($additionalText === false) {
520
-                            $ignoreRules = ['.all' => true];
518
+                        $additionalText = substr( $commentText, 13 );
519
+                        if ( $additionalText === false ) {
520
+                            $ignoreRules = [ '.all' => true ];
521 521
                         } else {
522
-                            $parts = explode(',', substr($commentText, 13));
523
-                            foreach ($parts as $sniffCode) {
524
-                                $ignoreRules[trim($sniffCode)] = true;
522
+                            $parts = explode( ',', substr( $commentText, 13 ) );
523
+                            foreach ( $parts as $sniffCode ) {
524
+                                $ignoreRules[ trim( $sniffCode ) ] = true;
525 525
                             }
526 526
                         }
527 527
 
528
-                        $this->tokens[$i]['code']       = T_PHPCS_IGNORE;
529
-                        $this->tokens[$i]['type']       = 'T_PHPCS_IGNORE';
530
-                        $this->tokens[$i]['sniffCodes'] = $ignoreRules;
528
+                        $this->tokens[ $i ][ 'code' ]       = T_PHPCS_IGNORE;
529
+                        $this->tokens[ $i ][ 'type' ]       = 'T_PHPCS_IGNORE';
530
+                        $this->tokens[ $i ][ 'sniffCodes' ] = $ignoreRules;
531 531
 
532
-                        if ($ignoring !== null) {
532
+                        if ( $ignoring !== null ) {
533 533
                             $ignoreRules += $ignoring;
534 534
                         }
535 535
 
536
-                        if ($lineHasOtherContent === false) {
536
+                        if ( $lineHasOtherContent === false ) {
537 537
                             // Completely ignore the comment line, and set the following
538 538
                             // line to include the ignore rules we've set.
539
-                            $this->ignoredLines[$this->tokens[$i]['line']]       = ['.all' => true];
540
-                            $this->ignoredLines[($this->tokens[$i]['line'] + 1)] = $ignoreRules;
539
+                            $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ]       = [ '.all' => true ];
540
+                            $this->ignoredLines[ ( $this->tokens[ $i ][ 'line' ] + 1 ) ] = $ignoreRules;
541 541
                         } else {
542 542
                             // The comment is on the same line as the code it is ignoring,
543 543
                             // so respect the ignore rules it set.
544
-                            $this->ignoredLines[$this->tokens[$i]['line']] = $ignoreRules;
544
+                            $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = $ignoreRules;
545 545
                         }
546 546
                     }//end if
547 547
                 }//end if
548 548
             }//end if
549 549
 
550
-            if ($ignoring !== null && isset($this->ignoredLines[$this->tokens[$i]['line']]) === false) {
551
-                $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
550
+            if ( $ignoring !== null && isset( $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] ) === false ) {
551
+                $this->ignoredLines[ $this->tokens[ $i ][ 'line' ] ] = $ignoring;
552 552
             }
553 553
         }//end for
554 554
 
555 555
         // If annotations are being ignored, we clear out all the ignore rules
556 556
         // but leave the annotations tokenized as normal.
557
-        if ($checkAnnotations === false) {
558
-            $this->ignoredLines = [];
557
+        if ( $checkAnnotations === false ) {
558
+            $this->ignoredLines = [ ];
559 559
         }
560 560
 
561 561
     }//end createPositionMap()
@@ -576,52 +576,52 @@  discard block
 block discarded – undo
576 576
      *
577 577
      * @return void
578 578
      */
579
-    public function replaceTabsInToken(&$token, $prefix=' ', $padding=' ', $tabWidth=null)
579
+    public function replaceTabsInToken( &$token, $prefix = ' ', $padding = ' ', $tabWidth = null )
580 580
     {
581 581
         $checkEncoding = false;
582
-        if (function_exists('iconv_strlen') === true) {
582
+        if ( function_exists( 'iconv_strlen' ) === true ) {
583 583
             $checkEncoding = true;
584 584
         }
585 585
 
586
-        $currColumn = $token['column'];
587
-        if ($tabWidth === null) {
586
+        $currColumn = $token[ 'column' ];
587
+        if ( $tabWidth === null ) {
588 588
             $tabWidth = $this->config->tabWidth;
589
-            if ($tabWidth === 0) {
589
+            if ( $tabWidth === 0 ) {
590 590
                 $tabWidth = 1;
591 591
             }
592 592
         }
593 593
 
594
-        if (rtrim($token['content'], "\t") === '') {
594
+        if ( rtrim( $token[ 'content' ], "\t" ) === '' ) {
595 595
             // String only contains tabs, so we can shortcut the process.
596
-            $numTabs = strlen($token['content']);
596
+            $numTabs = strlen( $token[ 'content' ] );
597 597
 
598
-            $firstTabSize = ($tabWidth - (($currColumn - 1) % $tabWidth));
599
-            $length       = ($firstTabSize + ($tabWidth * ($numTabs - 1)));
600
-            $newContent   = $prefix.str_repeat($padding, ($length - 1));
598
+            $firstTabSize = ( $tabWidth - ( ( $currColumn - 1 ) % $tabWidth ) );
599
+            $length       = ( $firstTabSize + ( $tabWidth * ( $numTabs - 1 ) ) );
600
+            $newContent   = $prefix . str_repeat( $padding, ( $length - 1 ) );
601 601
         } else {
602 602
             // We need to determine the length of each tab.
603
-            $tabs = explode("\t", $token['content']);
603
+            $tabs = explode( "\t", $token[ 'content' ] );
604 604
 
605
-            $numTabs    = (count($tabs) - 1);
605
+            $numTabs    = ( count( $tabs ) - 1 );
606 606
             $tabNum     = 0;
607 607
             $newContent = '';
608 608
             $length     = 0;
609 609
 
610
-            foreach ($tabs as $content) {
611
-                if ($content !== '') {
610
+            foreach ( $tabs as $content ) {
611
+                if ( $content !== '' ) {
612 612
                     $newContent .= $content;
613
-                    if ($checkEncoding === true) {
613
+                    if ( $checkEncoding === true ) {
614 614
                         // Not using the default encoding, so take a bit more care.
615 615
                         $oldLevel = error_reporting();
616
-                        error_reporting(0);
617
-                        $contentLength = iconv_strlen($content, $this->config->encoding);
618
-                        error_reporting($oldLevel);
619
-                        if ($contentLength === false) {
616
+                        error_reporting( 0 );
617
+                        $contentLength = iconv_strlen( $content, $this->config->encoding );
618
+                        error_reporting( $oldLevel );
619
+                        if ( $contentLength === false ) {
620 620
                             // String contained invalid characters, so revert to default.
621
-                            $contentLength = strlen($content);
621
+                            $contentLength = strlen( $content );
622 622
                         }
623 623
                     } else {
624
-                        $contentLength = strlen($content);
624
+                        $contentLength = strlen( $content );
625 625
                     }
626 626
 
627 627
                     $currColumn += $contentLength;
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
                 }
630 630
 
631 631
                 // The last piece of content does not have a tab after it.
632
-                if ($tabNum === $numTabs) {
632
+                if ( $tabNum === $numTabs ) {
633 633
                     break;
634 634
                 }
635 635
 
@@ -638,27 +638,27 @@  discard block
 block discarded – undo
638 638
                 $tabNum++;
639 639
 
640 640
                 // Move the pointer to the next tab stop.
641
-                if (($currColumn % $tabWidth) === 0) {
641
+                if ( ( $currColumn % $tabWidth ) === 0 ) {
642 642
                     // This is the first tab, and we are already at a
643 643
                     // tab stop, so this tab counts as a single space.
644 644
                     $currColumn++;
645 645
                 } else {
646 646
                     $currColumn++;
647
-                    while (($currColumn % $tabWidth) !== 0) {
647
+                    while ( ( $currColumn % $tabWidth ) !== 0 ) {
648 648
                         $currColumn++;
649 649
                     }
650 650
 
651 651
                     $currColumn++;
652 652
                 }
653 653
 
654
-                $length     += ($currColumn - $lastCurrColumn);
655
-                $newContent .= $prefix.str_repeat($padding, ($currColumn - $lastCurrColumn - 1));
654
+                $length     += ( $currColumn - $lastCurrColumn );
655
+                $newContent .= $prefix . str_repeat( $padding, ( $currColumn - $lastCurrColumn - 1 ) );
656 656
             }//end foreach
657 657
         }//end if
658 658
 
659
-        $token['orig_content'] = $token['content'];
660
-        $token['content']      = $newContent;
661
-        $token['length']       = $length;
659
+        $token[ 'orig_content' ] = $token[ 'content' ];
660
+        $token[ 'content' ]      = $newContent;
661
+        $token[ 'length' ]       = $length;
662 662
 
663 663
     }//end replaceTabsInToken()
664 664
 
@@ -670,50 +670,50 @@  discard block
 block discarded – undo
670 670
      */
671 671
     private function createTokenMap()
672 672
     {
673
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
674
-            echo "\t*** START TOKEN MAP ***".PHP_EOL;
673
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
674
+            echo "\t*** START TOKEN MAP ***" . PHP_EOL;
675 675
         }
676 676
 
677
-        $squareOpeners   = [];
678
-        $curlyOpeners    = [];
679
-        $this->numTokens = count($this->tokens);
677
+        $squareOpeners   = [ ];
678
+        $curlyOpeners    = [ ];
679
+        $this->numTokens = count( $this->tokens );
680 680
 
681
-        $openers   = [];
681
+        $openers   = [ ];
682 682
         $openOwner = null;
683 683
 
684
-        for ($i = 0; $i < $this->numTokens; $i++) {
684
+        for ( $i = 0; $i < $this->numTokens; $i++ ) {
685 685
             /*
686 686
                 Parenthesis mapping.
687 687
             */
688 688
 
689
-            if (isset(Util\Tokens::$parenthesisOpeners[$this->tokens[$i]['code']]) === true) {
690
-                $this->tokens[$i]['parenthesis_opener'] = null;
691
-                $this->tokens[$i]['parenthesis_closer'] = null;
692
-                $this->tokens[$i]['parenthesis_owner']  = $i;
689
+            if ( isset( Util\Tokens::$parenthesisOpeners[ $this->tokens[ $i ][ 'code' ] ] ) === true ) {
690
+                $this->tokens[ $i ][ 'parenthesis_opener' ] = null;
691
+                $this->tokens[ $i ][ 'parenthesis_closer' ] = null;
692
+                $this->tokens[ $i ][ 'parenthesis_owner' ]  = $i;
693 693
                 $openOwner = $i;
694
-            } else if ($this->tokens[$i]['code'] === T_OPEN_PARENTHESIS) {
695
-                $openers[] = $i;
696
-                $this->tokens[$i]['parenthesis_opener'] = $i;
697
-                if ($openOwner !== null) {
698
-                    $this->tokens[$openOwner]['parenthesis_opener'] = $i;
699
-                    $this->tokens[$i]['parenthesis_owner']          = $openOwner;
694
+            } else if ( $this->tokens[ $i ][ 'code' ] === T_OPEN_PARENTHESIS ) {
695
+                $openers[ ] = $i;
696
+                $this->tokens[ $i ][ 'parenthesis_opener' ] = $i;
697
+                if ( $openOwner !== null ) {
698
+                    $this->tokens[ $openOwner ][ 'parenthesis_opener' ] = $i;
699
+                    $this->tokens[ $i ][ 'parenthesis_owner' ]          = $openOwner;
700 700
                     $openOwner = null;
701 701
                 }
702
-            } else if ($this->tokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
702
+            } else if ( $this->tokens[ $i ][ 'code' ] === T_CLOSE_PARENTHESIS ) {
703 703
                 // Did we set an owner for this set of parenthesis?
704
-                $numOpeners = count($openers);
705
-                if ($numOpeners !== 0) {
706
-                    $opener = array_pop($openers);
707
-                    if (isset($this->tokens[$opener]['parenthesis_owner']) === true) {
708
-                        $owner = $this->tokens[$opener]['parenthesis_owner'];
709
-
710
-                        $this->tokens[$owner]['parenthesis_closer'] = $i;
711
-                        $this->tokens[$i]['parenthesis_owner']      = $owner;
704
+                $numOpeners = count( $openers );
705
+                if ( $numOpeners !== 0 ) {
706
+                    $opener = array_pop( $openers );
707
+                    if ( isset( $this->tokens[ $opener ][ 'parenthesis_owner' ] ) === true ) {
708
+                        $owner = $this->tokens[ $opener ][ 'parenthesis_owner' ];
709
+
710
+                        $this->tokens[ $owner ][ 'parenthesis_closer' ] = $i;
711
+                        $this->tokens[ $i ][ 'parenthesis_owner' ]      = $owner;
712 712
                     }
713 713
 
714
-                    $this->tokens[$i]['parenthesis_opener']      = $opener;
715
-                    $this->tokens[$i]['parenthesis_closer']      = $i;
716
-                    $this->tokens[$opener]['parenthesis_closer'] = $i;
714
+                    $this->tokens[ $i ][ 'parenthesis_opener' ]      = $opener;
715
+                    $this->tokens[ $i ][ 'parenthesis_closer' ]      = $i;
716
+                    $this->tokens[ $opener ][ 'parenthesis_closer' ] = $i;
717 717
                 }
718 718
             }//end if
719 719
 
@@ -721,56 +721,56 @@  discard block
 block discarded – undo
721 721
                 Bracket mapping.
722 722
             */
723 723
 
724
-            switch ($this->tokens[$i]['code']) {
724
+            switch ( $this->tokens[ $i ][ 'code' ] ) {
725 725
             case T_OPEN_SQUARE_BRACKET:
726
-                $squareOpeners[] = $i;
726
+                $squareOpeners[ ] = $i;
727 727
 
728
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
729
-                    echo str_repeat("\t", count($squareOpeners));
730
-                    echo str_repeat("\t", count($curlyOpeners));
731
-                    echo "=> Found square bracket opener at $i".PHP_EOL;
728
+                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
729
+                    echo str_repeat( "\t", count( $squareOpeners ) );
730
+                    echo str_repeat( "\t", count( $curlyOpeners ) );
731
+                    echo "=> Found square bracket opener at $i" . PHP_EOL;
732 732
                 }
733 733
                 break;
734 734
             case T_OPEN_CURLY_BRACKET:
735
-                if (isset($this->tokens[$i]['scope_closer']) === false) {
736
-                    $curlyOpeners[] = $i;
735
+                if ( isset( $this->tokens[ $i ][ 'scope_closer' ] ) === false ) {
736
+                    $curlyOpeners[ ] = $i;
737 737
 
738
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
739
-                        echo str_repeat("\t", count($squareOpeners));
740
-                        echo str_repeat("\t", count($curlyOpeners));
741
-                        echo "=> Found curly bracket opener at $i".PHP_EOL;
738
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
739
+                        echo str_repeat( "\t", count( $squareOpeners ) );
740
+                        echo str_repeat( "\t", count( $curlyOpeners ) );
741
+                        echo "=> Found curly bracket opener at $i" . PHP_EOL;
742 742
                     }
743 743
                 }
744 744
                 break;
745 745
             case T_CLOSE_SQUARE_BRACKET:
746
-                if (empty($squareOpeners) === false) {
747
-                    $opener = array_pop($squareOpeners);
748
-                    $this->tokens[$i]['bracket_opener']      = $opener;
749
-                    $this->tokens[$i]['bracket_closer']      = $i;
750
-                    $this->tokens[$opener]['bracket_opener'] = $opener;
751
-                    $this->tokens[$opener]['bracket_closer'] = $i;
752
-
753
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
754
-                        echo str_repeat("\t", count($squareOpeners));
755
-                        echo str_repeat("\t", count($curlyOpeners));
756
-                        echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL;
746
+                if ( empty( $squareOpeners ) === false ) {
747
+                    $opener = array_pop( $squareOpeners );
748
+                    $this->tokens[ $i ][ 'bracket_opener' ]      = $opener;
749
+                    $this->tokens[ $i ][ 'bracket_closer' ]      = $i;
750
+                    $this->tokens[ $opener ][ 'bracket_opener' ] = $opener;
751
+                    $this->tokens[ $opener ][ 'bracket_closer' ] = $i;
752
+
753
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
754
+                        echo str_repeat( "\t", count( $squareOpeners ) );
755
+                        echo str_repeat( "\t", count( $curlyOpeners ) );
756
+                        echo "\t=> Found square bracket closer at $i for $opener" . PHP_EOL;
757 757
                     }
758 758
                 }
759 759
                 break;
760 760
             case T_CLOSE_CURLY_BRACKET:
761
-                if (empty($curlyOpeners) === false
762
-                    && isset($this->tokens[$i]['scope_opener']) === false
761
+                if ( empty( $curlyOpeners ) === false
762
+                    && isset( $this->tokens[ $i ][ 'scope_opener' ] ) === false
763 763
                 ) {
764
-                    $opener = array_pop($curlyOpeners);
765
-                    $this->tokens[$i]['bracket_opener']      = $opener;
766
-                    $this->tokens[$i]['bracket_closer']      = $i;
767
-                    $this->tokens[$opener]['bracket_opener'] = $opener;
768
-                    $this->tokens[$opener]['bracket_closer'] = $i;
769
-
770
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
771
-                        echo str_repeat("\t", count($squareOpeners));
772
-                        echo str_repeat("\t", count($curlyOpeners));
773
-                        echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL;
764
+                    $opener = array_pop( $curlyOpeners );
765
+                    $this->tokens[ $i ][ 'bracket_opener' ]      = $opener;
766
+                    $this->tokens[ $i ][ 'bracket_closer' ]      = $i;
767
+                    $this->tokens[ $opener ][ 'bracket_opener' ] = $opener;
768
+                    $this->tokens[ $opener ][ 'bracket_closer' ] = $i;
769
+
770
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
771
+                        echo str_repeat( "\t", count( $squareOpeners ) );
772
+                        echo str_repeat( "\t", count( $curlyOpeners ) );
773
+                        echo "\t=> Found curly bracket closer at $i for $opener" . PHP_EOL;
774 774
                     }
775 775
                 }
776 776
                 break;
@@ -781,13 +781,13 @@  discard block
 block discarded – undo
781 781
 
782 782
         // Cleanup for any openers that we didn't find closers for.
783 783
         // This typically means there was a syntax error breaking things.
784
-        foreach ($openers as $opener) {
785
-            unset($this->tokens[$opener]['parenthesis_opener']);
786
-            unset($this->tokens[$opener]['parenthesis_owner']);
784
+        foreach ( $openers as $opener ) {
785
+            unset( $this->tokens[ $opener ][ 'parenthesis_opener' ] );
786
+            unset( $this->tokens[ $opener ][ 'parenthesis_owner' ] );
787 787
         }
788 788
 
789
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
790
-            echo "\t*** END TOKEN MAP ***".PHP_EOL;
789
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
790
+            echo "\t*** END TOKEN MAP ***" . PHP_EOL;
791 791
         }
792 792
 
793 793
     }//end createTokenMap()
@@ -800,29 +800,29 @@  discard block
 block discarded – undo
800 800
      */
801 801
     private function createParenthesisNestingMap()
802 802
     {
803
-        $map = [];
804
-        for ($i = 0; $i < $this->numTokens; $i++) {
805
-            if (isset($this->tokens[$i]['parenthesis_opener']) === true
806
-                && $i === $this->tokens[$i]['parenthesis_opener']
803
+        $map = [ ];
804
+        for ( $i = 0; $i < $this->numTokens; $i++ ) {
805
+            if ( isset( $this->tokens[ $i ][ 'parenthesis_opener' ] ) === true
806
+                && $i === $this->tokens[ $i ][ 'parenthesis_opener' ]
807 807
             ) {
808
-                if (empty($map) === false) {
809
-                    $this->tokens[$i]['nested_parenthesis'] = $map;
808
+                if ( empty( $map ) === false ) {
809
+                    $this->tokens[ $i ][ 'nested_parenthesis' ] = $map;
810 810
                 }
811 811
 
812
-                if (isset($this->tokens[$i]['parenthesis_closer']) === true) {
813
-                    $map[$this->tokens[$i]['parenthesis_opener']]
814
-                        = $this->tokens[$i]['parenthesis_closer'];
812
+                if ( isset( $this->tokens[ $i ][ 'parenthesis_closer' ] ) === true ) {
813
+                    $map[ $this->tokens[ $i ][ 'parenthesis_opener' ] ]
814
+                        = $this->tokens[ $i ][ 'parenthesis_closer' ];
815 815
                 }
816
-            } else if (isset($this->tokens[$i]['parenthesis_closer']) === true
817
-                && $i === $this->tokens[$i]['parenthesis_closer']
816
+            } else if ( isset( $this->tokens[ $i ][ 'parenthesis_closer' ] ) === true
817
+                && $i === $this->tokens[ $i ][ 'parenthesis_closer' ]
818 818
             ) {
819
-                array_pop($map);
820
-                if (empty($map) === false) {
821
-                    $this->tokens[$i]['nested_parenthesis'] = $map;
819
+                array_pop( $map );
820
+                if ( empty( $map ) === false ) {
821
+                    $this->tokens[ $i ][ 'nested_parenthesis' ] = $map;
822 822
                 }
823 823
             } else {
824
-                if (empty($map) === false) {
825
-                    $this->tokens[$i]['nested_parenthesis'] = $map;
824
+                if ( empty( $map ) === false ) {
825
+                    $this->tokens[ $i ][ 'nested_parenthesis' ] = $map;
826 826
                 }
827 827
             }//end if
828 828
         }//end for
@@ -838,33 +838,33 @@  discard block
 block discarded – undo
838 838
      */
839 839
     private function createScopeMap()
840 840
     {
841
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
842
-            echo "\t*** START SCOPE MAP ***".PHP_EOL;
841
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
842
+            echo "\t*** START SCOPE MAP ***" . PHP_EOL;
843 843
         }
844 844
 
845
-        for ($i = 0; $i < $this->numTokens; $i++) {
845
+        for ( $i = 0; $i < $this->numTokens; $i++ ) {
846 846
             // Check to see if the current token starts a new scope.
847
-            if (isset($this->scopeOpeners[$this->tokens[$i]['code']]) === true) {
848
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
849
-                    $type    = $this->tokens[$i]['type'];
850
-                    $content = Util\Common::prepareForOutput($this->tokens[$i]['content']);
851
-                    echo "\tStart scope map at $i:$type => $content".PHP_EOL;
847
+            if ( isset( $this->scopeOpeners[ $this->tokens[ $i ][ 'code' ] ] ) === true ) {
848
+                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
849
+                    $type    = $this->tokens[ $i ][ 'type' ];
850
+                    $content = Util\Common::prepareForOutput( $this->tokens[ $i ][ 'content' ] );
851
+                    echo "\tStart scope map at $i:$type => $content" . PHP_EOL;
852 852
                 }
853 853
 
854
-                if (isset($this->tokens[$i]['scope_condition']) === true) {
855
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
856
-                        echo "\t* already processed, skipping *".PHP_EOL;
854
+                if ( isset( $this->tokens[ $i ][ 'scope_condition' ] ) === true ) {
855
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
856
+                        echo "\t* already processed, skipping *" . PHP_EOL;
857 857
                     }
858 858
 
859 859
                     continue;
860 860
                 }
861 861
 
862
-                $i = $this->recurseScopeMap($i);
862
+                $i = $this->recurseScopeMap( $i );
863 863
             }//end if
864 864
         }//end for
865 865
 
866
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
867
-            echo "\t*** END SCOPE MAP ***".PHP_EOL;
866
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
867
+            echo "\t*** END SCOPE MAP ***" . PHP_EOL;
868 868
         }
869 869
 
870 870
     }//end createScopeMap()
@@ -880,16 +880,16 @@  discard block
 block discarded – undo
880 880
      *
881 881
      * @return int The position in the stack that closed the scope.
882 882
      */
883
-    private function recurseScopeMap($stackPtr, $depth=1, &$ignore=0)
883
+    private function recurseScopeMap( $stackPtr, $depth = 1, &$ignore = 0 )
884 884
     {
885
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
886
-            echo str_repeat("\t", $depth);
887
-            echo "=> Begin scope map recursion at token $stackPtr with depth $depth".PHP_EOL;
885
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
886
+            echo str_repeat( "\t", $depth );
887
+            echo "=> Begin scope map recursion at token $stackPtr with depth $depth" . PHP_EOL;
888 888
         }
889 889
 
890 890
         $opener    = null;
891
-        $currType  = $this->tokens[$stackPtr]['code'];
892
-        $startLine = $this->tokens[$stackPtr]['line'];
891
+        $currType  = $this->tokens[ $stackPtr ][ 'code' ];
892
+        $startLine = $this->tokens[ $stackPtr ][ 'line' ];
893 893
 
894 894
         // We will need this to restore the value if we end up
895 895
         // returning a token ID that causes our calling function to go back
@@ -898,29 +898,29 @@  discard block
 block discarded – undo
898 898
 
899 899
         // If the start token for this scope opener is the same as
900 900
         // the scope token, we have already found our opener.
901
-        if (isset($this->scopeOpeners[$currType]['start'][$currType]) === true) {
901
+        if ( isset( $this->scopeOpeners[ $currType ][ 'start' ][ $currType ] ) === true ) {
902 902
             $opener = $stackPtr;
903 903
         }
904 904
 
905
-        for ($i = ($stackPtr + 1); $i < $this->numTokens; $i++) {
906
-            $tokenType = $this->tokens[$i]['code'];
905
+        for ( $i = ( $stackPtr + 1 ); $i < $this->numTokens; $i++ ) {
906
+            $tokenType = $this->tokens[ $i ][ 'code' ];
907 907
 
908
-            if (PHP_CODESNIFFER_VERBOSITY > 1) {
909
-                $type    = $this->tokens[$i]['type'];
910
-                $line    = $this->tokens[$i]['line'];
911
-                $content = Util\Common::prepareForOutput($this->tokens[$i]['content']);
908
+            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
909
+                $type    = $this->tokens[ $i ][ 'type' ];
910
+                $line    = $this->tokens[ $i ][ 'line' ];
911
+                $content = Util\Common::prepareForOutput( $this->tokens[ $i ][ 'content' ] );
912 912
 
913
-                echo str_repeat("\t", $depth);
913
+                echo str_repeat( "\t", $depth );
914 914
                 echo "Process token $i on line $line [";
915
-                if ($opener !== null) {
915
+                if ( $opener !== null ) {
916 916
                     echo "opener:$opener;";
917 917
                 }
918 918
 
919
-                if ($ignore > 0) {
919
+                if ( $ignore > 0 ) {
920 920
                     echo "ignore=$ignore;";
921 921
                 }
922 922
 
923
-                echo "]: $type => $content".PHP_EOL;
923
+                echo "]: $type => $content" . PHP_EOL;
924 924
             }//end if
925 925
 
926 926
             // Very special case for IF statements in PHP that can be defined without
@@ -929,21 +929,21 @@  discard block
 block discarded – undo
929 929
             // keyword, the opener will be incorrectly assigned to this IF statement.
930 930
             // The same case also applies to USE statements, which don't have to have
931 931
             // openers, so a following USE statement can cause an incorrect brace match.
932
-            if (($currType === T_IF || $currType === T_ELSE || $currType === T_USE)
932
+            if ( ( $currType === T_IF || $currType === T_ELSE || $currType === T_USE )
933 933
                 && $opener === null
934
-                && ($this->tokens[$i]['code'] === T_SEMICOLON
935
-                || $this->tokens[$i]['code'] === T_CLOSE_TAG)
934
+                && ( $this->tokens[ $i ][ 'code' ] === T_SEMICOLON
935
+                || $this->tokens[ $i ][ 'code' ] === T_CLOSE_TAG )
936 936
             ) {
937
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
938
-                    $type = $this->tokens[$stackPtr]['type'];
939
-                    echo str_repeat("\t", $depth);
940
-                    if ($this->tokens[$i]['code'] === T_SEMICOLON) {
937
+                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
938
+                    $type = $this->tokens[ $stackPtr ][ 'type' ];
939
+                    echo str_repeat( "\t", $depth );
940
+                    if ( $this->tokens[ $i ][ 'code' ] === T_SEMICOLON ) {
941 941
                         $closerType = 'semicolon';
942 942
                     } else {
943 943
                         $closerType = 'close tag';
944 944
                     }
945 945
 
946
-                    echo "=> Found $closerType before scope opener for $stackPtr:$type, bailing".PHP_EOL;
946
+                    echo "=> Found $closerType before scope opener for $stackPtr:$type, bailing" . PHP_EOL;
947 947
                 }
948 948
 
949 949
                 return $i;
@@ -953,45 +953,45 @@  discard block
 block discarded – undo
953 953
             // If we find a curly brace closer before we find the opener,
954 954
             // we're not going to find an opener. That closer probably belongs to
955 955
             // a control structure higher up.
956
-            if ($opener === null
956
+            if ( $opener === null
957 957
                 && $ignore === 0
958 958
                 && $tokenType === T_CLOSE_CURLY_BRACKET
959
-                && isset($this->scopeOpeners[$currType]['end'][$tokenType]) === true
959
+                && isset( $this->scopeOpeners[ $currType ][ 'end' ][ $tokenType ] ) === true
960 960
             ) {
961
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
962
-                    $type = $this->tokens[$stackPtr]['type'];
963
-                    echo str_repeat("\t", $depth);
964
-                    echo "=> Found curly brace closer before scope opener for $stackPtr:$type, bailing".PHP_EOL;
961
+                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
962
+                    $type = $this->tokens[ $stackPtr ][ 'type' ];
963
+                    echo str_repeat( "\t", $depth );
964
+                    echo "=> Found curly brace closer before scope opener for $stackPtr:$type, bailing" . PHP_EOL;
965 965
                 }
966 966
 
967
-                return ($i - 1);
967
+                return ( $i - 1 );
968 968
             }
969 969
 
970
-            if ($opener !== null
971
-                && (isset($this->tokens[$i]['scope_opener']) === false
972
-                || $this->scopeOpeners[$this->tokens[$stackPtr]['code']]['shared'] === true)
973
-                && isset($this->scopeOpeners[$currType]['end'][$tokenType]) === true
970
+            if ( $opener !== null
971
+                && ( isset( $this->tokens[ $i ][ 'scope_opener' ] ) === false
972
+                || $this->scopeOpeners[ $this->tokens[ $stackPtr ][ 'code' ] ][ 'shared' ] === true )
973
+                && isset( $this->scopeOpeners[ $currType ][ 'end' ][ $tokenType ] ) === true
974 974
             ) {
975
-                if ($ignore > 0 && $tokenType === T_CLOSE_CURLY_BRACKET) {
975
+                if ( $ignore > 0 && $tokenType === T_CLOSE_CURLY_BRACKET ) {
976 976
                     // The last opening bracket must have been for a string
977 977
                     // offset or alike, so let's ignore it.
978
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
979
-                        echo str_repeat("\t", $depth);
980
-                        echo '* finished ignoring curly brace *'.PHP_EOL;
978
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
979
+                        echo str_repeat( "\t", $depth );
980
+                        echo '* finished ignoring curly brace *' . PHP_EOL;
981 981
                     }
982 982
 
983 983
                     $ignore--;
984 984
                     continue;
985
-                } else if ($this->tokens[$opener]['code'] === T_OPEN_CURLY_BRACKET
985
+                } else if ( $this->tokens[ $opener ][ 'code' ] === T_OPEN_CURLY_BRACKET
986 986
                     && $tokenType !== T_CLOSE_CURLY_BRACKET
987 987
                 ) {
988 988
                     // The opener is a curly bracket so the closer must be a curly bracket as well.
989 989
                     // We ignore this closer to handle cases such as T_ELSE or T_ELSEIF being considered
990 990
                     // a closer of T_IF when it should not.
991
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
992
-                        $type = $this->tokens[$stackPtr]['type'];
993
-                        echo str_repeat("\t", $depth);
994
-                        echo "=> Ignoring non-curly scope closer for $stackPtr:$type".PHP_EOL;
991
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
992
+                        $type = $this->tokens[ $stackPtr ][ 'type' ];
993
+                        echo str_repeat( "\t", $depth );
994
+                        echo "=> Ignoring non-curly scope closer for $stackPtr:$type" . PHP_EOL;
995 995
                     }
996 996
                 } else {
997 997
                     $scopeCloser = $i;
@@ -1000,63 +1000,63 @@  discard block
 block discarded – undo
1000 1000
                         $opener,
1001 1001
                     ];
1002 1002
 
1003
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1004
-                        $type       = $this->tokens[$stackPtr]['type'];
1005
-                        $closerType = $this->tokens[$scopeCloser]['type'];
1006
-                        echo str_repeat("\t", $depth);
1007
-                        echo "=> Found scope closer ($scopeCloser:$closerType) for $stackPtr:$type".PHP_EOL;
1003
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1004
+                        $type       = $this->tokens[ $stackPtr ][ 'type' ];
1005
+                        $closerType = $this->tokens[ $scopeCloser ][ 'type' ];
1006
+                        echo str_repeat( "\t", $depth );
1007
+                        echo "=> Found scope closer ($scopeCloser:$closerType) for $stackPtr:$type" . PHP_EOL;
1008 1008
                     }
1009 1009
 
1010 1010
                     $validCloser = true;
1011
-                    if (($this->tokens[$stackPtr]['code'] === T_IF || $this->tokens[$stackPtr]['code'] === T_ELSEIF)
1012
-                        && ($tokenType === T_ELSE || $tokenType === T_ELSEIF)
1011
+                    if ( ( $this->tokens[ $stackPtr ][ 'code' ] === T_IF || $this->tokens[ $stackPtr ][ 'code' ] === T_ELSEIF )
1012
+                        && ( $tokenType === T_ELSE || $tokenType === T_ELSEIF )
1013 1013
                     ) {
1014 1014
                         // To be a closer, this token must have an opener.
1015
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1016
-                            echo str_repeat("\t", $depth);
1017
-                            echo "* closer needs to be tested *".PHP_EOL;
1015
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1016
+                            echo str_repeat( "\t", $depth );
1017
+                            echo "* closer needs to be tested *" . PHP_EOL;
1018 1018
                         }
1019 1019
 
1020
-                        $i = self::recurseScopeMap($i, ($depth + 1), $ignore);
1020
+                        $i = self::recurseScopeMap( $i, ( $depth + 1 ), $ignore );
1021 1021
 
1022
-                        if (isset($this->tokens[$scopeCloser]['scope_opener']) === false) {
1022
+                        if ( isset( $this->tokens[ $scopeCloser ][ 'scope_opener' ] ) === false ) {
1023 1023
                             $validCloser = false;
1024
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1025
-                                echo str_repeat("\t", $depth);
1026
-                                echo "* closer is not valid (no opener found) *".PHP_EOL;
1024
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1025
+                                echo str_repeat( "\t", $depth );
1026
+                                echo "* closer is not valid (no opener found) *" . PHP_EOL;
1027 1027
                             }
1028
-                        } else if ($this->tokens[$this->tokens[$scopeCloser]['scope_opener']]['code'] !== $this->tokens[$opener]['code']) {
1028
+                        } else if ( $this->tokens[ $this->tokens[ $scopeCloser ][ 'scope_opener' ] ][ 'code' ] !== $this->tokens[ $opener ][ 'code' ] ) {
1029 1029
                             $validCloser = false;
1030
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1031
-                                echo str_repeat("\t", $depth);
1032
-                                $type       = $this->tokens[$this->tokens[$scopeCloser]['scope_opener']]['type'];
1033
-                                $openerType = $this->tokens[$opener]['type'];
1034
-                                echo "* closer is not valid (mismatched opener type; $type != $openerType) *".PHP_EOL;
1030
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1031
+                                echo str_repeat( "\t", $depth );
1032
+                                $type       = $this->tokens[ $this->tokens[ $scopeCloser ][ 'scope_opener' ] ][ 'type' ];
1033
+                                $openerType = $this->tokens[ $opener ][ 'type' ];
1034
+                                echo "* closer is not valid (mismatched opener type; $type != $openerType) *" . PHP_EOL;
1035 1035
                             }
1036
-                        } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
1037
-                            echo str_repeat("\t", $depth);
1038
-                            echo "* closer was valid *".PHP_EOL;
1036
+                        } else if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1037
+                            echo str_repeat( "\t", $depth );
1038
+                            echo "* closer was valid *" . PHP_EOL;
1039 1039
                         }
1040 1040
                     } else {
1041 1041
                         // The closer was not processed, so we need to
1042 1042
                         // complete that token as well.
1043
-                        $todo[] = $scopeCloser;
1043
+                        $todo[ ] = $scopeCloser;
1044 1044
                     }//end if
1045 1045
 
1046
-                    if ($validCloser === true) {
1047
-                        foreach ($todo as $token) {
1048
-                            $this->tokens[$token]['scope_condition'] = $stackPtr;
1049
-                            $this->tokens[$token]['scope_opener']    = $opener;
1050
-                            $this->tokens[$token]['scope_closer']    = $scopeCloser;
1046
+                    if ( $validCloser === true ) {
1047
+                        foreach ( $todo as $token ) {
1048
+                            $this->tokens[ $token ][ 'scope_condition' ] = $stackPtr;
1049
+                            $this->tokens[ $token ][ 'scope_opener' ]    = $opener;
1050
+                            $this->tokens[ $token ][ 'scope_closer' ]    = $scopeCloser;
1051 1051
                         }
1052 1052
 
1053
-                        if ($this->scopeOpeners[$this->tokens[$stackPtr]['code']]['shared'] === true) {
1053
+                        if ( $this->scopeOpeners[ $this->tokens[ $stackPtr ][ 'code' ] ][ 'shared' ] === true ) {
1054 1054
                             // As we are going back to where we started originally, restore
1055 1055
                             // the ignore value back to its original value.
1056 1056
                             $ignore = $originalIgnore;
1057 1057
                             return $opener;
1058
-                        } else if ($scopeCloser === $i
1059
-                            && isset($this->scopeOpeners[$tokenType]) === true
1058
+                        } else if ( $scopeCloser === $i
1059
+                            && isset( $this->scopeOpeners[ $tokenType ] ) === true
1060 1060
                         ) {
1061 1061
                             // Unset scope_condition here or else the token will appear to have
1062 1062
                             // already been processed, and it will be skipped. Normally we want that,
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
                             // it needs to act like an opener. This is also why we return the
1065 1065
                             // token before this one; so the closer has a chance to be processed
1066 1066
                             // a second time, but as an opener.
1067
-                            unset($this->tokens[$scopeCloser]['scope_condition']);
1068
-                            return ($i - 1);
1067
+                            unset( $this->tokens[ $scopeCloser ][ 'scope_condition' ] );
1068
+                            return ( $i - 1 );
1069 1069
                         } else {
1070 1070
                             return $i;
1071 1071
                         }
@@ -1076,151 +1076,151 @@  discard block
 block discarded – undo
1076 1076
             }//end if
1077 1077
 
1078 1078
             // Is this an opening condition ?
1079
-            if (isset($this->scopeOpeners[$tokenType]) === true) {
1080
-                if ($opener === null) {
1081
-                    if ($tokenType === T_USE) {
1079
+            if ( isset( $this->scopeOpeners[ $tokenType ] ) === true ) {
1080
+                if ( $opener === null ) {
1081
+                    if ( $tokenType === T_USE ) {
1082 1082
                         // PHP use keywords are special because they can be
1083 1083
                         // used as blocks but also inline in function definitions.
1084 1084
                         // So if we find them nested inside another opener, just skip them.
1085 1085
                         continue;
1086 1086
                     }
1087 1087
 
1088
-                    if ($tokenType === T_FUNCTION
1089
-                        && $this->tokens[$stackPtr]['code'] !== T_FUNCTION
1088
+                    if ( $tokenType === T_FUNCTION
1089
+                        && $this->tokens[ $stackPtr ][ 'code' ] !== T_FUNCTION
1090 1090
                     ) {
1091 1091
                         // Probably a closure, so process it manually.
1092
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1093
-                            $type = $this->tokens[$stackPtr]['type'];
1094
-                            echo str_repeat("\t", $depth);
1095
-                            echo "=> Found function before scope opener for $stackPtr:$type, processing manually".PHP_EOL;
1092
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1093
+                            $type = $this->tokens[ $stackPtr ][ 'type' ];
1094
+                            echo str_repeat( "\t", $depth );
1095
+                            echo "=> Found function before scope opener for $stackPtr:$type, processing manually" . PHP_EOL;
1096 1096
                         }
1097 1097
 
1098
-                        if (isset($this->tokens[$i]['scope_closer']) === true) {
1098
+                        if ( isset( $this->tokens[ $i ][ 'scope_closer' ] ) === true ) {
1099 1099
                             // We've already processed this closure.
1100
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1101
-                                echo str_repeat("\t", $depth);
1102
-                                echo '* already processed, skipping *'.PHP_EOL;
1100
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1101
+                                echo str_repeat( "\t", $depth );
1102
+                                echo '* already processed, skipping *' . PHP_EOL;
1103 1103
                             }
1104 1104
 
1105
-                            $i = $this->tokens[$i]['scope_closer'];
1105
+                            $i = $this->tokens[ $i ][ 'scope_closer' ];
1106 1106
                             continue;
1107 1107
                         }
1108 1108
 
1109
-                        $i = self::recurseScopeMap($i, ($depth + 1), $ignore);
1109
+                        $i = self::recurseScopeMap( $i, ( $depth + 1 ), $ignore );
1110 1110
                         continue;
1111 1111
                     }//end if
1112 1112
 
1113
-                    if ($tokenType === T_CLASS) {
1113
+                    if ( $tokenType === T_CLASS ) {
1114 1114
                         // Probably an anonymous class inside another anonymous class,
1115 1115
                         // so process it manually.
1116
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1117
-                            $type = $this->tokens[$stackPtr]['type'];
1118
-                            echo str_repeat("\t", $depth);
1119
-                            echo "=> Found class before scope opener for $stackPtr:$type, processing manually".PHP_EOL;
1116
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1117
+                            $type = $this->tokens[ $stackPtr ][ 'type' ];
1118
+                            echo str_repeat( "\t", $depth );
1119
+                            echo "=> Found class before scope opener for $stackPtr:$type, processing manually" . PHP_EOL;
1120 1120
                         }
1121 1121
 
1122
-                        if (isset($this->tokens[$i]['scope_closer']) === true) {
1122
+                        if ( isset( $this->tokens[ $i ][ 'scope_closer' ] ) === true ) {
1123 1123
                             // We've already processed this anon class.
1124
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1125
-                                echo str_repeat("\t", $depth);
1126
-                                echo '* already processed, skipping *'.PHP_EOL;
1124
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1125
+                                echo str_repeat( "\t", $depth );
1126
+                                echo '* already processed, skipping *' . PHP_EOL;
1127 1127
                             }
1128 1128
 
1129
-                            $i = $this->tokens[$i]['scope_closer'];
1129
+                            $i = $this->tokens[ $i ][ 'scope_closer' ];
1130 1130
                             continue;
1131 1131
                         }
1132 1132
 
1133
-                        $i = self::recurseScopeMap($i, ($depth + 1), $ignore);
1133
+                        $i = self::recurseScopeMap( $i, ( $depth + 1 ), $ignore );
1134 1134
                         continue;
1135 1135
                     }//end if
1136 1136
 
1137 1137
                     // Found another opening condition but still haven't
1138 1138
                     // found our opener, so we are never going to find one.
1139
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1140
-                        $type = $this->tokens[$stackPtr]['type'];
1141
-                        echo str_repeat("\t", $depth);
1139
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1140
+                        $type = $this->tokens[ $stackPtr ][ 'type' ];
1141
+                        echo str_repeat( "\t", $depth );
1142 1142
                         echo "=> Found new opening condition before scope opener for $stackPtr:$type, ";
1143 1143
                     }
1144 1144
 
1145
-                    if (($this->tokens[$stackPtr]['code'] === T_IF
1146
-                        || $this->tokens[$stackPtr]['code'] === T_ELSEIF
1147
-                        || $this->tokens[$stackPtr]['code'] === T_ELSE)
1148
-                        && ($this->tokens[$i]['code'] === T_ELSE
1149
-                        || $this->tokens[$i]['code'] === T_ELSEIF)
1145
+                    if ( ( $this->tokens[ $stackPtr ][ 'code' ] === T_IF
1146
+                        || $this->tokens[ $stackPtr ][ 'code' ] === T_ELSEIF
1147
+                        || $this->tokens[ $stackPtr ][ 'code' ] === T_ELSE )
1148
+                        && ( $this->tokens[ $i ][ 'code' ] === T_ELSE
1149
+                        || $this->tokens[ $i ][ 'code' ] === T_ELSEIF )
1150 1150
                     ) {
1151
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1152
-                            echo "continuing".PHP_EOL;
1151
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1152
+                            echo "continuing" . PHP_EOL;
1153 1153
                         }
1154 1154
 
1155
-                        return ($i - 1);
1155
+                        return ( $i - 1 );
1156 1156
                     } else {
1157
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1158
-                            echo "backtracking".PHP_EOL;
1157
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1158
+                            echo "backtracking" . PHP_EOL;
1159 1159
                         }
1160 1160
 
1161 1161
                         return $stackPtr;
1162 1162
                     }
1163 1163
                 }//end if
1164 1164
 
1165
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1166
-                    echo str_repeat("\t", $depth);
1167
-                    echo '* token is an opening condition *'.PHP_EOL;
1165
+                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1166
+                    echo str_repeat( "\t", $depth );
1167
+                    echo '* token is an opening condition *' . PHP_EOL;
1168 1168
                 }
1169 1169
 
1170
-                $isShared = ($this->scopeOpeners[$tokenType]['shared'] === true);
1170
+                $isShared = ( $this->scopeOpeners[ $tokenType ][ 'shared' ] === true );
1171 1171
 
1172
-                if (isset($this->tokens[$i]['scope_condition']) === true) {
1172
+                if ( isset( $this->tokens[ $i ][ 'scope_condition' ] ) === true ) {
1173 1173
                     // We've been here before.
1174
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1175
-                        echo str_repeat("\t", $depth);
1176
-                        echo '* already processed, skipping *'.PHP_EOL;
1174
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1175
+                        echo str_repeat( "\t", $depth );
1176
+                        echo '* already processed, skipping *' . PHP_EOL;
1177 1177
                     }
1178 1178
 
1179
-                    if ($isShared === false
1180
-                        && isset($this->tokens[$i]['scope_closer']) === true
1179
+                    if ( $isShared === false
1180
+                        && isset( $this->tokens[ $i ][ 'scope_closer' ] ) === true
1181 1181
                     ) {
1182
-                        $i = $this->tokens[$i]['scope_closer'];
1182
+                        $i = $this->tokens[ $i ][ 'scope_closer' ];
1183 1183
                     }
1184 1184
 
1185 1185
                     continue;
1186
-                } else if ($currType === $tokenType
1186
+                } else if ( $currType === $tokenType
1187 1187
                     && $isShared === false
1188 1188
                     && $opener === null
1189 1189
                 ) {
1190 1190
                     // We haven't yet found our opener, but we have found another
1191 1191
                     // scope opener which is the same type as us, and we don't
1192 1192
                     // share openers, so we will never find one.
1193
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1194
-                        echo str_repeat("\t", $depth);
1195
-                        echo '* it was another token\'s opener, bailing *'.PHP_EOL;
1193
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1194
+                        echo str_repeat( "\t", $depth );
1195
+                        echo '* it was another token\'s opener, bailing *' . PHP_EOL;
1196 1196
                     }
1197 1197
 
1198 1198
                     return $stackPtr;
1199 1199
                 } else {
1200
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1201
-                        echo str_repeat("\t", $depth);
1202
-                        echo '* searching for opener *'.PHP_EOL;
1200
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1201
+                        echo str_repeat( "\t", $depth );
1202
+                        echo '* searching for opener *' . PHP_EOL;
1203 1203
                     }
1204 1204
 
1205
-                    if (isset($this->scopeOpeners[$tokenType]['end'][T_CLOSE_CURLY_BRACKET]) === true) {
1205
+                    if ( isset( $this->scopeOpeners[ $tokenType ][ 'end' ][ T_CLOSE_CURLY_BRACKET ] ) === true ) {
1206 1206
                         $oldIgnore = $ignore;
1207 1207
                         $ignore    = 0;
1208 1208
                     }
1209 1209
 
1210 1210
                     // PHP has a max nesting level for functions. Stop before we hit that limit
1211 1211
                     // because too many loops means we've run into trouble anyway.
1212
-                    if ($depth > 50) {
1213
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1214
-                            echo str_repeat("\t", $depth);
1215
-                            echo '* reached maximum nesting level; aborting *'.PHP_EOL;
1212
+                    if ( $depth > 50 ) {
1213
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1214
+                            echo str_repeat( "\t", $depth );
1215
+                            echo '* reached maximum nesting level; aborting *' . PHP_EOL;
1216 1216
                         }
1217 1217
 
1218
-                        throw new RuntimeException('Maximum nesting level reached; file could not be processed');
1218
+                        throw new RuntimeException( 'Maximum nesting level reached; file could not be processed' );
1219 1219
                     }
1220 1220
 
1221 1221
                     $oldDepth = $depth;
1222
-                    if ($isShared === true
1223
-                        && isset($this->scopeOpeners[$tokenType]['with'][$currType]) === true
1222
+                    if ( $isShared === true
1223
+                        && isset( $this->scopeOpeners[ $tokenType ][ 'with' ][ $currType ] ) === true
1224 1224
                     ) {
1225 1225
                         // Don't allow the depth to increment because this is
1226 1226
                         // possibly not a true nesting if we are sharing our closer.
@@ -1229,35 +1229,35 @@  discard block
 block discarded – undo
1229 1229
                         $depth--;
1230 1230
                     }
1231 1231
 
1232
-                    $i     = self::recurseScopeMap($i, ($depth + 1), $ignore);
1232
+                    $i     = self::recurseScopeMap( $i, ( $depth + 1 ), $ignore );
1233 1233
                     $depth = $oldDepth;
1234 1234
 
1235
-                    if (isset($this->scopeOpeners[$tokenType]['end'][T_CLOSE_CURLY_BRACKET]) === true) {
1235
+                    if ( isset( $this->scopeOpeners[ $tokenType ][ 'end' ][ T_CLOSE_CURLY_BRACKET ] ) === true ) {
1236 1236
                         $ignore = $oldIgnore;
1237 1237
                     }
1238 1238
                 }//end if
1239 1239
             }//end if
1240 1240
 
1241
-            if (isset($this->scopeOpeners[$currType]['start'][$tokenType]) === true
1241
+            if ( isset( $this->scopeOpeners[ $currType ][ 'start' ][ $tokenType ] ) === true
1242 1242
                 && $opener === null
1243 1243
             ) {
1244
-                if ($tokenType === T_OPEN_CURLY_BRACKET) {
1245
-                    if (isset($this->tokens[$stackPtr]['parenthesis_closer']) === true
1246
-                        && $i < $this->tokens[$stackPtr]['parenthesis_closer']
1244
+                if ( $tokenType === T_OPEN_CURLY_BRACKET ) {
1245
+                    if ( isset( $this->tokens[ $stackPtr ][ 'parenthesis_closer' ] ) === true
1246
+                        && $i < $this->tokens[ $stackPtr ][ 'parenthesis_closer' ]
1247 1247
                     ) {
1248 1248
                         // We found a curly brace inside the condition of the
1249 1249
                         // current scope opener, so it must be a string offset.
1250
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1251
-                            echo str_repeat("\t", $depth);
1252
-                            echo '* ignoring curly brace inside condition *'.PHP_EOL;
1250
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1251
+                            echo str_repeat( "\t", $depth );
1252
+                            echo '* ignoring curly brace inside condition *' . PHP_EOL;
1253 1253
                         }
1254 1254
 
1255 1255
                         $ignore++;
1256 1256
                     } else {
1257 1257
                         // Make sure this is actually an opener and not a
1258 1258
                         // string offset (e.g., $var{0}).
1259
-                        for ($x = ($i - 1); $x > 0; $x--) {
1260
-                            if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === true) {
1259
+                        for ( $x = ( $i - 1 ); $x > 0; $x-- ) {
1260
+                            if ( isset( Util\Tokens::$emptyTokens[ $this->tokens[ $x ][ 'code' ] ] ) === true ) {
1261 1261
                                 continue;
1262 1262
                             } else {
1263 1263
                                 // If the first non-whitespace/comment token looks like this
@@ -1272,10 +1272,10 @@  discard block
 block discarded – undo
1272 1272
                                     T_OPEN_PARENTHESIS => true,
1273 1273
                                 ];
1274 1274
 
1275
-                                if (isset($disallowed[$this->tokens[$x]['code']]) === true) {
1276
-                                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1277
-                                        echo str_repeat("\t", $depth);
1278
-                                        echo '* ignoring curly brace *'.PHP_EOL;
1275
+                                if ( isset( $disallowed[ $this->tokens[ $x ][ 'code' ] ] ) === true ) {
1276
+                                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1277
+                                        echo str_repeat( "\t", $depth );
1278
+                                        echo '* ignoring curly brace *' . PHP_EOL;
1279 1279
                                     }
1280 1280
 
1281 1281
                                     $ignore++;
@@ -1287,87 +1287,87 @@  discard block
 block discarded – undo
1287 1287
                     }//end if
1288 1288
                 }//end if
1289 1289
 
1290
-                if ($ignore === 0 || $tokenType !== T_OPEN_CURLY_BRACKET) {
1290
+                if ( $ignore === 0 || $tokenType !== T_OPEN_CURLY_BRACKET ) {
1291 1291
                     // We found the opening scope token for $currType.
1292
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1293
-                        $type = $this->tokens[$stackPtr]['type'];
1294
-                        echo str_repeat("\t", $depth);
1295
-                        echo "=> Found scope opener for $stackPtr:$type".PHP_EOL;
1292
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1293
+                        $type = $this->tokens[ $stackPtr ][ 'type' ];
1294
+                        echo str_repeat( "\t", $depth );
1295
+                        echo "=> Found scope opener for $stackPtr:$type" . PHP_EOL;
1296 1296
                     }
1297 1297
 
1298 1298
                     $opener = $i;
1299 1299
                 }
1300
-            } else if ($tokenType === T_OPEN_PARENTHESIS) {
1301
-                if (isset($this->tokens[$i]['parenthesis_owner']) === true) {
1302
-                    $owner = $this->tokens[$i]['parenthesis_owner'];
1303
-                    if (isset(Util\Tokens::$scopeOpeners[$this->tokens[$owner]['code']]) === true
1304
-                        && isset($this->tokens[$i]['parenthesis_closer']) === true
1300
+            } else if ( $tokenType === T_OPEN_PARENTHESIS ) {
1301
+                if ( isset( $this->tokens[ $i ][ 'parenthesis_owner' ] ) === true ) {
1302
+                    $owner = $this->tokens[ $i ][ 'parenthesis_owner' ];
1303
+                    if ( isset( Util\Tokens::$scopeOpeners[ $this->tokens[ $owner ][ 'code' ] ] ) === true
1304
+                        && isset( $this->tokens[ $i ][ 'parenthesis_closer' ] ) === true
1305 1305
                     ) {
1306 1306
                         // If we get into here, then we opened a parenthesis for
1307 1307
                         // a scope (eg. an if or else if) so we need to update the
1308 1308
                         // start of the line so that when we check to see
1309 1309
                         // if the closing parenthesis is more than 3 lines away from
1310 1310
                         // the statement, we check from the closing parenthesis.
1311
-                        $startLine = $this->tokens[$this->tokens[$i]['parenthesis_closer']]['line'];
1311
+                        $startLine = $this->tokens[ $this->tokens[ $i ][ 'parenthesis_closer' ] ][ 'line' ];
1312 1312
                     }
1313 1313
                 }
1314
-            } else if ($tokenType === T_OPEN_CURLY_BRACKET && $opener !== null) {
1314
+            } else if ( $tokenType === T_OPEN_CURLY_BRACKET && $opener !== null ) {
1315 1315
                 // We opened something that we don't have a scope opener for.
1316 1316
                 // Examples of this are curly brackets for string offsets etc.
1317 1317
                 // We want to ignore this so that we don't have an invalid scope
1318 1318
                 // map.
1319
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1320
-                    echo str_repeat("\t", $depth);
1321
-                    echo '* ignoring curly brace *'.PHP_EOL;
1319
+                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1320
+                    echo str_repeat( "\t", $depth );
1321
+                    echo '* ignoring curly brace *' . PHP_EOL;
1322 1322
                 }
1323 1323
 
1324 1324
                 $ignore++;
1325
-            } else if ($tokenType === T_CLOSE_CURLY_BRACKET && $ignore > 0) {
1325
+            } else if ( $tokenType === T_CLOSE_CURLY_BRACKET && $ignore > 0 ) {
1326 1326
                 // We found the end token for the opener we were ignoring.
1327
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1328
-                    echo str_repeat("\t", $depth);
1329
-                    echo '* finished ignoring curly brace *'.PHP_EOL;
1327
+                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1328
+                    echo str_repeat( "\t", $depth );
1329
+                    echo '* finished ignoring curly brace *' . PHP_EOL;
1330 1330
                 }
1331 1331
 
1332 1332
                 $ignore--;
1333
-            } else if ($opener === null
1334
-                && isset($this->scopeOpeners[$currType]) === true
1333
+            } else if ( $opener === null
1334
+                && isset( $this->scopeOpeners[ $currType ] ) === true
1335 1335
             ) {
1336 1336
                 // If we still haven't found the opener after 30 lines,
1337 1337
                 // we're not going to find it, unless we know it requires
1338 1338
                 // an opener (in which case we better keep looking) or the last
1339 1339
                 // token was empty (in which case we'll just confirm there is
1340 1340
                 // more code in this file and not just a big comment).
1341
-                if ($this->tokens[$i]['line'] >= ($startLine + 30)
1342
-                    && isset(Util\Tokens::$emptyTokens[$this->tokens[($i - 1)]['code']]) === false
1341
+                if ( $this->tokens[ $i ][ 'line' ] >= ( $startLine + 30 )
1342
+                    && isset( Util\Tokens::$emptyTokens[ $this->tokens[ ( $i - 1 ) ][ 'code' ] ] ) === false
1343 1343
                 ) {
1344
-                    if ($this->scopeOpeners[$currType]['strict'] === true) {
1345
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1346
-                            $type  = $this->tokens[$stackPtr]['type'];
1347
-                            $lines = ($this->tokens[$i]['line'] - $startLine);
1348
-                            echo str_repeat("\t", $depth);
1349
-                            echo "=> Still looking for $stackPtr:$type scope opener after $lines lines".PHP_EOL;
1344
+                    if ( $this->scopeOpeners[ $currType ][ 'strict' ] === true ) {
1345
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1346
+                            $type  = $this->tokens[ $stackPtr ][ 'type' ];
1347
+                            $lines = ( $this->tokens[ $i ][ 'line' ] - $startLine );
1348
+                            echo str_repeat( "\t", $depth );
1349
+                            echo "=> Still looking for $stackPtr:$type scope opener after $lines lines" . PHP_EOL;
1350 1350
                         }
1351 1351
                     } else {
1352
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1353
-                            $type = $this->tokens[$stackPtr]['type'];
1354
-                            echo str_repeat("\t", $depth);
1355
-                            echo "=> Couldn't find scope opener for $stackPtr:$type, bailing".PHP_EOL;
1352
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1353
+                            $type = $this->tokens[ $stackPtr ][ 'type' ];
1354
+                            echo str_repeat( "\t", $depth );
1355
+                            echo "=> Couldn't find scope opener for $stackPtr:$type, bailing" . PHP_EOL;
1356 1356
                         }
1357 1357
 
1358 1358
                         return $stackPtr;
1359 1359
                     }
1360 1360
                 }
1361
-            } else if ($opener !== null
1361
+            } else if ( $opener !== null
1362 1362
                 && $tokenType !== T_BREAK
1363
-                && isset($this->endScopeTokens[$tokenType]) === true
1363
+                && isset( $this->endScopeTokens[ $tokenType ] ) === true
1364 1364
             ) {
1365
-                if (isset($this->tokens[$i]['scope_condition']) === false) {
1366
-                    if ($ignore > 0) {
1365
+                if ( isset( $this->tokens[ $i ][ 'scope_condition' ] ) === false ) {
1366
+                    if ( $ignore > 0 ) {
1367 1367
                         // We found the end token for the opener we were ignoring.
1368
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1369
-                            echo str_repeat("\t", $depth);
1370
-                            echo '* finished ignoring curly brace *'.PHP_EOL;
1368
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1369
+                            echo str_repeat( "\t", $depth );
1370
+                            echo '* finished ignoring curly brace *' . PHP_EOL;
1371 1371
                         }
1372 1372
 
1373 1373
                         $ignore--;
@@ -1376,19 +1376,19 @@  discard block
 block discarded – undo
1376 1376
                         // have a condition, so it belongs to another token and
1377 1377
                         // our token doesn't have a closer, so pretend this is
1378 1378
                         // the closer.
1379
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1380
-                            $type = $this->tokens[$stackPtr]['type'];
1381
-                            echo str_repeat("\t", $depth);
1382
-                            echo "=> Found (unexpected) scope closer for $stackPtr:$type".PHP_EOL;
1379
+                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1380
+                            $type = $this->tokens[ $stackPtr ][ 'type' ];
1381
+                            echo str_repeat( "\t", $depth );
1382
+                            echo "=> Found (unexpected) scope closer for $stackPtr:$type" . PHP_EOL;
1383 1383
                         }
1384 1384
 
1385
-                        foreach ([$stackPtr, $opener] as $token) {
1386
-                            $this->tokens[$token]['scope_condition'] = $stackPtr;
1387
-                            $this->tokens[$token]['scope_opener']    = $opener;
1388
-                            $this->tokens[$token]['scope_closer']    = $i;
1385
+                        foreach ( [ $stackPtr, $opener ] as $token ) {
1386
+                            $this->tokens[ $token ][ 'scope_condition' ] = $stackPtr;
1387
+                            $this->tokens[ $token ][ 'scope_opener' ]    = $opener;
1388
+                            $this->tokens[ $token ][ 'scope_closer' ]    = $i;
1389 1389
                         }
1390 1390
 
1391
-                        return ($i - 1);
1391
+                        return ( $i - 1 );
1392 1392
                     }//end if
1393 1393
                 }//end if
1394 1394
             }//end if
@@ -1411,233 +1411,233 @@  discard block
 block discarded – undo
1411 1411
      */
1412 1412
     private function createLevelMap()
1413 1413
     {
1414
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1415
-            echo "\t*** START LEVEL MAP ***".PHP_EOL;
1414
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1415
+            echo "\t*** START LEVEL MAP ***" . PHP_EOL;
1416 1416
         }
1417 1417
 
1418
-        $this->numTokens = count($this->tokens);
1418
+        $this->numTokens = count( $this->tokens );
1419 1419
         $level           = 0;
1420
-        $conditions      = [];
1420
+        $conditions      = [ ];
1421 1421
         $lastOpener      = null;
1422
-        $openers         = [];
1422
+        $openers         = [ ];
1423 1423
 
1424
-        for ($i = 0; $i < $this->numTokens; $i++) {
1425
-            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1426
-                $type = $this->tokens[$i]['type'];
1427
-                $line = $this->tokens[$i]['line'];
1428
-                $len  = $this->tokens[$i]['length'];
1429
-                $col  = $this->tokens[$i]['column'];
1424
+        for ( $i = 0; $i < $this->numTokens; $i++ ) {
1425
+            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1426
+                $type = $this->tokens[ $i ][ 'type' ];
1427
+                $line = $this->tokens[ $i ][ 'line' ];
1428
+                $len  = $this->tokens[ $i ][ 'length' ];
1429
+                $col  = $this->tokens[ $i ][ 'column' ];
1430 1430
 
1431
-                $content = Util\Common::prepareForOutput($this->tokens[$i]['content']);
1431
+                $content = Util\Common::prepareForOutput( $this->tokens[ $i ][ 'content' ] );
1432 1432
 
1433
-                echo str_repeat("\t", ($level + 1));
1433
+                echo str_repeat( "\t", ( $level + 1 ) );
1434 1434
                 echo "Process token $i on line $line [col:$col;len:$len;lvl:$level;";
1435
-                if (empty($conditions) !== true) {
1435
+                if ( empty( $conditions ) !== true ) {
1436 1436
                     $condString = 'conds;';
1437
-                    foreach ($conditions as $condition) {
1438
-                        $condString .= Util\Tokens::tokenName($condition).',';
1437
+                    foreach ( $conditions as $condition ) {
1438
+                        $condString .= Util\Tokens::tokenName( $condition ) . ',';
1439 1439
                     }
1440 1440
 
1441
-                    echo rtrim($condString, ',').';';
1441
+                    echo rtrim( $condString, ',' ) . ';';
1442 1442
                 }
1443 1443
 
1444
-                echo "]: $type => $content".PHP_EOL;
1444
+                echo "]: $type => $content" . PHP_EOL;
1445 1445
             }//end if
1446 1446
 
1447
-            $this->tokens[$i]['level']      = $level;
1448
-            $this->tokens[$i]['conditions'] = $conditions;
1447
+            $this->tokens[ $i ][ 'level' ]      = $level;
1448
+            $this->tokens[ $i ][ 'conditions' ] = $conditions;
1449 1449
 
1450
-            if (isset($this->tokens[$i]['scope_condition']) === true) {
1450
+            if ( isset( $this->tokens[ $i ][ 'scope_condition' ] ) === true ) {
1451 1451
                 // Check to see if this token opened the scope.
1452
-                if ($this->tokens[$i]['scope_opener'] === $i) {
1453
-                    $stackPtr = $this->tokens[$i]['scope_condition'];
1454
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1455
-                        $type = $this->tokens[$stackPtr]['type'];
1456
-                        echo str_repeat("\t", ($level + 1));
1457
-                        echo "=> Found scope opener for $stackPtr:$type".PHP_EOL;
1452
+                if ( $this->tokens[ $i ][ 'scope_opener' ] === $i ) {
1453
+                    $stackPtr = $this->tokens[ $i ][ 'scope_condition' ];
1454
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1455
+                        $type = $this->tokens[ $stackPtr ][ 'type' ];
1456
+                        echo str_repeat( "\t", ( $level + 1 ) );
1457
+                        echo "=> Found scope opener for $stackPtr:$type" . PHP_EOL;
1458 1458
                     }
1459 1459
 
1460
-                    $stackPtr = $this->tokens[$i]['scope_condition'];
1460
+                    $stackPtr = $this->tokens[ $i ][ 'scope_condition' ];
1461 1461
 
1462 1462
                     // If we find a scope opener that has a shared closer,
1463 1463
                     // then we need to go back over the condition map that we
1464 1464
                     // just created and fix ourselves as we just added some
1465 1465
                     // conditions where there was none. This happens for T_CASE
1466 1466
                     // statements that are using the same break statement.
1467
-                    if ($lastOpener !== null && $this->tokens[$lastOpener]['scope_closer'] === $this->tokens[$i]['scope_closer']) {
1467
+                    if ( $lastOpener !== null && $this->tokens[ $lastOpener ][ 'scope_closer' ] === $this->tokens[ $i ][ 'scope_closer' ] ) {
1468 1468
                         // This opener shares its closer with the previous opener,
1469 1469
                         // but we still need to check if the two openers share their
1470 1470
                         // closer with each other directly (like CASE and DEFAULT)
1471 1471
                         // or if they are just sharing because one doesn't have a
1472 1472
                         // closer (like CASE with no BREAK using a SWITCHes closer).
1473
-                        $thisType = $this->tokens[$this->tokens[$i]['scope_condition']]['code'];
1474
-                        $opener   = $this->tokens[$lastOpener]['scope_condition'];
1473
+                        $thisType = $this->tokens[ $this->tokens[ $i ][ 'scope_condition' ] ][ 'code' ];
1474
+                        $opener   = $this->tokens[ $lastOpener ][ 'scope_condition' ];
1475 1475
 
1476
-                        $isShared = isset($this->scopeOpeners[$thisType]['with'][$this->tokens[$opener]['code']]);
1476
+                        $isShared = isset( $this->scopeOpeners[ $thisType ][ 'with' ][ $this->tokens[ $opener ][ 'code' ] ] );
1477 1477
 
1478
-                        reset($this->scopeOpeners[$thisType]['end']);
1479
-                        reset($this->scopeOpeners[$this->tokens[$opener]['code']]['end']);
1480
-                        $sameEnd = (current($this->scopeOpeners[$thisType]['end']) === current($this->scopeOpeners[$this->tokens[$opener]['code']]['end']));
1478
+                        reset( $this->scopeOpeners[ $thisType ][ 'end' ] );
1479
+                        reset( $this->scopeOpeners[ $this->tokens[ $opener ][ 'code' ] ][ 'end' ] );
1480
+                        $sameEnd = ( current( $this->scopeOpeners[ $thisType ][ 'end' ] ) === current( $this->scopeOpeners[ $this->tokens[ $opener ][ 'code' ] ][ 'end' ] ) );
1481 1481
 
1482
-                        if ($isShared === true && $sameEnd === true) {
1482
+                        if ( $isShared === true && $sameEnd === true ) {
1483 1483
                             $badToken = $opener;
1484
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1485
-                                $type = $this->tokens[$badToken]['type'];
1486
-                                echo str_repeat("\t", ($level + 1));
1487
-                                echo "* shared closer, cleaning up $badToken:$type *".PHP_EOL;
1484
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1485
+                                $type = $this->tokens[ $badToken ][ 'type' ];
1486
+                                echo str_repeat( "\t", ( $level + 1 ) );
1487
+                                echo "* shared closer, cleaning up $badToken:$type *" . PHP_EOL;
1488 1488
                             }
1489 1489
 
1490
-                            for ($x = $this->tokens[$i]['scope_condition']; $x <= $i; $x++) {
1491
-                                $oldConditions = $this->tokens[$x]['conditions'];
1492
-                                $oldLevel      = $this->tokens[$x]['level'];
1493
-                                $this->tokens[$x]['level']--;
1494
-                                unset($this->tokens[$x]['conditions'][$badToken]);
1495
-                                if (PHP_CODESNIFFER_VERBOSITY > 1) {
1496
-                                    $type     = $this->tokens[$x]['type'];
1490
+                            for ( $x = $this->tokens[ $i ][ 'scope_condition' ]; $x <= $i; $x++ ) {
1491
+                                $oldConditions = $this->tokens[ $x ][ 'conditions' ];
1492
+                                $oldLevel      = $this->tokens[ $x ][ 'level' ];
1493
+                                $this->tokens[ $x ][ 'level' ]--;
1494
+                                unset( $this->tokens[ $x ][ 'conditions' ][ $badToken ] );
1495
+                                if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1496
+                                    $type     = $this->tokens[ $x ][ 'type' ];
1497 1497
                                     $oldConds = '';
1498
-                                    foreach ($oldConditions as $condition) {
1499
-                                        $oldConds .= Util\Tokens::tokenName($condition).',';
1498
+                                    foreach ( $oldConditions as $condition ) {
1499
+                                        $oldConds .= Util\Tokens::tokenName( $condition ) . ',';
1500 1500
                                     }
1501 1501
 
1502
-                                    $oldConds = rtrim($oldConds, ',');
1502
+                                    $oldConds = rtrim( $oldConds, ',' );
1503 1503
 
1504 1504
                                     $newConds = '';
1505
-                                    foreach ($this->tokens[$x]['conditions'] as $condition) {
1506
-                                        $newConds .= Util\Tokens::tokenName($condition).',';
1505
+                                    foreach ( $this->tokens[ $x ][ 'conditions' ] as $condition ) {
1506
+                                        $newConds .= Util\Tokens::tokenName( $condition ) . ',';
1507 1507
                                     }
1508 1508
 
1509
-                                    $newConds = rtrim($newConds, ',');
1509
+                                    $newConds = rtrim( $newConds, ',' );
1510 1510
 
1511
-                                    $newLevel = $this->tokens[$x]['level'];
1512
-                                    echo str_repeat("\t", ($level + 1));
1513
-                                    echo "* cleaned $x:$type *".PHP_EOL;
1514
-                                    echo str_repeat("\t", ($level + 2));
1515
-                                    echo "=> level changed from $oldLevel to $newLevel".PHP_EOL;
1516
-                                    echo str_repeat("\t", ($level + 2));
1517
-                                    echo "=> conditions changed from $oldConds to $newConds".PHP_EOL;
1511
+                                    $newLevel = $this->tokens[ $x ][ 'level' ];
1512
+                                    echo str_repeat( "\t", ( $level + 1 ) );
1513
+                                    echo "* cleaned $x:$type *" . PHP_EOL;
1514
+                                    echo str_repeat( "\t", ( $level + 2 ) );
1515
+                                    echo "=> level changed from $oldLevel to $newLevel" . PHP_EOL;
1516
+                                    echo str_repeat( "\t", ( $level + 2 ) );
1517
+                                    echo "=> conditions changed from $oldConds to $newConds" . PHP_EOL;
1518 1518
                                 }//end if
1519 1519
                             }//end for
1520 1520
 
1521
-                            unset($conditions[$badToken]);
1522
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1523
-                                $type = $this->tokens[$badToken]['type'];
1524
-                                echo str_repeat("\t", ($level + 1));
1525
-                                echo "* token $badToken:$type removed from conditions array *".PHP_EOL;
1521
+                            unset( $conditions[ $badToken ] );
1522
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1523
+                                $type = $this->tokens[ $badToken ][ 'type' ];
1524
+                                echo str_repeat( "\t", ( $level + 1 ) );
1525
+                                echo "* token $badToken:$type removed from conditions array *" . PHP_EOL;
1526 1526
                             }
1527 1527
 
1528
-                            unset($openers[$lastOpener]);
1528
+                            unset( $openers[ $lastOpener ] );
1529 1529
 
1530 1530
                             $level--;
1531
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1532
-                                echo str_repeat("\t", ($level + 2));
1533
-                                echo '* level decreased *'.PHP_EOL;
1531
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1532
+                                echo str_repeat( "\t", ( $level + 2 ) );
1533
+                                echo '* level decreased *' . PHP_EOL;
1534 1534
                             }
1535 1535
                         }//end if
1536 1536
                     }//end if
1537 1537
 
1538 1538
                     $level++;
1539
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1540
-                        echo str_repeat("\t", ($level + 1));
1541
-                        echo '* level increased *'.PHP_EOL;
1539
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1540
+                        echo str_repeat( "\t", ( $level + 1 ) );
1541
+                        echo '* level increased *' . PHP_EOL;
1542 1542
                     }
1543 1543
 
1544
-                    $conditions[$stackPtr] = $this->tokens[$stackPtr]['code'];
1545
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1546
-                        $type = $this->tokens[$stackPtr]['type'];
1547
-                        echo str_repeat("\t", ($level + 1));
1548
-                        echo "* token $stackPtr:$type added to conditions array *".PHP_EOL;
1544
+                    $conditions[ $stackPtr ] = $this->tokens[ $stackPtr ][ 'code' ];
1545
+                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1546
+                        $type = $this->tokens[ $stackPtr ][ 'type' ];
1547
+                        echo str_repeat( "\t", ( $level + 1 ) );
1548
+                        echo "* token $stackPtr:$type added to conditions array *" . PHP_EOL;
1549 1549
                     }
1550 1550
 
1551
-                    $lastOpener = $this->tokens[$i]['scope_opener'];
1552
-                    if ($lastOpener !== null) {
1553
-                        $openers[$lastOpener] = $lastOpener;
1551
+                    $lastOpener = $this->tokens[ $i ][ 'scope_opener' ];
1552
+                    if ( $lastOpener !== null ) {
1553
+                        $openers[ $lastOpener ] = $lastOpener;
1554 1554
                     }
1555
-                } else if ($lastOpener !== null && $this->tokens[$lastOpener]['scope_closer'] === $i) {
1556
-                    foreach (array_reverse($openers) as $opener) {
1557
-                        if ($this->tokens[$opener]['scope_closer'] === $i) {
1558
-                            $oldOpener = array_pop($openers);
1559
-                            if (empty($openers) === false) {
1560
-                                $lastOpener           = array_pop($openers);
1561
-                                $openers[$lastOpener] = $lastOpener;
1555
+                } else if ( $lastOpener !== null && $this->tokens[ $lastOpener ][ 'scope_closer' ] === $i ) {
1556
+                    foreach ( array_reverse( $openers ) as $opener ) {
1557
+                        if ( $this->tokens[ $opener ][ 'scope_closer' ] === $i ) {
1558
+                            $oldOpener = array_pop( $openers );
1559
+                            if ( empty( $openers ) === false ) {
1560
+                                $lastOpener           = array_pop( $openers );
1561
+                                $openers[ $lastOpener ] = $lastOpener;
1562 1562
                             } else {
1563 1563
                                 $lastOpener = null;
1564 1564
                             }
1565 1565
 
1566
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1567
-                                $type = $this->tokens[$oldOpener]['type'];
1568
-                                echo str_repeat("\t", ($level + 1));
1569
-                                echo "=> Found scope closer for $oldOpener:$type".PHP_EOL;
1566
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1567
+                                $type = $this->tokens[ $oldOpener ][ 'type' ];
1568
+                                echo str_repeat( "\t", ( $level + 1 ) );
1569
+                                echo "=> Found scope closer for $oldOpener:$type" . PHP_EOL;
1570 1570
                             }
1571 1571
 
1572
-                            $oldCondition = array_pop($conditions);
1573
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1574
-                                echo str_repeat("\t", ($level + 1));
1575
-                                echo '* token '.Util\Tokens::tokenName($oldCondition).' removed from conditions array *'.PHP_EOL;
1572
+                            $oldCondition = array_pop( $conditions );
1573
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1574
+                                echo str_repeat( "\t", ( $level + 1 ) );
1575
+                                echo '* token ' . Util\Tokens::tokenName( $oldCondition ) . ' removed from conditions array *' . PHP_EOL;
1576 1576
                             }
1577 1577
 
1578 1578
                             // Make sure this closer actually belongs to us.
1579 1579
                             // Either the condition also has to think this is the
1580 1580
                             // closer, or it has to allow sharing with us.
1581
-                            $condition = $this->tokens[$this->tokens[$i]['scope_condition']]['code'];
1582
-                            if ($condition !== $oldCondition) {
1583
-                                if (isset($this->scopeOpeners[$oldCondition]['with'][$condition]) === false) {
1584
-                                    $badToken = $this->tokens[$oldOpener]['scope_condition'];
1585
-
1586
-                                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
1587
-                                        $type = Util\Tokens::tokenName($oldCondition);
1588
-                                        echo str_repeat("\t", ($level + 1));
1589
-                                        echo "* scope closer was bad, cleaning up $badToken:$type *".PHP_EOL;
1581
+                            $condition = $this->tokens[ $this->tokens[ $i ][ 'scope_condition' ] ][ 'code' ];
1582
+                            if ( $condition !== $oldCondition ) {
1583
+                                if ( isset( $this->scopeOpeners[ $oldCondition ][ 'with' ][ $condition ] ) === false ) {
1584
+                                    $badToken = $this->tokens[ $oldOpener ][ 'scope_condition' ];
1585
+
1586
+                                    if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1587
+                                        $type = Util\Tokens::tokenName( $oldCondition );
1588
+                                        echo str_repeat( "\t", ( $level + 1 ) );
1589
+                                        echo "* scope closer was bad, cleaning up $badToken:$type *" . PHP_EOL;
1590 1590
                                     }
1591 1591
 
1592
-                                    for ($x = ($oldOpener + 1); $x <= $i; $x++) {
1593
-                                        $oldConditions = $this->tokens[$x]['conditions'];
1594
-                                        $oldLevel      = $this->tokens[$x]['level'];
1595
-                                        $this->tokens[$x]['level']--;
1596
-                                        unset($this->tokens[$x]['conditions'][$badToken]);
1597
-                                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1598
-                                            $type     = $this->tokens[$x]['type'];
1592
+                                    for ( $x = ( $oldOpener + 1 ); $x <= $i; $x++ ) {
1593
+                                        $oldConditions = $this->tokens[ $x ][ 'conditions' ];
1594
+                                        $oldLevel      = $this->tokens[ $x ][ 'level' ];
1595
+                                        $this->tokens[ $x ][ 'level' ]--;
1596
+                                        unset( $this->tokens[ $x ][ 'conditions' ][ $badToken ] );
1597
+                                        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1598
+                                            $type     = $this->tokens[ $x ][ 'type' ];
1599 1599
                                             $oldConds = '';
1600
-                                            foreach ($oldConditions as $condition) {
1601
-                                                $oldConds .= Util\Tokens::tokenName($condition).',';
1600
+                                            foreach ( $oldConditions as $condition ) {
1601
+                                                $oldConds .= Util\Tokens::tokenName( $condition ) . ',';
1602 1602
                                             }
1603 1603
 
1604
-                                            $oldConds = rtrim($oldConds, ',');
1604
+                                            $oldConds = rtrim( $oldConds, ',' );
1605 1605
 
1606 1606
                                             $newConds = '';
1607
-                                            foreach ($this->tokens[$x]['conditions'] as $condition) {
1608
-                                                $newConds .= Util\Tokens::tokenName($condition).',';
1607
+                                            foreach ( $this->tokens[ $x ][ 'conditions' ] as $condition ) {
1608
+                                                $newConds .= Util\Tokens::tokenName( $condition ) . ',';
1609 1609
                                             }
1610 1610
 
1611
-                                            $newConds = rtrim($newConds, ',');
1611
+                                            $newConds = rtrim( $newConds, ',' );
1612 1612
 
1613
-                                            $newLevel = $this->tokens[$x]['level'];
1614
-                                            echo str_repeat("\t", ($level + 1));
1615
-                                            echo "* cleaned $x:$type *".PHP_EOL;
1616
-                                            echo str_repeat("\t", ($level + 2));
1617
-                                            echo "=> level changed from $oldLevel to $newLevel".PHP_EOL;
1618
-                                            echo str_repeat("\t", ($level + 2));
1619
-                                            echo "=> conditions changed from $oldConds to $newConds".PHP_EOL;
1613
+                                            $newLevel = $this->tokens[ $x ][ 'level' ];
1614
+                                            echo str_repeat( "\t", ( $level + 1 ) );
1615
+                                            echo "* cleaned $x:$type *" . PHP_EOL;
1616
+                                            echo str_repeat( "\t", ( $level + 2 ) );
1617
+                                            echo "=> level changed from $oldLevel to $newLevel" . PHP_EOL;
1618
+                                            echo str_repeat( "\t", ( $level + 2 ) );
1619
+                                            echo "=> conditions changed from $oldConds to $newConds" . PHP_EOL;
1620 1620
                                         }//end if
1621 1621
                                     }//end for
1622 1622
                                 }//end if
1623 1623
                             }//end if
1624 1624
 
1625 1625
                             $level--;
1626
-                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
1627
-                                echo str_repeat("\t", ($level + 2));
1628
-                                echo '* level decreased *'.PHP_EOL;
1626
+                            if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1627
+                                echo str_repeat( "\t", ( $level + 2 ) );
1628
+                                echo '* level decreased *' . PHP_EOL;
1629 1629
                             }
1630 1630
 
1631
-                            $this->tokens[$i]['level']      = $level;
1632
-                            $this->tokens[$i]['conditions'] = $conditions;
1631
+                            $this->tokens[ $i ][ 'level' ]      = $level;
1632
+                            $this->tokens[ $i ][ 'conditions' ] = $conditions;
1633 1633
                         }//end if
1634 1634
                     }//end foreach
1635 1635
                 }//end if
1636 1636
             }//end if
1637 1637
         }//end for
1638 1638
 
1639
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
1640
-            echo "\t*** END LEVEL MAP ***".PHP_EOL;
1639
+        if ( PHP_CODESNIFFER_VERBOSITY > 1 ) {
1640
+            echo "\t*** END LEVEL MAP ***" . PHP_EOL;
1641 1641
         }
1642 1642
 
1643 1643
     }//end createLevelMap()
Please login to merge, or discard this patch.