1 | <?php |
||
28 | class Compiler |
||
29 | { |
||
30 | /** |
||
31 | * @var string |
||
32 | * |
||
33 | * version |
||
34 | */ |
||
35 | protected $version; |
||
36 | |||
37 | /** |
||
38 | * @var DateTime |
||
39 | * |
||
40 | * versionDate |
||
41 | */ |
||
42 | protected $versionDate; |
||
43 | |||
44 | /** |
||
45 | * Compiles composer into a single phar file. |
||
46 | * |
||
47 | * @throws RuntimeException |
||
48 | */ |
||
49 | public function compile() |
||
79 | |||
80 | /** |
||
81 | * Add a file into the phar package. |
||
82 | * |
||
83 | * @param Phar $phar Phar object |
||
84 | * @param SplFileInfo $file File to add |
||
85 | * @param bool $strip strip |
||
86 | * |
||
87 | * @return Compiler self Object |
||
88 | */ |
||
89 | protected function addFile( |
||
111 | |||
112 | /** |
||
113 | * Add bin into Phar. |
||
114 | * |
||
115 | * @param Phar $phar Phar |
||
116 | * |
||
117 | * @return Compiler self Object |
||
118 | */ |
||
119 | protected function addBin(Phar $phar) |
||
127 | |||
128 | /** |
||
129 | * Removes whitespace from a PHP source string while preserving line numbers. |
||
130 | * |
||
131 | * @param string $source A PHP string |
||
132 | * |
||
133 | * @return string The PHP string with the whitespace removed |
||
134 | */ |
||
135 | protected function stripWhitespace($source) |
||
162 | |||
163 | protected function addStub(Phar $phar) |
||
192 | |||
193 | /** |
||
194 | * Add php files. |
||
195 | * |
||
196 | * @param Phar $phar Phar instance |
||
197 | * |
||
198 | * @return Compiler self Object |
||
199 | */ |
||
200 | private function addPHPFiles(Phar $phar) |
||
201 | { |
||
202 | /** |
||
203 | * All *.php files. |
||
204 | */ |
||
205 | $finder = new Finder(); |
||
206 | $finder |
||
207 | ->files() |
||
208 | ->ignoreVCS(true) |
||
209 | ->name('*.php') |
||
210 | ->notName('Compiler.php') |
||
211 | ->notName('ClassLoader.php') |
||
212 | ->in(realpath(__DIR__ . '/../../../src')); |
||
213 | |||
214 | foreach ($finder->files() as $file) { |
||
215 | $this->addFile($phar, $file); |
||
216 | } |
||
217 | |||
218 | return $this; |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * Add vendor files. |
||
223 | * |
||
224 | * @param Phar $phar Phar instance |
||
225 | * |
||
226 | * @return Compiler self Object |
||
227 | */ |
||
228 | private function addVendorFiles(Phar $phar) |
||
229 | { |
||
230 | $vendorPath = __DIR__ . '/../../../vendor/'; |
||
231 | |||
232 | /** |
||
233 | * All *.php files. |
||
234 | */ |
||
235 | $finder = new Finder(); |
||
236 | $finder |
||
237 | ->files() |
||
238 | ->ignoreVCS(true) |
||
239 | ->name('*.php') |
||
240 | ->exclude('Tests') |
||
241 | ->in(realpath($vendorPath . 'symfony/')); |
||
242 | |||
243 | foreach ($finder as $file) { |
||
244 | $this->addFile($phar, $file); |
||
245 | } |
||
246 | |||
247 | return $this; |
||
248 | } |
||
249 | |||
250 | /** |
||
251 | * Add composer vendor files. |
||
252 | * |
||
253 | * @param Phar $phar Phar |
||
254 | * |
||
255 | * @return Compiler self Object |
||
256 | */ |
||
257 | private function addComposerVendorFiles(Phar $phar) |
||
278 | |||
279 | /** |
||
280 | * Add license. |
||
281 | * |
||
282 | * @param Phar $phar Phar |
||
283 | * |
||
284 | * @return Compiler self Object |
||
285 | */ |
||
286 | private function addLicense(Phar $phar) |
||
292 | |||
293 | /** |
||
294 | * Load versions. |
||
295 | */ |
||
296 | private function loadVersion() |
||
319 | } |
||
320 |