@@ -16,12 +16,12 @@ |
||
16 | 16 | $tokens = $phpcsFile->getTokens(); |
17 | 17 | $look_for = [ T_STRING, T_NS_SEPARATOR ]; |
18 | 18 | $next = $phpcsFile->findNext( $look_for, $stackPtr ); |
19 | - if ( $tokens[ $next ]['code'] === T_NS_SEPARATOR ) { |
|
19 | + if ( $tokens[ $next ][ 'code' ] === T_NS_SEPARATOR ) { |
|
20 | 20 | $name = ''; |
21 | 21 | do { |
22 | 22 | $next++; |
23 | - $name .= $tokens[ $next ]['content']; |
|
24 | - } while ( in_array( $tokens[ $next + 1 ]['code'], $look_for ) ); |
|
23 | + $name .= $tokens[ $next ][ 'content' ]; |
|
24 | + } while ( in_array( $tokens[ $next + 1 ][ 'code' ], $look_for ) ); |
|
25 | 25 | |
26 | 26 | $error = '`use` statement for class %s should not prefix with a backslash'; |
27 | 27 | $phpcsFile->addError( $error, $stackPtr, 'LeadingSlash', [ $name ] ); |
@@ -12,20 +12,20 @@ |
||
12 | 12 | return array( T_FUNCTION ); |
13 | 13 | } |
14 | 14 | |
15 | - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { |
|
15 | + public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) { |
|
16 | 16 | $tokens = $phpcsFile->getTokens(); |
17 | - if (isset($tokens[$stackPtr]['scope_closer']) === false) { |
|
17 | + if ( isset( $tokens[ $stackPtr ][ 'scope_closer' ] ) === false ) { |
|
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | - $errorData = array(strtolower($tokens[$stackPtr]['content'])); |
|
22 | - $namespace = $phpcsFile->findNext(array(T_NAMESPACE, T_FUNCTION), 0); |
|
23 | - if ($tokens[$namespace]['code'] !== T_NAMESPACE) { |
|
21 | + $errorData = array( strtolower( $tokens[ $stackPtr ][ 'content' ] ) ); |
|
22 | + $namespace = $phpcsFile->findNext( array( T_NAMESPACE, T_FUNCTION ), 0 ); |
|
23 | + if ( $tokens[ $namespace ][ 'code' ] !== T_NAMESPACE ) { |
|
24 | 24 | $error = 'Each %s must be in a namespace of at least one level (a top-level vendor name)'; |
25 | - $phpcsFile->addError($error, $stackPtr, 'MissingNamespace', $errorData); |
|
26 | - $phpcsFile->recordMetric($stackPtr, 'Function defined in namespace', 'no'); |
|
25 | + $phpcsFile->addError( $error, $stackPtr, 'MissingNamespace', $errorData ); |
|
26 | + $phpcsFile->recordMetric( $stackPtr, 'Function defined in namespace', 'no' ); |
|
27 | 27 | } else { |
28 | - $phpcsFile->recordMetric($stackPtr, 'Function defined in namespace', 'yes'); |
|
28 | + $phpcsFile->recordMetric( $stackPtr, 'Function defined in namespace', 'yes' ); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | } |
@@ -48,12 +48,12 @@ |
||
48 | 48 | $next_token = $tokens[ $next_pos ]; |
49 | 49 | |
50 | 50 | // Must be current or higher. |
51 | - $next_type_score = $look_for[ $next_token['code'] ]; |
|
51 | + $next_type_score = $look_for[ $next_token[ 'code' ] ]; |
|
52 | 52 | if ( $next_type_score < $current_score ) { |
53 | 53 | // ERROR! |
54 | 54 | $error = '%s found on line %s, but %s was declared on line %s.'; |
55 | 55 | $error .= ' Statements should be ordered `namespace`, `use`, `const`, `require`, then code.'; |
56 | - $data = [ $next_token['content'], $next_token['line'], $current_token['content'], $current_token['line'] ]; |
|
56 | + $data = [ $next_token[ 'content' ], $next_token[ 'line' ], $current_token[ 'content' ], $current_token[ 'line' ] ]; |
|
57 | 57 | $phpcsFile->addError( $error, $stackPtr, 'WrongOrder', $data ); |
58 | 58 | return; |
59 | 59 | } |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | return array( T_FUNCTION ); |
13 | 13 | } |
14 | 14 | |
15 | - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { |
|
15 | + public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) { |
|
16 | 16 | $tokens = $phpcsFile->getTokens(); |
17 | - if ( $tokens[ $stackPtr ]['level'] !== 0 ) { |
|
17 | + if ( $tokens[ $stackPtr ][ 'level' ] !== 0 ) { |
|
18 | 18 | // Ignore methods. |
19 | 19 | return; |
20 | 20 | } |
21 | 21 | |
22 | - $namespace = $phpcsFile->findNext( T_NAMESPACE , 0); |
|
22 | + $namespace = $phpcsFile->findNext( T_NAMESPACE, 0 ); |
|
23 | 23 | if ( empty( $namespace ) ) { |
24 | 24 | // Non-namespaced function. |
25 | 25 | return; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $filename = basename( $phpcsFile->getFileName() ); |
29 | 29 | if ( $filename !== 'namespace.php' ) { |
30 | 30 | $error = 'Namespaced functions must be in namespace.php'; |
31 | - $phpcsFile->addError($error, $stackPtr, 'WrongFile'); |
|
31 | + $phpcsFile->addError( $error, $stackPtr, 'WrongFile' ); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) { |
30 | 30 | $tokens = $phpcsFile->getTokens(); |
31 | - $namespace_ptr = $phpcsFile->findNext(T_NAMESPACE, 0); |
|
31 | + $namespace_ptr = $phpcsFile->findNext( T_NAMESPACE, 0 ); |
|
32 | 32 | if ( ! $namespace_ptr ) { |
33 | 33 | // Non-namespaced, skip check. |
34 | 34 | return; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | $class_name_ptr = $phpcsFile->findNext( T_STRING, $stackPtr ); |
38 | 38 | |
39 | - $class_name = $tokens[ $class_name_ptr ]['content']; |
|
39 | + $class_name = $tokens[ $class_name_ptr ][ 'content' ]; |
|
40 | 40 | |
41 | 41 | // Build a filename from the class name. |
42 | 42 | $class_slug = str_replace( '_', '-', strtolower( $class_name ) ); |
@@ -48,19 +48,19 @@ |
||
48 | 48 | do { |
49 | 49 | $other_declaration = $phpcsFile->findNext( [ T_FUNCTION ], $other_declaration_start ); |
50 | 50 | $other_declaration_start = $other_declaration + 1; |
51 | - } while ( $other_declaration && $tokens[ $other_declaration ]['level'] > 0 ); |
|
51 | + } while ( $other_declaration && $tokens[ $other_declaration ][ 'level' ] > 0 ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | if ( ! empty( $other_declaration ) ) { |
55 | 55 | $data = [ |
56 | - $tokens[ $first_class ]['line'], |
|
57 | - $tokens[ $other_declaration ]['content'], |
|
58 | - $tokens[ $other_declaration ]['line'], |
|
56 | + $tokens[ $first_class ][ 'line' ], |
|
57 | + $tokens[ $other_declaration ][ 'content' ], |
|
58 | + $tokens[ $other_declaration ][ 'line' ], |
|
59 | 59 | ]; |
60 | - $phpcsFile->addWarning($error, 0, 'FoundMultipleDeclarations', $data); |
|
61 | - $phpcsFile->recordMetric($stackPtr, 'Multiple declarations', 'yes'); |
|
60 | + $phpcsFile->addWarning( $error, 0, 'FoundMultipleDeclarations', $data ); |
|
61 | + $phpcsFile->recordMetric( $stackPtr, 'Multiple declarations', 'yes' ); |
|
62 | 62 | } else { |
63 | - $phpcsFile->recordMetric($stackPtr, 'Multiple declarations', 'no'); |
|
63 | + $phpcsFile->recordMetric( $stackPtr, 'Multiple declarations', 'no' ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // Ignore the rest of the file. |
@@ -17,44 +17,44 @@ discard block |
||
17 | 17 | error_reporting(E_ALL | E_STRICT); |
18 | 18 | |
19 | 19 | if (ini_get('phar.readonly') === '1') { |
20 | - echo 'Unable to build, phar.readonly in php.ini is set to read only.'.PHP_EOL; |
|
21 | - exit(1); |
|
20 | + echo 'Unable to build, phar.readonly in php.ini is set to read only.'.PHP_EOL; |
|
21 | + exit(1); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | $cwd = getCwd(); |
25 | 25 | require_once __DIR__.'/../CodeSniffer.php'; |
26 | 26 | |
27 | 27 | $scripts = array( |
28 | - 'phpcs', |
|
29 | - 'phpcbf', |
|
30 | - ); |
|
28 | + 'phpcs', |
|
29 | + 'phpcbf', |
|
30 | + ); |
|
31 | 31 | |
32 | 32 | foreach ($scripts as $script) { |
33 | - echo "Building $script phar".PHP_EOL; |
|
34 | - |
|
35 | - $pharFile = $cwd.'/'.$script.'.phar'; |
|
36 | - echo "\t=> $pharFile".PHP_EOL; |
|
37 | - if (file_exists($pharFile) === true) { |
|
38 | - echo "\t** file exists, removing **".PHP_EOL; |
|
39 | - unlink($pharFile); |
|
40 | - } |
|
41 | - |
|
42 | - $phar = new Phar($pharFile, 0, $script.'.phar'); |
|
43 | - |
|
44 | - echo "\t=> adding files from package.xml... "; |
|
45 | - buildFromPackage($phar); |
|
46 | - echo 'done'.PHP_EOL; |
|
47 | - |
|
48 | - echo "\t=> adding stub... "; |
|
49 | - $stub = '#!/usr/bin/env php'."\n"; |
|
50 | - $stub .= '<?php'."\n"; |
|
51 | - $stub .= 'Phar::mapPhar(\''.$script.'.phar\');'."\n"; |
|
52 | - $stub .= 'require_once "phar://'.$script.'.phar/CodeSniffer/CLI.php";'."\n"; |
|
53 | - $stub .= '$cli = new PHP_CodeSniffer_CLI();'."\n"; |
|
54 | - $stub .= '$cli->run'.$script.'();'."\n"; |
|
55 | - $stub .= '__HALT_COMPILER();'; |
|
56 | - $phar->setStub($stub); |
|
57 | - echo 'done'.PHP_EOL; |
|
33 | + echo "Building $script phar".PHP_EOL; |
|
34 | + |
|
35 | + $pharFile = $cwd.'/'.$script.'.phar'; |
|
36 | + echo "\t=> $pharFile".PHP_EOL; |
|
37 | + if (file_exists($pharFile) === true) { |
|
38 | + echo "\t** file exists, removing **".PHP_EOL; |
|
39 | + unlink($pharFile); |
|
40 | + } |
|
41 | + |
|
42 | + $phar = new Phar($pharFile, 0, $script.'.phar'); |
|
43 | + |
|
44 | + echo "\t=> adding files from package.xml... "; |
|
45 | + buildFromPackage($phar); |
|
46 | + echo 'done'.PHP_EOL; |
|
47 | + |
|
48 | + echo "\t=> adding stub... "; |
|
49 | + $stub = '#!/usr/bin/env php'."\n"; |
|
50 | + $stub .= '<?php'."\n"; |
|
51 | + $stub .= 'Phar::mapPhar(\''.$script.'.phar\');'."\n"; |
|
52 | + $stub .= 'require_once "phar://'.$script.'.phar/CodeSniffer/CLI.php";'."\n"; |
|
53 | + $stub .= '$cli = new PHP_CodeSniffer_CLI();'."\n"; |
|
54 | + $stub .= '$cli->run'.$script.'();'."\n"; |
|
55 | + $stub .= '__HALT_COMPILER();'; |
|
56 | + $phar->setStub($stub); |
|
57 | + echo 'done'.PHP_EOL; |
|
58 | 58 | }//end foreach |
59 | 59 | |
60 | 60 | |
@@ -67,25 +67,25 @@ discard block |
||
67 | 67 | */ |
68 | 68 | function buildFromPackage(&$phar) |
69 | 69 | { |
70 | - $packageFile = realpath(__DIR__.'/../package.xml'); |
|
71 | - $dom = new DOMDocument('1.0', 'utf-8'); |
|
72 | - $loaded = $dom->loadXML(file_get_contents($packageFile)); |
|
73 | - if ($loaded === false) { |
|
74 | - echo "Unable to load package file: $packageFile".PHP_EOL; |
|
75 | - exit(1); |
|
76 | - } |
|
77 | - |
|
78 | - $contents = $dom->getElementsByTagName('contents'); |
|
79 | - $topLevels = $contents->item(0)->childNodes; |
|
80 | - $tlLength = $topLevels->length; |
|
81 | - for ($l = 0; $l < $tlLength; $l++) { |
|
82 | - $currentLevel = $topLevels->item($l); |
|
83 | - buildFromNode($phar, $currentLevel, ''); |
|
84 | - } |
|
85 | - |
|
86 | - // Add licence file. |
|
87 | - $phar->addFile(realpath(__DIR__.'/../licence.txt'), 'licence.txt'); |
|
88 | - $phar['licence.txt']->compress(Phar::GZ); |
|
70 | + $packageFile = realpath(__DIR__.'/../package.xml'); |
|
71 | + $dom = new DOMDocument('1.0', 'utf-8'); |
|
72 | + $loaded = $dom->loadXML(file_get_contents($packageFile)); |
|
73 | + if ($loaded === false) { |
|
74 | + echo "Unable to load package file: $packageFile".PHP_EOL; |
|
75 | + exit(1); |
|
76 | + } |
|
77 | + |
|
78 | + $contents = $dom->getElementsByTagName('contents'); |
|
79 | + $topLevels = $contents->item(0)->childNodes; |
|
80 | + $tlLength = $topLevels->length; |
|
81 | + for ($l = 0; $l < $tlLength; $l++) { |
|
82 | + $currentLevel = $topLevels->item($l); |
|
83 | + buildFromNode($phar, $currentLevel, ''); |
|
84 | + } |
|
85 | + |
|
86 | + // Add licence file. |
|
87 | + $phar->addFile(realpath(__DIR__.'/../licence.txt'), 'licence.txt'); |
|
88 | + $phar['licence.txt']->compress(Phar::GZ); |
|
89 | 89 | |
90 | 90 | }//end buildFromPackage() |
91 | 91 | |
@@ -101,28 +101,28 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function buildFromNode(&$phar, $node, $prefix='') |
103 | 103 | { |
104 | - $nodeName = $node->nodeName; |
|
105 | - if ($nodeName !== 'dir' && $nodeName !== 'file') { |
|
106 | - // Invalid node. |
|
107 | - return; |
|
108 | - } |
|
109 | - |
|
110 | - $path = $prefix.$node->getAttribute('name'); |
|
111 | - if ($node->getAttribute('role') === 'php' || $node->getAttribute('role') === 'data') { |
|
112 | - $path = ltrim($path, '/'); |
|
113 | - $phar->addFile(realpath(__DIR__.'/../'.$path), $path); |
|
114 | - $phar[$path]->compress(Phar::GZ); |
|
115 | - } |
|
116 | - |
|
117 | - if ($nodeName === 'dir') { |
|
118 | - // Descend into the depths. |
|
119 | - $path = rtrim($path, '/').'/'; |
|
120 | - $children = $node->childNodes; |
|
121 | - $childLn = $children->length; |
|
122 | - for ($c = 0; $c < $childLn; $c++) { |
|
123 | - $child = $children->item($c); |
|
124 | - buildFromNode($phar, $child, $path); |
|
125 | - } |
|
126 | - } |
|
104 | + $nodeName = $node->nodeName; |
|
105 | + if ($nodeName !== 'dir' && $nodeName !== 'file') { |
|
106 | + // Invalid node. |
|
107 | + return; |
|
108 | + } |
|
109 | + |
|
110 | + $path = $prefix.$node->getAttribute('name'); |
|
111 | + if ($node->getAttribute('role') === 'php' || $node->getAttribute('role') === 'data') { |
|
112 | + $path = ltrim($path, '/'); |
|
113 | + $phar->addFile(realpath(__DIR__.'/../'.$path), $path); |
|
114 | + $phar[$path]->compress(Phar::GZ); |
|
115 | + } |
|
116 | + |
|
117 | + if ($nodeName === 'dir') { |
|
118 | + // Descend into the depths. |
|
119 | + $path = rtrim($path, '/').'/'; |
|
120 | + $children = $node->childNodes; |
|
121 | + $childLn = $children->length; |
|
122 | + for ($c = 0; $c < $childLn; $c++) { |
|
123 | + $child = $children->item($c); |
|
124 | + buildFromNode($phar, $child, $path); |
|
125 | + } |
|
126 | + } |
|
127 | 127 | |
128 | 128 | }//end buildFromNode() |
@@ -14,47 +14,47 @@ discard block |
||
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 | $cwd = getCwd(); |
25 | -require_once __DIR__.'/../CodeSniffer.php'; |
|
25 | +require_once __DIR__ . '/../CodeSniffer.php'; |
|
26 | 26 | |
27 | 27 | $scripts = array( |
28 | 28 | 'phpcs', |
29 | 29 | 'phpcbf', |
30 | 30 | ); |
31 | 31 | |
32 | -foreach ($scripts as $script) { |
|
33 | - echo "Building $script phar".PHP_EOL; |
|
32 | +foreach ( $scripts as $script ) { |
|
33 | + echo "Building $script phar" . PHP_EOL; |
|
34 | 34 | |
35 | - $pharFile = $cwd.'/'.$script.'.phar'; |
|
36 | - echo "\t=> $pharFile".PHP_EOL; |
|
37 | - if (file_exists($pharFile) === true) { |
|
38 | - echo "\t** file exists, removing **".PHP_EOL; |
|
39 | - unlink($pharFile); |
|
35 | + $pharFile = $cwd . '/' . $script . '.phar'; |
|
36 | + echo "\t=> $pharFile" . PHP_EOL; |
|
37 | + if ( file_exists( $pharFile ) === true ) { |
|
38 | + echo "\t** file exists, removing **" . PHP_EOL; |
|
39 | + unlink( $pharFile ); |
|
40 | 40 | } |
41 | 41 | |
42 | - $phar = new Phar($pharFile, 0, $script.'.phar'); |
|
42 | + $phar = new Phar( $pharFile, 0, $script . '.phar' ); |
|
43 | 43 | |
44 | 44 | echo "\t=> adding files from package.xml... "; |
45 | - buildFromPackage($phar); |
|
46 | - echo 'done'.PHP_EOL; |
|
45 | + buildFromPackage( $phar ); |
|
46 | + echo 'done' . PHP_EOL; |
|
47 | 47 | |
48 | 48 | echo "\t=> adding stub... "; |
49 | - $stub = '#!/usr/bin/env php'."\n"; |
|
50 | - $stub .= '<?php'."\n"; |
|
51 | - $stub .= 'Phar::mapPhar(\''.$script.'.phar\');'."\n"; |
|
52 | - $stub .= 'require_once "phar://'.$script.'.phar/CodeSniffer/CLI.php";'."\n"; |
|
53 | - $stub .= '$cli = new PHP_CodeSniffer_CLI();'."\n"; |
|
54 | - $stub .= '$cli->run'.$script.'();'."\n"; |
|
49 | + $stub = '#!/usr/bin/env php' . "\n"; |
|
50 | + $stub .= '<?php' . "\n"; |
|
51 | + $stub .= 'Phar::mapPhar(\'' . $script . '.phar\');' . "\n"; |
|
52 | + $stub .= 'require_once "phar://' . $script . '.phar/CodeSniffer/CLI.php";' . "\n"; |
|
53 | + $stub .= '$cli = new PHP_CodeSniffer_CLI();' . "\n"; |
|
54 | + $stub .= '$cli->run' . $script . '();' . "\n"; |
|
55 | 55 | $stub .= '__HALT_COMPILER();'; |
56 | - $phar->setStub($stub); |
|
57 | - echo 'done'.PHP_EOL; |
|
56 | + $phar->setStub( $stub ); |
|
57 | + echo 'done' . PHP_EOL; |
|
58 | 58 | }//end foreach |
59 | 59 | |
60 | 60 | |
@@ -65,27 +65,27 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return void |
67 | 67 | */ |
68 | -function buildFromPackage(&$phar) |
|
68 | +function buildFromPackage( &$phar ) |
|
69 | 69 | { |
70 | - $packageFile = realpath(__DIR__.'/../package.xml'); |
|
71 | - $dom = new DOMDocument('1.0', 'utf-8'); |
|
72 | - $loaded = $dom->loadXML(file_get_contents($packageFile)); |
|
73 | - if ($loaded === false) { |
|
74 | - echo "Unable to load package file: $packageFile".PHP_EOL; |
|
75 | - exit(1); |
|
70 | + $packageFile = realpath( __DIR__ . '/../package.xml' ); |
|
71 | + $dom = new DOMDocument( '1.0', 'utf-8' ); |
|
72 | + $loaded = $dom->loadXML( file_get_contents( $packageFile ) ); |
|
73 | + if ( $loaded === false ) { |
|
74 | + echo "Unable to load package file: $packageFile" . PHP_EOL; |
|
75 | + exit( 1 ); |
|
76 | 76 | } |
77 | 77 | |
78 | - $contents = $dom->getElementsByTagName('contents'); |
|
79 | - $topLevels = $contents->item(0)->childNodes; |
|
78 | + $contents = $dom->getElementsByTagName( 'contents' ); |
|
79 | + $topLevels = $contents->item( 0 )->childNodes; |
|
80 | 80 | $tlLength = $topLevels->length; |
81 | - for ($l = 0; $l < $tlLength; $l++) { |
|
82 | - $currentLevel = $topLevels->item($l); |
|
83 | - buildFromNode($phar, $currentLevel, ''); |
|
81 | + for ( $l = 0; $l < $tlLength; $l++ ) { |
|
82 | + $currentLevel = $topLevels->item( $l ); |
|
83 | + buildFromNode( $phar, $currentLevel, '' ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // Add licence file. |
87 | - $phar->addFile(realpath(__DIR__.'/../licence.txt'), 'licence.txt'); |
|
88 | - $phar['licence.txt']->compress(Phar::GZ); |
|
87 | + $phar->addFile( realpath( __DIR__ . '/../licence.txt' ), 'licence.txt' ); |
|
88 | + $phar[ 'licence.txt' ]->compress( Phar::GZ ); |
|
89 | 89 | |
90 | 90 | }//end buildFromPackage() |
91 | 91 | |
@@ -99,29 +99,29 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return void |
101 | 101 | */ |
102 | -function buildFromNode(&$phar, $node, $prefix='') |
|
102 | +function buildFromNode( &$phar, $node, $prefix = '' ) |
|
103 | 103 | { |
104 | 104 | $nodeName = $node->nodeName; |
105 | - if ($nodeName !== 'dir' && $nodeName !== 'file') { |
|
105 | + if ( $nodeName !== 'dir' && $nodeName !== 'file' ) { |
|
106 | 106 | // Invalid node. |
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | - $path = $prefix.$node->getAttribute('name'); |
|
111 | - if ($node->getAttribute('role') === 'php' || $node->getAttribute('role') === 'data') { |
|
112 | - $path = ltrim($path, '/'); |
|
113 | - $phar->addFile(realpath(__DIR__.'/../'.$path), $path); |
|
114 | - $phar[$path]->compress(Phar::GZ); |
|
110 | + $path = $prefix . $node->getAttribute( 'name' ); |
|
111 | + if ( $node->getAttribute( 'role' ) === 'php' || $node->getAttribute( 'role' ) === 'data' ) { |
|
112 | + $path = ltrim( $path, '/' ); |
|
113 | + $phar->addFile( realpath( __DIR__ . '/../' . $path ), $path ); |
|
114 | + $phar[ $path ]->compress( Phar::GZ ); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ($nodeName === 'dir') { |
|
117 | + if ( $nodeName === 'dir' ) { |
|
118 | 118 | // Descend into the depths. |
119 | - $path = rtrim($path, '/').'/'; |
|
119 | + $path = rtrim( $path, '/' ) . '/'; |
|
120 | 120 | $children = $node->childNodes; |
121 | 121 | $childLn = $children->length; |
122 | - for ($c = 0; $c < $childLn; $c++) { |
|
123 | - $child = $children->item($c); |
|
124 | - buildFromNode($phar, $child, $path); |
|
122 | + for ( $c = 0; $c < $childLn; $c++ ) { |
|
123 | + $child = $children->item( $c ); |
|
124 | + buildFromNode( $phar, $child, $path ); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 |
@@ -65,8 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return void |
67 | 67 | */ |
68 | -function buildFromPackage(&$phar) |
|
69 | -{ |
|
68 | +function buildFromPackage(&$phar) { |
|
70 | 69 | $packageFile = realpath(__DIR__.'/../package.xml'); |
71 | 70 | $dom = new DOMDocument('1.0', 'utf-8'); |
72 | 71 | $loaded = $dom->loadXML(file_get_contents($packageFile)); |
@@ -99,8 +98,7 @@ discard block |
||
99 | 98 | * |
100 | 99 | * @return void |
101 | 100 | */ |
102 | -function buildFromNode(&$phar, $node, $prefix='') |
|
103 | -{ |
|
101 | +function buildFromNode(&$phar, $node, $prefix='') { |
|
104 | 102 | $nodeName = $node->nodeName; |
105 | 103 | if ($nodeName !== 'dir' && $nodeName !== 'file') { |
106 | 104 | // Invalid node. |
@@ -31,42 +31,42 @@ |
||
31 | 31 | { |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Returns an array of tokens this test wants to listen for. |
|
36 | - * |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function register() |
|
40 | - { |
|
41 | - return PHP_CodeSniffer_Tokens::$castTokens; |
|
34 | + /** |
|
35 | + * Returns an array of tokens this test wants to listen for. |
|
36 | + * |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function register() |
|
40 | + { |
|
41 | + return PHP_CodeSniffer_Tokens::$castTokens; |
|
42 | 42 | |
43 | - }//end register() |
|
43 | + }//end register() |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Processes this test, when one of its tokens is encountered. |
|
48 | - * |
|
49 | - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
50 | - * @param int $stackPtr The position of the current token in |
|
51 | - * the stack passed in $tokens. |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
56 | - { |
|
57 | - $tokens = $phpcsFile->getTokens(); |
|
46 | + /** |
|
47 | + * Processes this test, when one of its tokens is encountered. |
|
48 | + * |
|
49 | + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
50 | + * @param int $stackPtr The position of the current token in |
|
51 | + * the stack passed in $tokens. |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
56 | + { |
|
57 | + $tokens = $phpcsFile->getTokens(); |
|
58 | 58 | |
59 | - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { |
|
60 | - return; |
|
61 | - } |
|
59 | + if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { |
|
60 | + return; |
|
61 | + } |
|
62 | 62 | |
63 | - $error = 'A cast statement must not be followed by a space'; |
|
64 | - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceFound'); |
|
65 | - if ($fix === true) { |
|
66 | - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); |
|
67 | - } |
|
63 | + $error = 'A cast statement must not be followed by a space'; |
|
64 | + $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceFound'); |
|
65 | + if ($fix === true) { |
|
66 | + $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); |
|
67 | + } |
|
68 | 68 | |
69 | - }//end process() |
|
69 | + }//end process() |
|
70 | 70 | |
71 | 71 | |
72 | 72 | }//end class |
@@ -52,18 +52,18 @@ |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
55 | + public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) |
|
56 | 56 | { |
57 | 57 | $tokens = $phpcsFile->getTokens(); |
58 | 58 | |
59 | - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { |
|
59 | + if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] !== T_WHITESPACE ) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $error = 'A cast statement must not be followed by a space'; |
64 | - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceFound'); |
|
65 | - if ($fix === true) { |
|
66 | - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); |
|
64 | + $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpaceFound' ); |
|
65 | + if ( $fix === true ) { |
|
66 | + $phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), '' ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | }//end process() |
@@ -27,8 +27,7 @@ discard block |
||
27 | 27 | * @version Release: @package_version@ |
28 | 28 | * @link http://pear.php.net/package/PHP_CodeSniffer |
29 | 29 | */ |
30 | -class Generic_Sniffs_Formatting_NoSpaceAfterCastSniff implements PHP_CodeSniffer_Sniff |
|
31 | -{ |
|
30 | +class Generic_Sniffs_Formatting_NoSpaceAfterCastSniff implements PHP_CodeSniffer_Sniff { |
|
32 | 31 | |
33 | 32 | |
34 | 33 | /** |
@@ -36,8 +35,7 @@ discard block |
||
36 | 35 | * |
37 | 36 | * @return array |
38 | 37 | */ |
39 | - public function register() |
|
40 | - { |
|
38 | + public function register() { |
|
41 | 39 | return PHP_CodeSniffer_Tokens::$castTokens; |
42 | 40 | |
43 | 41 | }//end register() |
@@ -52,8 +50,7 @@ discard block |
||
52 | 50 | * |
53 | 51 | * @return void |
54 | 52 | */ |
55 | - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
56 | - { |
|
53 | + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { |
|
57 | 54 | $tokens = $phpcsFile->getTokens(); |
58 | 55 | |
59 | 56 | if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { |
@@ -28,63 +28,63 @@ |
||
28 | 28 | class Generic_Sniffs_Formatting_SpaceAfterNotSniff implements PHP_CodeSniffer_Sniff |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * A list of tokenizers this sniff supports. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - public $supportedTokenizers = array( |
|
37 | - 'PHP', |
|
38 | - 'JS', |
|
39 | - ); |
|
31 | + /** |
|
32 | + * A list of tokenizers this sniff supports. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + public $supportedTokenizers = array( |
|
37 | + 'PHP', |
|
38 | + 'JS', |
|
39 | + ); |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * Returns an array of tokens this test wants to listen for. |
|
44 | - * |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function register() |
|
48 | - { |
|
49 | - return array(T_BOOLEAN_NOT); |
|
42 | + /** |
|
43 | + * Returns an array of tokens this test wants to listen for. |
|
44 | + * |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function register() |
|
48 | + { |
|
49 | + return array(T_BOOLEAN_NOT); |
|
50 | 50 | |
51 | - }//end register() |
|
51 | + }//end register() |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * Processes this test, when one of its tokens is encountered. |
|
56 | - * |
|
57 | - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. |
|
58 | - * @param int $stackPtr The position of the current token in |
|
59 | - * the stack passed in $tokens. |
|
60 | - * |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
64 | - { |
|
65 | - $tokens = $phpcsFile->getTokens(); |
|
54 | + /** |
|
55 | + * Processes this test, when one of its tokens is encountered. |
|
56 | + * |
|
57 | + * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. |
|
58 | + * @param int $stackPtr The position of the current token in |
|
59 | + * the stack passed in $tokens. |
|
60 | + * |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
64 | + { |
|
65 | + $tokens = $phpcsFile->getTokens(); |
|
66 | 66 | |
67 | - $spacing = 0; |
|
68 | - if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { |
|
69 | - $spacing = $tokens[($stackPtr + 1)]['length']; |
|
70 | - } |
|
67 | + $spacing = 0; |
|
68 | + if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { |
|
69 | + $spacing = $tokens[($stackPtr + 1)]['length']; |
|
70 | + } |
|
71 | 71 | |
72 | - if ($spacing === 1) { |
|
73 | - return; |
|
74 | - } |
|
72 | + if ($spacing === 1) { |
|
73 | + return; |
|
74 | + } |
|
75 | 75 | |
76 | - $message = 'There must be a single space after a NOT operator; %s found'; |
|
77 | - $fix = $phpcsFile->addFixableError($message, $stackPtr, 'Incorrect', array($spacing)); |
|
76 | + $message = 'There must be a single space after a NOT operator; %s found'; |
|
77 | + $fix = $phpcsFile->addFixableError($message, $stackPtr, 'Incorrect', array($spacing)); |
|
78 | 78 | |
79 | - if ($fix === true) { |
|
80 | - if ($spacing === 0) { |
|
81 | - $phpcsFile->fixer->addContent($stackPtr, ' '); |
|
82 | - } else { |
|
83 | - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); |
|
84 | - } |
|
85 | - } |
|
79 | + if ($fix === true) { |
|
80 | + if ($spacing === 0) { |
|
81 | + $phpcsFile->fixer->addContent($stackPtr, ' '); |
|
82 | + } else { |
|
83 | + $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - }//end process() |
|
87 | + }//end process() |
|
88 | 88 | |
89 | 89 | |
90 | 90 | }//end class |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function register() |
48 | 48 | { |
49 | - return array(T_BOOLEAN_NOT); |
|
49 | + return array( T_BOOLEAN_NOT ); |
|
50 | 50 | |
51 | 51 | }//end register() |
52 | 52 | |
@@ -60,27 +60,27 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return void |
62 | 62 | */ |
63 | - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
63 | + public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) |
|
64 | 64 | { |
65 | 65 | $tokens = $phpcsFile->getTokens(); |
66 | 66 | |
67 | 67 | $spacing = 0; |
68 | - if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { |
|
69 | - $spacing = $tokens[($stackPtr + 1)]['length']; |
|
68 | + if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_WHITESPACE ) { |
|
69 | + $spacing = $tokens[ ( $stackPtr + 1 ) ][ 'length' ]; |
|
70 | 70 | } |
71 | 71 | |
72 | - if ($spacing === 1) { |
|
72 | + if ( $spacing === 1 ) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | 76 | $message = 'There must be a single space after a NOT operator; %s found'; |
77 | - $fix = $phpcsFile->addFixableError($message, $stackPtr, 'Incorrect', array($spacing)); |
|
77 | + $fix = $phpcsFile->addFixableError( $message, $stackPtr, 'Incorrect', array( $spacing ) ); |
|
78 | 78 | |
79 | - if ($fix === true) { |
|
80 | - if ($spacing === 0) { |
|
81 | - $phpcsFile->fixer->addContent($stackPtr, ' '); |
|
79 | + if ( $fix === true ) { |
|
80 | + if ( $spacing === 0 ) { |
|
81 | + $phpcsFile->fixer->addContent( $stackPtr, ' ' ); |
|
82 | 82 | } else { |
83 | - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); |
|
83 | + $phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), ' ' ); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 |
@@ -25,8 +25,7 @@ discard block |
||
25 | 25 | * @version Release: @package_version@ |
26 | 26 | * @link http://pear.php.net/package/PHP_CodeSniffer |
27 | 27 | */ |
28 | -class Generic_Sniffs_Formatting_SpaceAfterNotSniff implements PHP_CodeSniffer_Sniff |
|
29 | -{ |
|
28 | +class Generic_Sniffs_Formatting_SpaceAfterNotSniff implements PHP_CodeSniffer_Sniff { |
|
30 | 29 | |
31 | 30 | /** |
32 | 31 | * A list of tokenizers this sniff supports. |
@@ -44,8 +43,7 @@ discard block |
||
44 | 43 | * |
45 | 44 | * @return array |
46 | 45 | */ |
47 | - public function register() |
|
48 | - { |
|
46 | + public function register() { |
|
49 | 47 | return array(T_BOOLEAN_NOT); |
50 | 48 | |
51 | 49 | }//end register() |
@@ -60,8 +58,7 @@ discard block |
||
60 | 58 | * |
61 | 59 | * @return void |
62 | 60 | */ |
63 | - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
64 | - { |
|
61 | + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { |
|
65 | 62 | $tokens = $phpcsFile->getTokens(); |
66 | 63 | |
67 | 64 | $spacing = 0; |