phine/lib-phar — pull request #1 by Toflar (2014-08-15 19:16:44+00:00)
Title: Added support for webPhar rewrite function

Hi there!

Incredible code quality! I gave my very best and hope it's good enough for you :-)

I had the problem that I could not add any rewrite function before your `Stub` helper class generated some `Phar::webPhar()` code. I had to help myself using the banner and replacing the first occurrence of `*/` which obviously worked fine and did the job for me but I thought I wanted to give something back :-)

So instead of hacking something like that:
```php
$rewrite_function = "function rewrite_function(\$path) {
return 'index.php';
}";

$stub = Phine\Phar\Stub::create()
->webPhar(null, 'index.php', null, array(), 'rewrite_function')
->getStub();

$stub = preg_replace('/(\*\/)/', '$1' . "\n\n" . $rewrite_function, $stub, 1);

$builder->setStub($stub);
```

you can can now do this:
```php
$rewrite_function = "function rewrite_function(\$path) {
return 'index.php';
}";

$stub = Phine\Phar\Stub::create()
->webPhar(null, 'index.php', null, array())
->setRewriteFunction('rewrite_function', $rewrite_function)
->getStub();

$builder->setStub($stub);
```

Hope you like it :-)