@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | namespace PHP_CodeSniffer; |
18 | 18 | |
19 | 19 | if (class_exists('PHP_CodeSniffer\Autoload', false) === false) { |
20 | - class Autoload |
|
21 | - { |
|
20 | + class Autoload { |
|
22 | 21 | |
23 | 22 | /** |
24 | 23 | * The composer autoloader. |
@@ -61,8 +60,7 @@ discard block |
||
61 | 60 | * |
62 | 61 | * @return bool |
63 | 62 | */ |
64 | - public static function load($class) |
|
65 | - { |
|
63 | + public static function load($class) { |
|
66 | 64 | // Include the composer autoloader if there is one, but re-register it |
67 | 65 | // so this autoloader runs before the composer one as we need to include |
68 | 66 | // all files so we can figure out what the class/interface/trait name is. |
@@ -147,8 +145,7 @@ discard block |
||
147 | 145 | * |
148 | 146 | * @return string The fully qualified name of the class in the loaded file. |
149 | 147 | */ |
150 | - public static function loadFile($path) |
|
151 | - { |
|
148 | + public static function loadFile($path) { |
|
152 | 149 | if (strpos(__DIR__, 'phar://') !== 0) { |
153 | 150 | $path = realpath($path); |
154 | 151 | if ($path === false) { |
@@ -210,8 +207,7 @@ discard block |
||
210 | 207 | * |
211 | 208 | * @return void |
212 | 209 | */ |
213 | - public static function addSearchPath($path, $nsPrefix='') |
|
214 | - { |
|
210 | + public static function addSearchPath($path, $nsPrefix='') { |
|
215 | 211 | self::$searchPaths[$path] = rtrim(trim((string) $nsPrefix), '\\'); |
216 | 212 | |
217 | 213 | }//end addSearchPath() |
@@ -222,8 +218,7 @@ discard block |
||
222 | 218 | * |
223 | 219 | * @return array |
224 | 220 | */ |
225 | - public static function getSearchPaths() |
|
226 | - { |
|
221 | + public static function getSearchPaths() { |
|
227 | 222 | return self::$searchPaths; |
228 | 223 | |
229 | 224 | }//end getSearchPaths() |
@@ -237,8 +232,7 @@ discard block |
||
237 | 232 | * @throws \Exception If the file path has not been loaded. |
238 | 233 | * @return string |
239 | 234 | */ |
240 | - public static function getLoadedClassName($path) |
|
241 | - { |
|
235 | + public static function getLoadedClassName($path) { |
|
242 | 236 | if (isset(self::$loadedClasses[$path]) === false) { |
243 | 237 | throw new \Exception("Cannot get class name for $path; file has not been included"); |
244 | 238 | } |
@@ -256,8 +250,7 @@ discard block |
||
256 | 250 | * @throws \Exception If the class name has not been loaded |
257 | 251 | * @return string |
258 | 252 | */ |
259 | - public static function getLoadedFileName($class) |
|
260 | - { |
|
253 | + public static function getLoadedFileName($class) { |
|
261 | 254 | if (isset(self::$loadedFiles[$class]) === false) { |
262 | 255 | throw new \Exception("Cannot get file name for $class; class has not been included"); |
263 | 256 | } |
@@ -272,8 +265,7 @@ discard block |
||
272 | 265 | * |
273 | 266 | * @return array<string, string> |
274 | 267 | */ |
275 | - public static function getLoadedClasses() |
|
276 | - { |
|
268 | + public static function getLoadedClasses() { |
|
277 | 269 | return self::$loadedClasses; |
278 | 270 | |
279 | 271 | }//end getLoadedClasses() |
@@ -284,8 +276,7 @@ discard block |
||
284 | 276 | * |
285 | 277 | * @return array<string, string> |
286 | 278 | */ |
287 | - public static function getLoadedFiles() |
|
288 | - { |
|
279 | + public static function getLoadedFiles() { |
|
289 | 280 | return self::$loadedFiles; |
290 | 281 | |
291 | 282 | }//end getLoadedFiles() |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Validate the PHP_CodeSniffer PEAR package.xml file. |
16 | 16 | */ |
17 | -class ValidatePEARPackageXML |
|
18 | -{ |
|
17 | +class ValidatePEARPackageXML { |
|
19 | 18 | |
20 | 19 | /** |
21 | 20 | * The root directory of the project. |
@@ -67,8 +66,7 @@ discard block |
||
67 | 66 | /** |
68 | 67 | * Constructor. |
69 | 68 | */ |
70 | - public function __construct() |
|
71 | - { |
|
69 | + public function __construct() { |
|
72 | 70 | $this->projectRoot = dirname(dirname(__DIR__)).'/'; |
73 | 71 | $this->packageXML = simplexml_load_file($this->projectRoot.'package.xml'); |
74 | 72 | |
@@ -83,8 +81,7 @@ discard block |
||
83 | 81 | * |
84 | 82 | * @return void |
85 | 83 | */ |
86 | - public function validate() |
|
87 | - { |
|
84 | + public function validate() { |
|
88 | 85 | $exitCode = 0; |
89 | 86 | if ($this->checkContents() !== true) { |
90 | 87 | $exitCode = 1; |
@@ -104,8 +101,7 @@ discard block |
||
104 | 101 | * |
105 | 102 | * @return bool |
106 | 103 | */ |
107 | - protected function checkContents() |
|
108 | - { |
|
104 | + protected function checkContents() { |
|
109 | 105 | echo PHP_EOL.'Checking Contents tag'.PHP_EOL; |
110 | 106 | echo '====================='.PHP_EOL; |
111 | 107 | |
@@ -165,8 +161,7 @@ discard block |
||
165 | 161 | * |
166 | 162 | * @return bool |
167 | 163 | */ |
168 | - protected function walkDirTag($tag, $currentDirectory='') |
|
169 | - { |
|
164 | + protected function walkDirTag($tag, $currentDirectory='') { |
|
170 | 165 | $valid = true; |
171 | 166 | $name = (string) $tag['name']; |
172 | 167 | if ($name !== '/' && empty($name) === false) { |
@@ -202,8 +197,7 @@ discard block |
||
202 | 197 | * |
203 | 198 | * @return bool |
204 | 199 | */ |
205 | - protected function checkFileTag($tag, $currentDirectory='') |
|
206 | - { |
|
200 | + protected function checkFileTag($tag, $currentDirectory='') { |
|
207 | 201 | $valid = true; |
208 | 202 | $attributes = $tag->attributes(); |
209 | 203 | $baseinstalldir = (string) $attributes['baseinstalldir']; |
@@ -270,8 +264,7 @@ discard block |
||
270 | 264 | * |
271 | 265 | * @return bool True if the info in the "phprelease" tags is valid. False otherwise. |
272 | 266 | */ |
273 | - protected function checkPHPRelease() |
|
274 | - { |
|
267 | + protected function checkPHPRelease() { |
|
275 | 268 | echo PHP_EOL.'Checking PHPRelease tags'.PHP_EOL; |
276 | 269 | echo '========================'.PHP_EOL; |
277 | 270 |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Class to create a file list with filtering. |
16 | 16 | */ |
17 | -class FileList |
|
18 | -{ |
|
17 | +class FileList { |
|
19 | 18 | |
20 | 19 | /** |
21 | 20 | * The path to the project root directory. |
@@ -53,8 +52,7 @@ discard block |
||
53 | 52 | * @param string $rootPath Path to the project root. |
54 | 53 | * @param string $filter PCRE regular expression to filter the file list with. |
55 | 54 | */ |
56 | - public function __construct($directory, $rootPath='', $filter='') |
|
57 | - { |
|
55 | + public function __construct($directory, $rootPath='', $filter='') { |
|
58 | 56 | $this->rootPath = $rootPath; |
59 | 57 | |
60 | 58 | $directory = new \RecursiveDirectoryIterator( |
@@ -83,8 +81,7 @@ discard block |
||
83 | 81 | * |
84 | 82 | * @return array |
85 | 83 | */ |
86 | - public function getList() |
|
87 | - { |
|
84 | + public function getList() { |
|
88 | 85 | $fileList = []; |
89 | 86 | |
90 | 87 | foreach ($this->fileIterator as $file) { |
@@ -13,8 +13,7 @@ discard block |
||
13 | 13 | use PHP_CodeSniffer\Ruleset; |
14 | 14 | use PHP_CodeSniffer\Config; |
15 | 15 | |
16 | -class Filter extends \RecursiveFilterIterator |
|
17 | -{ |
|
16 | +class Filter extends \RecursiveFilterIterator { |
|
18 | 17 | /** |
19 | 18 | * The top-level path we are filtering. |
20 | 19 | * |
@@ -70,8 +69,7 @@ discard block |
||
70 | 69 | * |
71 | 70 | * @return void |
72 | 71 | */ |
73 | - public function __construct($iterator, $basedir, Config $config, Ruleset $ruleset) |
|
74 | - { |
|
72 | + public function __construct($iterator, $basedir, Config $config, Ruleset $ruleset) { |
|
75 | 73 | parent::__construct($iterator); |
76 | 74 | $this->basedir = $basedir; |
77 | 75 | $this->config = $config; |
@@ -88,8 +86,7 @@ discard block |
||
88 | 86 | * |
89 | 87 | * @return bool |
90 | 88 | */ |
91 | - public function accept() |
|
92 | - { |
|
89 | + public function accept() { |
|
93 | 90 | $filePath = $this->current(); |
94 | 91 | $realPath = Util\Common::realpath($filePath); |
95 | 92 | |
@@ -129,8 +126,7 @@ discard block |
||
129 | 126 | * |
130 | 127 | * @return \RecursiveIterator |
131 | 128 | */ |
132 | - public function getChildren() |
|
133 | - { |
|
129 | + public function getChildren() { |
|
134 | 130 | $children = new static( |
135 | 131 | new \RecursiveDirectoryIterator($this->current(), (\RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS)), |
136 | 132 | $this->basedir, |
@@ -156,8 +152,7 @@ discard block |
||
156 | 152 | * |
157 | 153 | * @return bool |
158 | 154 | */ |
159 | - protected function shouldProcessFile($path) |
|
160 | - { |
|
155 | + protected function shouldProcessFile($path) { |
|
161 | 156 | // Check that the file's extension is one we are checking. |
162 | 157 | // We are strict about checking the extension and we don't |
163 | 158 | // let files through with no extension or that start with a dot. |
@@ -193,8 +188,7 @@ discard block |
||
193 | 188 | * |
194 | 189 | * @return bool |
195 | 190 | */ |
196 | - protected function shouldIgnorePath($path) |
|
197 | - { |
|
191 | + protected function shouldIgnorePath($path) { |
|
198 | 192 | if ($this->ignoreFilePatterns === null) { |
199 | 193 | $this->ignoreDirPatterns = []; |
200 | 194 | $this->ignoreFilePatterns = []; |
@@ -13,8 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | use PHP_CodeSniffer\Util; |
15 | 15 | |
16 | -abstract class ExactMatch extends Filter |
|
17 | -{ |
|
16 | +abstract class ExactMatch extends Filter { |
|
18 | 17 | |
19 | 18 | /** |
20 | 19 | * A list of files to exclude. |
@@ -40,8 +39,7 @@ discard block |
||
40 | 39 | * |
41 | 40 | * @return bool |
42 | 41 | */ |
43 | - public function accept() |
|
44 | - { |
|
42 | + public function accept() { |
|
45 | 43 | if (parent::accept() === false) { |
46 | 44 | return false; |
47 | 45 | } |
@@ -79,8 +77,7 @@ discard block |
||
79 | 77 | * |
80 | 78 | * @return \RecursiveIterator |
81 | 79 | */ |
82 | - public function getChildren() |
|
83 | - { |
|
80 | + public function getChildren() { |
|
84 | 81 | $children = parent::getChildren(); |
85 | 82 | $children->blacklist = $this->blacklist; |
86 | 83 | $children->whitelist = $this->whitelist; |
@@ -11,8 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | use PHP_CodeSniffer\Util; |
13 | 13 | |
14 | -class GitModified extends ExactMatch |
|
15 | -{ |
|
14 | +class GitModified extends ExactMatch { |
|
16 | 15 | |
17 | 16 | |
18 | 17 | /** |
@@ -20,8 +19,7 @@ discard block |
||
20 | 19 | * |
21 | 20 | * @return array |
22 | 21 | */ |
23 | - protected function getBlacklist() |
|
24 | - { |
|
22 | + protected function getBlacklist() { |
|
25 | 23 | return []; |
26 | 24 | |
27 | 25 | }//end getBlacklist() |
@@ -32,8 +30,7 @@ discard block |
||
32 | 30 | * |
33 | 31 | * @return array |
34 | 32 | */ |
35 | - protected function getWhitelist() |
|
36 | - { |
|
33 | + protected function getWhitelist() { |
|
37 | 34 | $modified = []; |
38 | 35 | |
39 | 36 | $cmd = 'git ls-files -o -m --exclude-standard -- '.escapeshellarg($this->basedir); |
@@ -15,8 +15,7 @@ discard block |
||
15 | 15 | use PHP_CodeSniffer\Exceptions\DeepExitException; |
16 | 16 | use PHP_CodeSniffer\Util\Common; |
17 | 17 | |
18 | -class Reporter |
|
19 | -{ |
|
18 | +class Reporter { |
|
20 | 19 | |
21 | 20 | /** |
22 | 21 | * The config data for the run. |
@@ -94,8 +93,7 @@ discard block |
||
94 | 93 | * @return void |
95 | 94 | * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If a report is not available. |
96 | 95 | */ |
97 | - public function __construct(Config $config) |
|
98 | - { |
|
96 | + public function __construct(Config $config) { |
|
99 | 97 | $this->config = $config; |
100 | 98 | |
101 | 99 | foreach ($config->reports as $type => $output) { |
@@ -173,8 +171,7 @@ discard block |
||
173 | 171 | * |
174 | 172 | * @return bool |
175 | 173 | */ |
176 | - public function printReports() |
|
177 | - { |
|
174 | + public function printReports() { |
|
178 | 175 | $toScreen = false; |
179 | 176 | foreach ($this->reports as $type => $report) { |
180 | 177 | if ($report['output'] === null) { |
@@ -196,8 +193,7 @@ discard block |
||
196 | 193 | * |
197 | 194 | * @return void |
198 | 195 | */ |
199 | - public function printReport($report) |
|
200 | - { |
|
196 | + public function printReport($report) { |
|
201 | 197 | $reportClass = $this->reports[$report]['class']; |
202 | 198 | $reportFile = $this->reports[$report]['output']; |
203 | 199 | |
@@ -266,8 +262,7 @@ discard block |
||
266 | 262 | * |
267 | 263 | * @return void |
268 | 264 | */ |
269 | - public function cacheFileReport(File $phpcsFile) |
|
270 | - { |
|
265 | + public function cacheFileReport(File $phpcsFile) { |
|
271 | 266 | if (isset($this->config->reports) === false) { |
272 | 267 | // This happens during unit testing, or any time someone just wants |
273 | 268 | // the error data and not the printed report. |
@@ -330,8 +325,7 @@ discard block |
||
330 | 325 | * |
331 | 326 | * @return array |
332 | 327 | */ |
333 | - public function prepareFileReport(File $phpcsFile) |
|
334 | - { |
|
328 | + public function prepareFileReport(File $phpcsFile) { |
|
335 | 329 | $report = [ |
336 | 330 | 'filename' => Common::stripBasepath($phpcsFile->getFilename(), $this->config->basepath), |
337 | 331 | 'errors' => $phpcsFile->getErrorCount(), |
@@ -11,8 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | use PHP_CodeSniffer\Util; |
13 | 13 | |
14 | -class PHP extends Tokenizer |
|
15 | -{ |
|
14 | +class PHP extends Tokenizer { |
|
16 | 15 | |
17 | 16 | |
18 | 17 | /** |
@@ -453,8 +452,7 @@ discard block |
||
453 | 452 | * |
454 | 453 | * @return array |
455 | 454 | */ |
456 | - protected function tokenize($string) |
|
457 | - { |
|
455 | + protected function tokenize($string) { |
|
458 | 456 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
459 | 457 | echo "\t*** START PHP TOKENIZING ***".PHP_EOL; |
460 | 458 | $isWin = false; |
@@ -1472,8 +1470,7 @@ discard block |
||
1472 | 1470 | * |
1473 | 1471 | * @return void |
1474 | 1472 | */ |
1475 | - protected function processAdditional() |
|
1476 | - { |
|
1473 | + protected function processAdditional() { |
|
1477 | 1474 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
1478 | 1475 | echo "\t*** START ADDITIONAL PHP PROCESSING ***".PHP_EOL; |
1479 | 1476 | } |
@@ -1836,8 +1833,7 @@ discard block |
||
1836 | 1833 | * |
1837 | 1834 | * @return array The new token. |
1838 | 1835 | */ |
1839 | - public static function standardiseToken($token) |
|
1840 | - { |
|
1836 | + public static function standardiseToken($token) { |
|
1841 | 1837 | if (isset($token[1]) === false) { |
1842 | 1838 | if (isset(self::$resolveTokenCache[$token[0]]) === true) { |
1843 | 1839 | return self::$resolveTokenCache[$token[0]]; |
@@ -1917,8 +1913,7 @@ discard block |
||
1917 | 1913 | * |
1918 | 1914 | * @return array The new token in array format. |
1919 | 1915 | */ |
1920 | - public static function resolveSimpleToken($token) |
|
1921 | - { |
|
1916 | + public static function resolveSimpleToken($token) { |
|
1922 | 1917 | $newToken = []; |
1923 | 1918 | |
1924 | 1919 | switch ($token) { |
@@ -12,8 +12,7 @@ discard block |
||
12 | 12 | use PHP_CodeSniffer\Exceptions\RuntimeException; |
13 | 13 | use PHP_CodeSniffer\Util; |
14 | 14 | |
15 | -abstract class Tokenizer |
|
16 | -{ |
|
15 | +abstract class Tokenizer { |
|
17 | 16 | |
18 | 17 | /** |
19 | 18 | * The config data for the run. |
@@ -82,8 +81,7 @@ discard block |
||
82 | 81 | * @return void |
83 | 82 | * @throws \PHP_CodeSniffer\Exceptions\TokenizerException If the file appears to be minified. |
84 | 83 | */ |
85 | - public function __construct($content, $config, $eolChar='\n') |
|
86 | - { |
|
84 | + public function __construct($content, $config, $eolChar='\n') { |
|
87 | 85 | $this->eolChar = $eolChar; |
88 | 86 | |
89 | 87 | $this->config = $config; |
@@ -113,8 +111,7 @@ discard block |
||
113 | 111 | * |
114 | 112 | * @return boolean |
115 | 113 | */ |
116 | - protected function isMinifiedContent($content, $eolChar='\n') |
|
117 | - { |
|
114 | + protected function isMinifiedContent($content, $eolChar='\n') { |
|
118 | 115 | // Minified files often have a very large number of characters per line |
119 | 116 | // and cause issues when tokenizing. |
120 | 117 | $numChars = strlen($content); |
@@ -134,8 +131,7 @@ discard block |
||
134 | 131 | * |
135 | 132 | * @return array |
136 | 133 | */ |
137 | - public function getTokens() |
|
138 | - { |
|
134 | + public function getTokens() { |
|
139 | 135 | return $this->tokens; |
140 | 136 | |
141 | 137 | }//end getTokens() |
@@ -167,8 +163,7 @@ discard block |
||
167 | 163 | * |
168 | 164 | * @return void |
169 | 165 | */ |
170 | - private function createPositionMap() |
|
171 | - { |
|
166 | + private function createPositionMap() { |
|
172 | 167 | $currColumn = 1; |
173 | 168 | $lineNumber = 1; |
174 | 169 | $eolLen = strlen($this->eolChar); |
@@ -576,8 +571,7 @@ discard block |
||
576 | 571 | * |
577 | 572 | * @return void |
578 | 573 | */ |
579 | - public function replaceTabsInToken(&$token, $prefix=' ', $padding=' ', $tabWidth=null) |
|
580 | - { |
|
574 | + public function replaceTabsInToken(&$token, $prefix=' ', $padding=' ', $tabWidth=null) { |
|
581 | 575 | $checkEncoding = false; |
582 | 576 | if (function_exists('iconv_strlen') === true) { |
583 | 577 | $checkEncoding = true; |
@@ -668,8 +662,7 @@ discard block |
||
668 | 662 | * |
669 | 663 | * @return void |
670 | 664 | */ |
671 | - private function createTokenMap() |
|
672 | - { |
|
665 | + private function createTokenMap() { |
|
673 | 666 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
674 | 667 | echo "\t*** START TOKEN MAP ***".PHP_EOL; |
675 | 668 | } |
@@ -798,8 +791,7 @@ discard block |
||
798 | 791 | * |
799 | 792 | * @return void |
800 | 793 | */ |
801 | - private function createParenthesisNestingMap() |
|
802 | - { |
|
794 | + private function createParenthesisNestingMap() { |
|
803 | 795 | $map = []; |
804 | 796 | for ($i = 0; $i < $this->numTokens; $i++) { |
805 | 797 | if (isset($this->tokens[$i]['parenthesis_opener']) === true |
@@ -836,8 +828,7 @@ discard block |
||
836 | 828 | * @return void |
837 | 829 | * @see recurseScopeMap() |
838 | 830 | */ |
839 | - private function createScopeMap() |
|
840 | - { |
|
831 | + private function createScopeMap() { |
|
841 | 832 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
842 | 833 | echo "\t*** START SCOPE MAP ***".PHP_EOL; |
843 | 834 | } |
@@ -880,8 +871,7 @@ discard block |
||
880 | 871 | * |
881 | 872 | * @return int The position in the stack that closed the scope. |
882 | 873 | */ |
883 | - private function recurseScopeMap($stackPtr, $depth=1, &$ignore=0) |
|
884 | - { |
|
874 | + private function recurseScopeMap($stackPtr, $depth=1, &$ignore=0) { |
|
885 | 875 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
886 | 876 | echo str_repeat("\t", $depth); |
887 | 877 | echo "=> Begin scope map recursion at token $stackPtr with depth $depth".PHP_EOL; |
@@ -1409,8 +1399,7 @@ discard block |
||
1409 | 1399 | * |
1410 | 1400 | * @return void |
1411 | 1401 | */ |
1412 | - private function createLevelMap() |
|
1413 | - { |
|
1402 | + private function createLevelMap() { |
|
1414 | 1403 | if (PHP_CODESNIFFER_VERBOSITY > 1) { |
1415 | 1404 | echo "\t*** START LEVEL MAP ***".PHP_EOL; |
1416 | 1405 | } |