-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Finder name glob does not behave as documented #42675
Comments
Hey, thanks for your report! |
Hello? This issue is about to be closed if nobody replies. |
I suggest updating the doc to explain the current behavior instead of doing a BC break |
Hey, thanks for your report! |
Still relevant. |
Calling this behavior a BC break is debatable.
as expected. Changing the behavior
To me, it could be considered as a bugfix. |
Hey, thanks for your report! |
Still relevant |
The phpdoc should be changed. |
I opened #50921 then |
This PR was merged into the 5.4 branch. Discussion ---------- [Finder] Fix phpdoc about glob syntax | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes ? no ? just phpdoc | New feature? | no | Deprecations? | no | Tickets | Fix #42675 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Closes #42675 cc `@nicolas`-grekas Commits ------- 2340a75 Fix Finder phpdoc
When a bug becomes a feature. |
In php |
Symfony version(s) affected: 5.3.6
Description
According to the
Finder::name()
docblock, the following two calling conventions are equivalent:symfony/src/Symfony/Component/Finder/Finder.php
Lines 167 to 168 in bf8ecc4
However, this is demonstrably false for dot-files.
How to reproduce
Given the file
.foo.php
and$finder
is called withignoreDotFiles(false)
:$finder->name('*.php')
will not match.$finder->name('/\.php$/')
will match.This is because
*.php
is actually translated to the following regular expression:#^(?=[^\.])[^/]*\.php$#
. The assertion prevents the file starting with a dot (.
). (Aside: that assertion should probably have been written as(?!\.)
for clarity).It is unclear what is the intended behaviour here. By default, shells like Bash will not match dotfiles with a glob like this, although they can be set to match dot-files (with
shopt -s dotglob
). In any case, Finder's own documentation claims that the glob should match because the glob is equivalent to a suffix-only match, failing to mention that dot-files are implicitly excluded from such globs.Possible Solution
Either:
My view is that, from the perspective of Finder, the only correct solution can be to allow globs to match dot-files, because Finder has its own way of excluding dot-files (with
ignoreDotFiles()
). But then we are stuck with the problem that fixing the issue is a breaking change within Finder.The text was updated successfully, but these errors were encountered: