|
4 | 4 |
|
5 | 5 | namespace Doctum; |
6 | 6 |
|
| 7 | +// To be able to fetch the version in this script afterwards |
| 8 | +require_once __DIR__ . '/../src/Doctum.php'; |
| 9 | + |
7 | 10 | use Phar; |
8 | 11 | use RecursiveDirectoryIterator; |
9 | 12 | use RecursiveIteratorIterator; |
|
22 | 25 | mkdir($buildRoot); |
23 | 26 | } |
24 | 27 |
|
| 28 | +$version = \Doctum\Doctum::VERSION; |
| 29 | + |
| 30 | +$pharAlias = 'doctum-' . $version . '.phar'; |
| 31 | + |
25 | 32 | $phar = new Phar( |
26 | 33 | $buildRoot . '/doctum.phar', |
27 | 34 | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, |
28 | | - 'doctum.phar' |
| 35 | + $pharAlias |
29 | 36 | ); |
30 | 37 |
|
31 | | -$shebang = "#!/usr/bin/env php"; |
| 38 | +$shebang = '#!/usr/bin/env php'; |
| 39 | + |
| 40 | +$date = date('c'); |
| 41 | + |
| 42 | +// See: https://github.com/zendtech/ZendOptimizerPlus/issues/115#issuecomment-25612769 |
| 43 | +// See: https://stackoverflow.com/a/13896692/5155484 |
| 44 | +$stub = <<<STUB |
| 45 | +<?php |
| 46 | +/** |
| 47 | + * Doctum phar, generated by Doctum the $date |
| 48 | + * @see https://github.com/code-lts/doctum#readme |
| 49 | + * @version $version |
| 50 | + * @license MIT |
| 51 | + */ |
| 52 | +Phar::interceptFileFuncs(); |
| 53 | +Phar::mapPhar('$pharAlias'); |
| 54 | +include 'phar://' . __FILE__ . '/bin/doctum-binary.php'; |
| 55 | +__HALT_COMPILER(); |
| 56 | +STUB; |
32 | 57 |
|
33 | 58 | $iterator = new RecursiveDirectoryIterator($srcRoot); |
34 | 59 | $iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS); |
@@ -192,7 +217,7 @@ public static function getExcludedFolders(): array |
192 | 217 |
|
193 | 218 | $pharFilesList = new RecursiveIteratorIterator($filter); |
194 | 219 |
|
195 | | -$phar->setStub($shebang . PHP_EOL . $phar->createDefaultStub('bin/doctum-binary.php')); |
| 220 | +$phar->setStub($shebang . PHP_EOL . $stub); |
196 | 221 | $phar->setSignatureAlgorithm(Phar::SHA256); |
197 | 222 | $phar->buildFromIterator($pharFilesList, $srcRoot); |
198 | 223 |
|
|
0 commit comments