-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.2][Finder] ->pathContains(), ->pathNotContains() methods (with basic tests) #4739
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
Conversation
if ($this->isRegex($str)) { | ||
return $str; | ||
} | ||
return '/' . str_replace('/', '\/', $str) . '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use preg_quote
to escape the string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* | ||
* @api | ||
*/ | ||
public function pathContains($pattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just path()
and notPath()
for the method names? contains
is used to check the file content, so it seems wrong to reuse the word here. And path()
is more consistent with name()
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabpot: Done.
Can you submit a PR on symfony/symfony-docs to update the documentation and reference it here before I merge? Thanks. |
I've already done it in PR1527. |
Actually, to be BC in PHPUnit when switching to Finder (this feature is the reason why the switch was reverted in 3.7), they will need the support of the glob syntax. Should it be supported directly in the Finder or should we consider that PHPUnit will have to put the code converting globs to regexes themselves before calling the finder ? |
@stof what about supporting globs/patterns for the |
yeah, this could be a good idea too |
Supporting globs in |
@gajdaw can you update this PR with the glob support and rebase it ? |
* @see Symfony\Component\Finder\Iterator\FilenameFilterIterator | ||
* | ||
* @api | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @api tags must be removed.
With pleasure! @gajdaw let me know if I can do anything. |
I have moved This implementation passes all the tests on Windows, but Travis reports failures. I think that similar methods should be implemented for @jfsimon What do you think? |
@gajdaw Travis says class 'Symfony\Component\HttpKernel\Exception\InternalServerErrorHttpException' not found in /home/travis/builds/symfony/symfony/src/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php on line 83. This is weird. And yes, |
I've just fixed the unit tests |
@jfsimon Can implement |
@gajdaw okay. |
@gajdaw work complete! I cant make a PR on your repos :-/ Could you merge my repos https://github.com/jfsimon/symfony/tree/component_finder_path_notPath please? Or maybe could I post a new PR on symfony/master. |
@jfsimon I have pulled your changes. I don't know wheather you should post a new PR. |
This PR was merged into the master branch. Commits ------- 4e21bf2 [Finder] Added path & notPath support to gnu find adapter. 6258d12 [Finder] Fixed expression classes. 5c6dbeb [Finder] Fixed tests. c36dfc1 [Component][Finder] ->path(), ->notPath() methods (with basic tests) Discussion ---------- [2.2][Finder] ->pathContains(), ->pathNotContains() methods (with basic tests) Bug fix: no Feature addition: yes Backwards compatibility break: no Symfony2 tests pass: [](http://travis-ci.org/gajdaw/symfony) Fixes the following tickets: #4581 Todo: - License of the code: MIT Documentation PR: - Two additional methods: `Finder->path()` and `Finder->notPath()`. They allow filtering with paths, e.g. `->path('some/special/dir')`. --------------------------------------------------------------------------- by fabpot at 2012-09-21T05:52:01Z Can you submit a PR on symfony/symfony-docs to update the documentation and reference it here before I merge? Thanks. --------------------------------------------------------------------------- by gajdaw at 2012-09-21T10:54:50Z I've already done it in PR1527. symfony/symfony-docs#1527 --------------------------------------------------------------------------- by stof at 2012-09-21T22:15:46Z Actually, to be BC in PHPUnit when switching to Finder (this feature is the reason why the switch was reverted in 3.7), they will need the support of the glob syntax. Should it be supported directly in the Finder or should we consider that PHPUnit will have to put the code converting globs to regexes themselves before calling the finder ? --------------------------------------------------------------------------- by fabpot at 2012-09-23T13:15:08Z @stof what about supporting globs/patterns for the `in()` method? --------------------------------------------------------------------------- by stof at 2012-09-23T13:38:00Z yeah, this could be a good idea too --------------------------------------------------------------------------- by gajdaw at 2012-09-26T06:11:56Z Supporting globs in `path(), notPath()` methods is trivial: we have `Glob::toRegex()`. The only thing to do is to convert (when necessary) parameter sent to `path(), notPath()`. --------------------------------------------------------------------------- by stof at 2012-10-13T17:19:08Z @gajdaw can you update this PR with the glob support and rebase it ? --------------------------------------------------------------------------- by fabpot at 2012-10-29T11:20:55Z @gajdaw You also need to rebase and update the new adapters accordingly. Maybe @jfsimon can help. --------------------------------------------------------------------------- by jfsimon at 2012-10-29T16:22:25Z With pleasure! @gajdaw let me know if I can do anything. --------------------------------------------------------------------------- by gajdaw at 2012-10-29T16:48:10Z I have moved `->path()` and `->notPath()` methods to `PhpAdapter`. This implementation passes all the tests on Windows, but Travis reports failures. I think that similar methods should be implemented for `GnuFindAdapter`. @jfsimon What do you think? --------------------------------------------------------------------------- by jfsimon at 2012-10-29T17:03:36Z @gajdaw Travis says class 'Symfony\Component\HttpKernel\Exception\InternalServerErrorHttpException' not found in /home/travis/builds/symfony/symfony/src/Symfony/Component/HttpKernel/Tests/Exception/FlattenExceptionTest.php on line 83. This is weird. And yes, `AdapterInterface` and `GnuFindAdapter` should be updated too. I can work on it if you like. --------------------------------------------------------------------------- by fabpot at 2012-10-29T17:07:46Z I've just fixed the unit tests --------------------------------------------------------------------------- by gajdaw at 2012-10-29T17:25:43Z @jfsimon Can implement `path(), notPath()` for `GnuFindAdapter`? I have no time to analyse Gnu's `find` command at the moment. Thanks! --------------------------------------------------------------------------- by jfsimon at 2012-10-29T17:30:13Z @gajdaw okay. --------------------------------------------------------------------------- by jfsimon at 2012-10-29T19:05:26Z @gajdaw work complete! I cant make a PR on your repos :-/ Could you merge my repos https://github.com/jfsimon/symfony/tree/component_finder_path_notPath please? Or maybe could I post a new PR on symfony/master. --------------------------------------------------------------------------- by gajdaw at 2012-10-30T05:34:17Z @jfsimon I have pulled your changes. I don't know wheather you should post a new PR.
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass:
Fixes the following tickets: #4581
Todo: -
License of the code: MIT
Documentation PR: -
Two additional methods:
Finder->path()
andFinder->notPath()
.They allow filtering with paths, e.g.
->path('some/special/dir')
.