@@ -27,16 +27,14 @@ discard block |
||
27 | 27 | * @package PHPCompatibility |
28 | 28 | * @author Juliette Reinders Folmer <[email protected]> |
29 | 29 | */ |
30 | -class PHPCSHelper |
|
31 | -{ |
|
30 | +class PHPCSHelper { |
|
32 | 31 | |
33 | 32 | /** |
34 | 33 | * Get the PHPCS version number. |
35 | 34 | * |
36 | 35 | * @return string |
37 | 36 | */ |
38 | - public static function getVersion() |
|
39 | - { |
|
37 | + public static function getVersion() { |
|
40 | 38 | if (\defined('\PHP_CodeSniffer\Config::VERSION')) { |
41 | 39 | // PHPCS 3.x. |
42 | 40 | return \PHP_CodeSniffer\Config::VERSION; |
@@ -60,8 +58,7 @@ discard block |
||
60 | 58 | * |
61 | 59 | * @return void |
62 | 60 | */ |
63 | - public static function setConfigData($key, $value, $temp = false) |
|
64 | - { |
|
61 | + public static function setConfigData($key, $value, $temp = false) { |
|
65 | 62 | if (method_exists('\PHP_CodeSniffer\Config', 'setConfigData')) { |
66 | 63 | // PHPCS 3.x. |
67 | 64 | \PHP_CodeSniffer\Config::setConfigData($key, $value, $temp); |
@@ -79,8 +76,7 @@ discard block |
||
79 | 76 | * |
80 | 77 | * @return string|null |
81 | 78 | */ |
82 | - public static function getConfigData($key) |
|
83 | - { |
|
79 | + public static function getConfigData($key) { |
|
84 | 80 | if (method_exists('\PHP_CodeSniffer\Config', 'getConfigData')) { |
85 | 81 | // PHPCS 3.x. |
86 | 82 | return \PHP_CodeSniffer\Config::getConfigData($key); |
@@ -102,8 +98,7 @@ discard block |
||
102 | 98 | * |
103 | 99 | * @return string|null |
104 | 100 | */ |
105 | - public static function getCommandLineData(File $phpcsFile, $key) |
|
106 | - { |
|
101 | + public static function getCommandLineData(File $phpcsFile, $key) { |
|
107 | 102 | if (class_exists('\PHP_CodeSniffer\Config')) { |
108 | 103 | // PHPCS 3.x. |
109 | 104 | $config = $phpcsFile->config; |
@@ -140,8 +135,7 @@ discard block |
||
140 | 135 | * |
141 | 136 | * @return int |
142 | 137 | */ |
143 | - public static function findStartOfStatement(File $phpcsFile, $start, $ignore = null) |
|
144 | - { |
|
138 | + public static function findStartOfStatement(File $phpcsFile, $start, $ignore = null) { |
|
145 | 139 | if (version_compare(self::getVersion(), '2.7.1', '>=') === true) { |
146 | 140 | return $phpcsFile->findStartOfStatement($start, $ignore); |
147 | 141 | } |
@@ -219,8 +213,7 @@ discard block |
||
219 | 213 | * |
220 | 214 | * @return int |
221 | 215 | */ |
222 | - public static function findEndOfStatement(File $phpcsFile, $start, $ignore = null) |
|
223 | - { |
|
216 | + public static function findEndOfStatement(File $phpcsFile, $start, $ignore = null) { |
|
224 | 217 | if (version_compare(self::getVersion(), '3.3.0', '>=') === true) { |
225 | 218 | return $phpcsFile->findEndOfStatement($start, $ignore); |
226 | 219 | } |
@@ -317,8 +310,7 @@ discard block |
||
317 | 310 | * |
318 | 311 | * @return string|false |
319 | 312 | */ |
320 | - public static function findExtendedClassName(File $phpcsFile, $stackPtr) |
|
321 | - { |
|
313 | + public static function findExtendedClassName(File $phpcsFile, $stackPtr) { |
|
322 | 314 | if (version_compare(self::getVersion(), '3.1.0', '>=') === true) { |
323 | 315 | return $phpcsFile->findExtendedClassName($stackPtr); |
324 | 316 | } |
@@ -382,8 +374,7 @@ discard block |
||
382 | 374 | * |
383 | 375 | * @return array|false |
384 | 376 | */ |
385 | - public static function findImplementedInterfaceNames(File $phpcsFile, $stackPtr) |
|
386 | - { |
|
377 | + public static function findImplementedInterfaceNames(File $phpcsFile, $stackPtr) { |
|
387 | 378 | if (version_compare(self::getVersion(), '2.7.1', '>') === true) { |
388 | 379 | return $phpcsFile->findImplementedInterfaceNames($stackPtr); |
389 | 380 | } |
@@ -468,8 +459,7 @@ discard block |
||
468 | 459 | * @throws \PHP_CodeSniffer_Exception If the specified $stackPtr is not of |
469 | 460 | * type T_FUNCTION or T_CLOSURE. |
470 | 461 | */ |
471 | - public static function getMethodParameters(File $phpcsFile, $stackPtr) |
|
472 | - { |
|
462 | + public static function getMethodParameters(File $phpcsFile, $stackPtr) { |
|
473 | 463 | if (version_compare(self::getVersion(), '3.3.0', '>=') === true) { |
474 | 464 | return $phpcsFile->getMethodParameters($stackPtr); |
475 | 465 | } |
@@ -90,8 +90,7 @@ discard block |
||
90 | 90 | * @throws ProcessFailedException |
91 | 91 | * @throws RuntimeException |
92 | 92 | */ |
93 | - public static function run(Event $event) |
|
94 | - { |
|
93 | + public static function run(Event $event) { |
|
95 | 94 | $io = $event->getIO(); |
96 | 95 | $composer = $event->getComposer(); |
97 | 96 | |
@@ -111,8 +110,7 @@ discard block |
||
111 | 110 | * @throws ProcessFailedException |
112 | 111 | * @throws RuntimeException |
113 | 112 | */ |
114 | - public function activate(Composer $composer, IOInterface $io) |
|
115 | - { |
|
113 | + public function activate(Composer $composer, IOInterface $io) { |
|
116 | 114 | $this->composer = $composer; |
117 | 115 | $this->io = $io; |
118 | 116 | |
@@ -127,8 +125,7 @@ discard block |
||
127 | 125 | * @throws ProcessFailedException |
128 | 126 | * @throws RuntimeException |
129 | 127 | */ |
130 | - private function init() |
|
131 | - { |
|
128 | + private function init() { |
|
132 | 129 | $this->cwd = getcwd(); |
133 | 130 | $this->installedPaths = array(); |
134 | 131 | |
@@ -139,8 +136,7 @@ discard block |
||
139 | 136 | /** |
140 | 137 | * {@inheritDoc} |
141 | 138 | */ |
142 | - public static function getSubscribedEvents() |
|
143 | - { |
|
139 | + public static function getSubscribedEvents() { |
|
144 | 140 | return array( |
145 | 141 | ScriptEvents::POST_INSTALL_CMD => array( |
146 | 142 | array('onDependenciesChangedEvent', 0), |
@@ -159,8 +155,7 @@ discard block |
||
159 | 155 | * @throws ProcessFailedException |
160 | 156 | * @throws RuntimeException |
161 | 157 | */ |
162 | - public function onDependenciesChangedEvent() |
|
163 | - { |
|
158 | + public function onDependenciesChangedEvent() { |
|
164 | 159 | $io = $this->io; |
165 | 160 | $isVerbose = $io->isVerbose(); |
166 | 161 | |
@@ -190,8 +185,7 @@ discard block |
||
190 | 185 | * @throws ProcessFailedException |
191 | 186 | * @throws RuntimeException |
192 | 187 | */ |
193 | - private function loadInstalledPaths() |
|
194 | - { |
|
188 | + private function loadInstalledPaths() { |
|
195 | 189 | if ($this->isPHPCodeSnifferInstalled() === true) { |
196 | 190 | $this->processExecutor->execute( |
197 | 191 | sprintf( |
@@ -218,8 +212,7 @@ discard block |
||
218 | 212 | * @throws ProcessFailedException |
219 | 213 | * @throws RuntimeException |
220 | 214 | */ |
221 | - private function saveInstalledPaths() |
|
222 | - { |
|
215 | + private function saveInstalledPaths() { |
|
223 | 216 | // Check if we found installed paths to set. |
224 | 217 | if (count($this->installedPaths) !== 0) { |
225 | 218 | $paths = implode(',', $this->installedPaths); |
@@ -262,8 +255,7 @@ discard block |
||
262 | 255 | * |
263 | 256 | * @return bool True if changes where made, false otherwise |
264 | 257 | */ |
265 | - private function cleanInstalledPaths() |
|
266 | - { |
|
258 | + private function cleanInstalledPaths() { |
|
267 | 259 | $changes = false; |
268 | 260 | foreach ($this->installedPaths as $key => $path) { |
269 | 261 | // This might be a relative path as well |
@@ -288,8 +280,7 @@ discard block |
||
288 | 280 | * @throws \InvalidArgumentException |
289 | 281 | * @throws \RuntimeException |
290 | 282 | */ |
291 | - private function updateInstalledPaths() |
|
292 | - { |
|
283 | + private function updateInstalledPaths() { |
|
293 | 284 | $changes = false; |
294 | 285 | |
295 | 286 | $searchPaths = array($this->cwd); |
@@ -350,8 +341,7 @@ discard block |
||
350 | 341 | * |
351 | 342 | * @return array Composer packages containing coding standard(s) |
352 | 343 | */ |
353 | - private function getPHPCodingStandardPackages() |
|
354 | - { |
|
344 | + private function getPHPCodingStandardPackages() { |
|
355 | 345 | $codingStandardPackages = array_filter( |
356 | 346 | $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(), |
357 | 347 | function (PackageInterface $package) { |
@@ -378,8 +368,7 @@ discard block |
||
378 | 368 | * |
379 | 369 | * @return PackageInterface|null |
380 | 370 | */ |
381 | - private function getPHPCodeSnifferPackage($versionConstraint = null) |
|
382 | - { |
|
371 | + private function getPHPCodeSnifferPackage($versionConstraint = null) { |
|
383 | 372 | $packages = $this |
384 | 373 | ->composer |
385 | 374 | ->getRepositoryManager() |
@@ -394,8 +383,7 @@ discard block |
||
394 | 383 | * |
395 | 384 | * @return string |
396 | 385 | */ |
397 | - private function getPHPCodeSnifferInstallPath() |
|
398 | - { |
|
386 | + private function getPHPCodeSnifferInstallPath() { |
|
399 | 387 | return $this->composer->getInstallationManager()->getInstallPath($this->getPHPCodeSnifferPackage()); |
400 | 388 | } |
401 | 389 | |
@@ -406,8 +394,7 @@ discard block |
||
406 | 394 | * |
407 | 395 | * @return bool Whether PHP_CodeSniffer is installed |
408 | 396 | */ |
409 | - private function isPHPCodeSnifferInstalled($versionConstraint = null) |
|
410 | - { |
|
397 | + private function isPHPCodeSnifferInstalled($versionConstraint = null) { |
|
411 | 398 | return ($this->getPHPCodeSnifferPackage($versionConstraint) !== null); |
412 | 399 | } |
413 | 400 | |
@@ -419,8 +406,7 @@ discard block |
||
419 | 406 | * |
420 | 407 | * @throws \RuntimeException |
421 | 408 | */ |
422 | - private function isRunningGlobally() |
|
423 | - { |
|
409 | + private function isRunningGlobally() { |
|
424 | 410 | return ($this->composer->getConfig()->get('home') === $this->cwd); |
425 | 411 | } |
426 | 412 | |
@@ -431,8 +417,7 @@ discard block |
||
431 | 417 | * |
432 | 418 | * @throws \InvalidArgumentException |
433 | 419 | */ |
434 | - private function getMaxDepth() |
|
435 | - { |
|
420 | + private function getMaxDepth() { |
|
436 | 421 | $maxDepth = 3; |
437 | 422 | |
438 | 423 | $extra = $this->composer->getPackage()->getExtra(); |
@@ -468,8 +453,7 @@ discard block |
||
468 | 453 | * |
469 | 454 | * @return int |
470 | 455 | */ |
471 | - private function getMinDepth() |
|
472 | - { |
|
456 | + private function getMinDepth() { |
|
473 | 457 | if ($this->isPHPCodeSnifferInstalled('>= 3.0.0') !== true) { |
474 | 458 | return 1; |
475 | 459 | } |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * |
51 | 51 | * @return void |
52 | 52 | */ |
53 | -function printPHPCodeSnifferTestOutput() |
|
54 | -{ |
|
53 | +function printPHPCodeSnifferTestOutput() { |
|
55 | 54 | echo PHP_EOL.PHP_EOL; |
56 | 55 | |
57 | 56 | $output = 'The test files'; |
@@ -12,8 +12,7 @@ |
||
12 | 12 | use PHPUnit\Framework\TestSuite as PHPUnit_TestSuite; |
13 | 13 | use PHPUnit\Framework\TestResult; |
14 | 14 | |
15 | -class TestSuite extends PHPUnit_TestSuite |
|
16 | -{ |
|
15 | +class TestSuite extends PHPUnit_TestSuite { |
|
17 | 16 | |
18 | 17 | |
19 | 18 | /** |
@@ -12,8 +12,7 @@ discard block |
||
12 | 12 | use PHPUnit\Framework\TestSuite as PHPUnit_TestSuite; |
13 | 13 | use PHPUnit\Framework\TestResult; |
14 | 14 | |
15 | -class TestSuite extends PHPUnit_TestSuite |
|
16 | -{ |
|
15 | +class TestSuite extends PHPUnit_TestSuite { |
|
17 | 16 | |
18 | 17 | |
19 | 18 | /** |
@@ -23,8 +22,7 @@ discard block |
||
23 | 22 | * |
24 | 23 | * @return \PHPUnit\Framework\TestResult |
25 | 24 | */ |
26 | - public function run(TestResult $result=null) |
|
27 | - { |
|
25 | + public function run(TestResult $result=null) { |
|
28 | 26 | $result = parent::run($result); |
29 | 27 | printPHPCodeSnifferTestOutput(); |
30 | 28 | return $result; |
@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | include_once 'TestSuite.php'; |
35 | 35 | } |
36 | 36 | |
37 | -class PHP_CodeSniffer_AllTests |
|
38 | -{ |
|
37 | +class PHP_CodeSniffer_AllTests { |
|
39 | 38 | |
40 | 39 | |
41 | 40 | /** |
@@ -43,8 +42,7 @@ discard block |
||
43 | 42 | * |
44 | 43 | * @return \PHPUnit\Framework\TestSuite |
45 | 44 | */ |
46 | - public static function suite() |
|
47 | - { |
|
45 | + public static function suite() { |
|
48 | 46 | $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'] = []; |
49 | 47 | $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'] = []; |
50 | 48 |
@@ -20,8 +20,7 @@ discard block |
||
20 | 20 | use PHP_CodeSniffer\Util\Common; |
21 | 21 | use PHPUnit\Framework\TestCase; |
22 | 22 | |
23 | -abstract class AbstractSniffUnitTest extends TestCase |
|
24 | -{ |
|
23 | +abstract class AbstractSniffUnitTest extends TestCase { |
|
25 | 24 | |
26 | 25 | /** |
27 | 26 | * Enable or disable the backup and restoration of the $GLOBALS array. |
@@ -52,8 +51,7 @@ discard block |
||
52 | 51 | * |
53 | 52 | * @return void |
54 | 53 | */ |
55 | - protected function setUp() |
|
56 | - { |
|
54 | + protected function setUp() { |
|
57 | 55 | $class = get_class($this); |
58 | 56 | $this->standardsDir = $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'][$class]; |
59 | 57 | $this->testsDir = $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'][$class]; |
@@ -71,8 +69,7 @@ discard block |
||
71 | 69 | * |
72 | 70 | * @return string[] |
73 | 71 | */ |
74 | - protected function getTestFiles($testFileBase) |
|
75 | - { |
|
72 | + protected function getTestFiles($testFileBase) { |
|
76 | 73 | $testFiles = []; |
77 | 74 | |
78 | 75 | $dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR)); |
@@ -100,8 +97,7 @@ discard block |
||
100 | 97 | * |
101 | 98 | * @return boolean |
102 | 99 | */ |
103 | - protected function shouldSkipTest() |
|
104 | - { |
|
100 | + protected function shouldSkipTest() { |
|
105 | 101 | return false; |
106 | 102 | |
107 | 103 | }//end shouldSkipTest() |
@@ -113,8 +109,7 @@ discard block |
||
113 | 109 | * @return void |
114 | 110 | * @throws \PHPUnit\Framework\Exception |
115 | 111 | */ |
116 | - final public function testSniff() |
|
117 | - { |
|
112 | + final public function testSniff() { |
|
118 | 113 | // Skip this test if we can't run in this environment. |
119 | 114 | if ($this->shouldSkipTest() === true) { |
120 | 115 | $this->markTestSkipped(); |
@@ -217,8 +212,7 @@ discard block |
||
217 | 212 | * @return array |
218 | 213 | * @throws \PHP_CodeSniffer\Exceptions\RuntimeException |
219 | 214 | */ |
220 | - public function generateFailureMessages(LocalFile $file) |
|
221 | - { |
|
215 | + public function generateFailureMessages(LocalFile $file) { |
|
222 | 216 | $testFile = $file->getFilename(); |
223 | 217 | |
224 | 218 | $foundErrors = $file->getErrors(); |
@@ -418,8 +412,7 @@ discard block |
||
418 | 412 | * |
419 | 413 | * @return void |
420 | 414 | */ |
421 | - public function setCliValues($filename, $config) |
|
422 | - { |
|
415 | + public function setCliValues($filename, $config) { |
|
423 | 416 | return; |
424 | 417 | |
425 | 418 | }//end setCliValues() |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | use PHPUnit\TextUI\TestRunner; |
15 | 15 | use PHPUnit\Framework\TestSuite; |
16 | 16 | |
17 | -class AllSniffs |
|
18 | -{ |
|
17 | +class AllSniffs { |
|
19 | 18 | |
20 | 19 | |
21 | 20 | /** |
@@ -23,8 +22,7 @@ discard block |
||
23 | 22 | * |
24 | 23 | * @return void |
25 | 24 | */ |
26 | - public static function main() |
|
27 | - { |
|
25 | + public static function main() { |
|
28 | 26 | TestRunner::run(self::suite()); |
29 | 27 | |
30 | 28 | }//end main() |
@@ -38,8 +36,7 @@ discard block |
||
38 | 36 | * |
39 | 37 | * @return \PHPUnit\Framework\TestSuite |
40 | 38 | */ |
41 | - public static function suite() |
|
42 | - { |
|
39 | + public static function suite() { |
|
43 | 40 | $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = []; |
44 | 41 | $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = []; |
45 | 42 | $GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES'] = []; |
@@ -113,8 +110,7 @@ discard block |
||
113 | 110 | * @return array |
114 | 111 | * @see Standards::getInstalledStandardDetails() |
115 | 112 | */ |
116 | - protected static function getInstalledStandardDetails() |
|
117 | - { |
|
113 | + protected static function getInstalledStandardDetails() { |
|
118 | 114 | return Standards::getInstalledStandardDetails(true); |
119 | 115 | |
120 | 116 | }//end getInstalledStandardDetails() |
@@ -12,8 +12,7 @@ discard block |
||
12 | 12 | use PHP_CodeSniffer\Util\Common; |
13 | 13 | use PHPUnit\Framework\TestCase; |
14 | 14 | |
15 | -class IsCamelCapsTest extends TestCase |
|
16 | -{ |
|
15 | +class IsCamelCapsTest extends TestCase { |
|
17 | 16 | |
18 | 17 | |
19 | 18 | /** |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | * |
22 | 21 | * @return void |
23 | 22 | */ |
24 | - public function testValidNotClassFormatPublic() |
|
25 | - { |
|
23 | + public function testValidNotClassFormatPublic() { |
|
26 | 24 | $this->assertTrue(Common::isCamelCaps('thisIsCamelCaps', false, true, true)); |
27 | 25 | $this->assertTrue(Common::isCamelCaps('thisISCamelCaps', false, true, false)); |
28 | 26 | |
@@ -34,8 +32,7 @@ discard block |
||
34 | 32 | * |
35 | 33 | * @return void |
36 | 34 | */ |
37 | - public function testInvalidNotClassFormatPublic() |
|
38 | - { |
|
35 | + public function testInvalidNotClassFormatPublic() { |
|
39 | 36 | $this->assertFalse(Common::isCamelCaps('_thisIsCamelCaps', false, true, true)); |
40 | 37 | $this->assertFalse(Common::isCamelCaps('thisISCamelCaps', false, true, true)); |
41 | 38 | $this->assertFalse(Common::isCamelCaps('ThisIsCamelCaps', false, true, true)); |
@@ -57,8 +54,7 @@ discard block |
||
57 | 54 | * |
58 | 55 | * @return void |
59 | 56 | */ |
60 | - public function testValidNotClassFormatPrivate() |
|
61 | - { |
|
57 | + public function testValidNotClassFormatPrivate() { |
|
62 | 58 | $this->assertTrue(Common::isCamelCaps('_thisIsCamelCaps', false, false, true)); |
63 | 59 | $this->assertTrue(Common::isCamelCaps('_thisISCamelCaps', false, false, false)); |
64 | 60 | $this->assertTrue(Common::isCamelCaps('_i18N', false, false, true)); |
@@ -72,8 +68,7 @@ discard block |
||
72 | 68 | * |
73 | 69 | * @return void |
74 | 70 | */ |
75 | - public function testInvalidNotClassFormatPrivate() |
|
76 | - { |
|
71 | + public function testInvalidNotClassFormatPrivate() { |
|
77 | 72 | $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', false, false, true)); |
78 | 73 | $this->assertFalse(Common::isCamelCaps('_thisISCamelCaps', false, false, true)); |
79 | 74 | $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', false, false, true)); |
@@ -93,8 +88,7 @@ discard block |
||
93 | 88 | * |
94 | 89 | * @return void |
95 | 90 | */ |
96 | - public function testValidClassFormatPublic() |
|
97 | - { |
|
91 | + public function testValidClassFormatPublic() { |
|
98 | 92 | $this->assertTrue(Common::isCamelCaps('ThisIsCamelCaps', true, true, true)); |
99 | 93 | $this->assertTrue(Common::isCamelCaps('ThisISCamelCaps', true, true, false)); |
100 | 94 | $this->assertTrue(Common::isCamelCaps('This3IsCamelCaps', true, true, false)); |
@@ -107,8 +101,7 @@ discard block |
||
107 | 101 | * |
108 | 102 | * @return void |
109 | 103 | */ |
110 | - public function testInvalidClassFormat() |
|
111 | - { |
|
104 | + public function testInvalidClassFormat() { |
|
112 | 105 | $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', true)); |
113 | 106 | $this->assertFalse(Common::isCamelCaps('This-IsCamelCaps', true)); |
114 | 107 | $this->assertFalse(Common::isCamelCaps('This_Is_Camel_Caps', true)); |
@@ -124,8 +117,7 @@ discard block |
||
124 | 117 | * |
125 | 118 | * @return void |
126 | 119 | */ |
127 | - public function testInvalidClassFormatPrivate() |
|
128 | - { |
|
120 | + public function testInvalidClassFormatPrivate() { |
|
129 | 121 | $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, true)); |
130 | 122 | $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, false)); |
131 | 123 |