23
23
error_reporting (E_ALL );
24
24
25
25
if (ini_get ('phar.readonly ' ) === '1 ' ) {
26
- echo 'Unable to build, phar.readonly in php.ini is set to read only. ' . PHP_EOL ;
26
+ echo 'Unable to build, phar.readonly in php.ini is set to read only. ' . PHP_EOL ;
27
27
exit (1 );
28
28
}
29
29
30
- require_once dirname (__DIR__ ). '/autoload.php ' ;
31
- require_once dirname (__DIR__ ). '/src/Util/Tokens.php ' ;
30
+ require_once dirname (__DIR__ ) . '/autoload.php ' ;
31
+ require_once dirname (__DIR__ ) . '/src/Util/Tokens.php ' ;
32
32
33
33
if (defined ('PHP_CODESNIFFER_VERBOSITY ' ) === false ) {
34
34
define ('PHP_CODESNIFFER_VERBOSITY ' , 0 );
@@ -54,13 +54,13 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
54
54
$ tokenizer = new PHP ($ contents , $ config , "\n" );
55
55
$ tokens = $ tokenizer ->getTokens ();
56
56
} catch (TokenizerException $ e ) {
57
- throw new RuntimeException ('Failed to tokenize file ' . $ fullpath );
57
+ throw new RuntimeException ('Failed to tokenize file ' . $ fullpath );
58
58
}
59
59
60
60
$ stripped = '' ;
61
61
foreach ($ tokens as $ token ) {
62
62
if ($ token ['code ' ] === T_ATTRIBUTE_END || $ token ['code ' ] === T_OPEN_TAG ) {
63
- $ stripped .= $ token ['content ' ]. "\n" ;
63
+ $ stripped .= $ token ['content ' ] . "\n" ;
64
64
continue ;
65
65
}
66
66
@@ -87,13 +87,13 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
87
87
];
88
88
89
89
foreach ($ scripts as $ script ) {
90
- echo "Building $ script phar " . PHP_EOL ;
90
+ echo "Building $ script phar " . PHP_EOL ;
91
91
92
- $ pharName = $ script. '.phar ' ;
93
- $ pharFile = getcwd (). '/ ' . $ pharName ;
94
- echo "\t=> $ pharFile " . PHP_EOL ;
92
+ $ pharName = $ script . '.phar ' ;
93
+ $ pharFile = getcwd () . '/ ' . $ pharName ;
94
+ echo "\t=> $ pharFile " . PHP_EOL ;
95
95
if (file_exists ($ pharFile ) === true ) {
96
- echo "\t** file exists, removing ** " . PHP_EOL ;
96
+ echo "\t** file exists, removing ** " . PHP_EOL ;
97
97
unlink ($ pharFile );
98
98
}
99
99
@@ -105,7 +105,7 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
105
105
106
106
echo "\t=> adding files... " ;
107
107
108
- $ srcDir = realpath (__DIR__ . '/../src ' );
108
+ $ srcDir = realpath (__DIR__ . '/../src ' );
109
109
$ srcDirLen = strlen ($ srcDir );
110
110
111
111
$ rdi = new RecursiveDirectoryIterator ($ srcDir , RecursiveDirectoryIterator::FOLLOW_SYMLINKS );
@@ -123,11 +123,11 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
123
123
}
124
124
125
125
$ fullpath = $ file ->getPathname ();
126
- if (strpos ($ fullpath , DIRECTORY_SEPARATOR . 'Tests ' . DIRECTORY_SEPARATOR ) !== false ) {
126
+ if (strpos ($ fullpath , DIRECTORY_SEPARATOR . 'Tests ' . DIRECTORY_SEPARATOR ) !== false ) {
127
127
continue ;
128
128
}
129
129
130
- $ path = 'src ' . substr ($ fullpath , $ srcDirLen );
130
+ $ path = 'src ' . substr ($ fullpath , $ srcDirLen );
131
131
132
132
if (substr ($ filename , -4 ) === '.xml ' ) {
133
133
$ phar ->addFile ($ fullpath , $ path );
@@ -140,39 +140,39 @@ function stripWhitespaceAndComments(string $fullpath, Config $config)
140
140
}//end foreach
141
141
142
142
// Add requirements check.
143
- $ phar ->addFromString ('requirements.php ' , stripWhitespaceAndComments (realpath (__DIR__ . '/../requirements.php ' ), $ config ));
143
+ $ phar ->addFromString ('requirements.php ' , stripWhitespaceAndComments (realpath (__DIR__ . '/../requirements.php ' ), $ config ));
144
144
145
145
// Add autoloader.
146
- $ phar ->addFromString ('autoload.php ' , stripWhitespaceAndComments (realpath (__DIR__ . '/../autoload.php ' ), $ config ));
146
+ $ phar ->addFromString ('autoload.php ' , stripWhitespaceAndComments (realpath (__DIR__ . '/../autoload.php ' ), $ config ));
147
147
148
148
// Add licence file.
149
- $ phar ->addFile (realpath (__DIR__ . '/../licence.txt ' ), 'licence.txt ' );
149
+ $ phar ->addFile (realpath (__DIR__ . '/../licence.txt ' ), 'licence.txt ' );
150
150
151
- echo 'done ' . PHP_EOL ;
152
- echo "\t Added " . $ fileCount. ' files ' . PHP_EOL ;
151
+ echo 'done ' . PHP_EOL ;
152
+ echo "\t Added " . $ fileCount . ' files ' . PHP_EOL ;
153
153
154
154
/*
155
155
Add the stub.
156
156
*/
157
157
158
158
echo "\t=> adding stub... " ;
159
- $ stub = '#!/usr/bin/env php ' . "\n" ;
160
- $ stub .= '<?php ' . "\n" ;
161
- $ stub .= 'Phar::mapPhar( \'' . $ pharName. '\'); ' . "\n" ;
162
- $ stub .= 'require_once "phar:// ' . $ pharName. '/requirements.php"; ' . "\n" ;
163
- $ stub .= 'PHP_CodeSniffer\checkRequirements(); ' . "\n" ;
164
- $ stub .= 'require_once "phar:// ' . $ pharName. '/autoload.php"; ' . "\n" ;
165
- $ stub .= '$runner = new PHP_CodeSniffer\Runner(); ' . "\n" ;
166
- $ stub .= '$exitCode = $runner->run ' . $ script. '(); ' . "\n" ;
167
- $ stub .= 'exit($exitCode); ' . "\n" ;
159
+ $ stub = '#!/usr/bin/env php ' . "\n" ;
160
+ $ stub .= '<?php ' . "\n" ;
161
+ $ stub .= 'Phar::mapPhar( \'' . $ pharName . '\'); ' . "\n" ;
162
+ $ stub .= 'require_once "phar:// ' . $ pharName . '/requirements.php"; ' . "\n" ;
163
+ $ stub .= 'PHP_CodeSniffer\checkRequirements(); ' . "\n" ;
164
+ $ stub .= 'require_once "phar:// ' . $ pharName . '/autoload.php"; ' . "\n" ;
165
+ $ stub .= '$runner = new PHP_CodeSniffer\Runner(); ' . "\n" ;
166
+ $ stub .= '$exitCode = $runner->run ' . $ script . '(); ' . "\n" ;
167
+ $ stub .= 'exit($exitCode); ' . "\n" ;
168
168
$ stub .= '__HALT_COMPILER(); ' ;
169
169
$ phar ->setStub ($ stub );
170
170
171
- echo 'done ' . PHP_EOL ;
171
+ echo 'done ' . PHP_EOL ;
172
172
}//end foreach
173
173
174
174
Timing::printRunTime ();
175
175
176
176
echo PHP_EOL ;
177
- echo 'Filesize generated phpcs.phar file: ' . number_format (filesize (dirname (__DIR__ ). '/phpcs.phar ' ), 0 , ', ' , '. ' ). ' bytes ' . PHP_EOL ;
178
- echo 'Filesize generated phpcs.phar file: ' . number_format (filesize (dirname (__DIR__ ). '/phpcbf.phar ' ), 0 , ', ' , '. ' ). ' bytes ' . PHP_EOL ;
177
+ echo 'Filesize generated phpcs.phar file: ' . number_format (filesize (dirname (__DIR__ ) . '/phpcs.phar ' ), 0 , ', ' , '. ' ) . ' bytes ' . PHP_EOL ;
178
+ echo 'Filesize generated phpcs.phar file: ' . number_format (filesize (dirname (__DIR__ ) . '/phpcbf.phar ' ), 0 , ', ' , '. ' ) . ' bytes ' . PHP_EOL ;
0 commit comments