3 namespace pharext\Task
;
12 class PharStub
implements Task
26 * @param string $stub file path to the stub
27 * @throws \pharext\Exception
29 function __construct(Phar
$phar, $stub) {
31 if (!file_exists($this->stub
= $stub)) {
32 throw new Exception("File '$stub' does not exist");
37 * @param bool $verbose
39 function run($verbose = false) {
41 printf("Using stub '%s'...\n", basename($this->stub
));
43 $stub = preg_replace_callback('/^#include <([^>]+)>/m', function($includes) {
44 return file_get_contents($includes[1], true, null, 5);
45 }, file_get_contents($this->stub
));
46 if ($this->phar
->isCompressed() && substr($stub, 0, 2) === "#!") {
47 $stub = substr($stub, strpos($stub, "\n")+
1);
49 $this->phar
->setStub($stub);