-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Finder excluded does NOT exclude relative directories #47431
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
Comments
@raveren Would you like to send a request to the documentation repository to update the docs accordingly? |
Okay here's the full reproduceable file, need to run it on linux/wsl in a symfony/laravel root directory (next to <?php
require __DIR__ . '/../vendor/autoload.php';
$dir = __DIR__;
exec("mkdir -p {$dir}/ex");
exec("mkdir -p {$dir}/not");
exec("mkdir -p {$dir}/not/ex");
exec("touch {$dir}/ex/should-be-excluded.php");
exec("touch {$dir}/not/ex/should-be-included.php");
$finder = Symfony\Component\Finder\Finder::create() // https://symfony.com/doc/current/components/finder.html
->in($dir)
->exclude('ex')
;
$parsedFiles = [];
foreach ($finder as $item) {
$parsedFiles[] = $item->getRelativePathname();
}
dd(
$parsedFiles,
'this must be true:',
file_exists("{$dir}/not/ex/should-be-included.php"),
'this must be also true:',
in_array("{$dir}/not/ex/should-be-included.php", $parsedFiles)
); The actually sad thing is, I can't figure out how to exclude a specific directory from Finder! |
I think updating documentation is not enough and there is a bug or bad behavior. $finder = new Finder();
$finder
->in(__DIR__)
->exclude('foo');
Actual result is
I think expected result should be
Finder exclude folder in all path and is not relative. I think exclude MUST be relative and if we want exclude in all path, it must be explicit, WDYT ? (If I'm not wrong, currently there is no way to exclude "foo" only at first level) |
Hey, thanks for your report! |
Hey, thanks for your report! |
Hello? This issue is about to be closed if nobody replies. |
That's a nice bot, here's a ⚙, good boy, carson! The feature is still relevant and unsolved :) |
Nothing will change that if nobody's gonna do that change though. PR welcome :) |
The thing is, there is no concensus what must be done in this case, it's quite a big BC break if we just "fix" it. What do you think? Should a new, 'correctly' working method be added? I don't use Symfony, what is the regular policy on? |
This seems to be similar territory as #28158. |
The non-BC way suggested approach in #28158 was:
|
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
PR with a proposed implementation is in #54752 if anyone feels like testing/reviewing. |
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
Hey, thanks for your report! |
@carsonbot the linked PR #54752 is still unmerged so this is still relevant... |
Hey, thanks for your report! |
Friendly reminder that this issue exists. If I don't hear anything I'll close this. |
Yes, @carsonbot, this is still relevant, the fix-pr is still open, waiting for attention |
Symfony version(s) affected
5.4+
Description
I'm configuring php-cs-fixer which uses the
symfony/finder
component and noticed it does not work as advertised.Will exclude all files that have
/storage/
in its path, such as"resources/lang/de/storage/index.php"
.Looking at the source it's quite obvious:
https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/Finder/Finder.php#L735
and going inside:
How to reproduce
Have dir structure
Possible Solution
No response
Additional Context
symfony/finder in my vendors directory reports itself as v5.4
relevant docs:

https://symfony.com/doc/current/components/finder.html#location
The text was updated successfully, but these errors were encountered: