-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Scoper] Pass directly the files to PHP-Scoper instead of finder instances #407
Comments
Wouldn't https://github.com/humbug/php-scoper#whitelisted-files fit the bill? |
If I understood correctly that setting allows whitelisting a concrete set of files only. A mechanism based in finders would be much more flexible and powerful. |
I'm wondering if it's worth it though. I realised quite late, but in the scoper file you already have access to the scoped Finder hence you can use it there right away and pass the result to the config which doesn't increase things in complexity for the user and simplifies things on PHP-Scoper side |
How would that work? Could you please provide an example for the use case I present in the issue description? (output all the files in a given directory but prefix only |
Sure, here's one (although not using the Finder but you could totally do): https://github.com/humbug/php-scoper/blob/master/scoper.inc.php#L17 |
Ok, got it. The following works and is equivalent to my example: $files_to_output_untouched = (static function (): array {
$finder = Finder::create()->files()->in('src')->notName('*.php');
$files = [];
foreach ($finder as $file) {
$files[] = $file->getPathName();
}
return $files;
})();
return [
'files-whitelist' => $files_to_output_untouched,
'finders' => [ Finder::create()->files()->in('src') ],
... Maybe something like this could be added to the documentation, but that's a different story 🙂 |
I think it would be clearer if the same would be done for |
Feature Request
Right now there's a
finders
configuration key that tells how to find the files to be processed and included in the output. The problem is that there's no way to tell PHP Scoper "include these files in the output, but don't process them".I think this could be implemented with a new
output_finders
key. It would work as follows:output_finders
orfinders
is included in the output.finders
is processed.Or put another way:
output_finders
but not byfinders
is copied verbatim to the output.finders
is processed and then generated in the output (as it happens now).That sounds complicated but it makes sense if we look at a simple example:
So this means "I want everything from
src
in the output, but only PHP files should be processed".This is something I actually need for my job so I can implement it and submit a pull request. In fact I've already been experimenting with the code and seems definitely doable.
The text was updated successfully, but these errors were encountered: