Add setWhitelist method to allow controlling which files get replaced.#7
Add setWhitelist method to allow controlling which files get replaced.#7
Conversation
|
Thank you for the great PR. Whitelist can be useful. I tried to test |
|
@dg That's only a guess. It was deep within Laravel's call stack. Perhaps the added layer of Docker caused the problem. We stopped digging at some point and just created the exclusion. In any case, even if the bug was somewhere else, this still covers a number of legitimate scenarios. |
|
I am thinking about method name… It is not entirely clear that this is about paths, ie allowed paths. What about |
|
Sure, whichever you prefer. |
|
Actually phpspec stops generating PHP classes based on specs: Was able to get it working with @afilina fork and custom phpspec bootstrap: <?php
require __DIR__.'/../vendor/autoload.php';
DG\BypassFinals::setWhitelist(findFinalClassesToBypass());
DG\BypassFinals::enable();
function findFinalClassesToBypass(): array
{
$finalClasses = (new Symfony\Component\Finder\Finder())
->in([__DIR__.'/../vendor/symfony/security-core'])
->name('*.php')
->contains('final class');
return array_values(array_map(
function (SplFileInfo $fileInfo) {
return $fileInfo->getRealPath();
},
iterator_to_array($finalClasses)
));
}@afilina Thanks! 👍 |
|
@dg PR will be merged & released? This feature is very important for me too |
|
Fork with this feature: https://github.com/avto-dev/bypass-finals @afilina - great thx! 👍 |
|
Isn't the name kinda misleading since you cannot just set a path, but need to set every filepath individually? Also it doesn't take into consideration the difference between operating systems (\ vs /). |
Reason behind this feature:
Some frameworks stop working because of DIR and such, since the files are now served from tmp. This prompted me to add a more fine-grained control.
I added a test and documentation. The old behavior remains unaffected.