-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Filesystem] added exists method #4586
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
Shouldn't it be better to stop on the first failure? as all the others files will be false automatically. |
indeed. We should avoid unnecessary filesystem IO by returning false as soon as it is known |
Indeed it's better this way. fixed! |
public function exists($files) | ||
{ | ||
foreach ($this->toIterator($files) as $file) { | ||
if (false === file_exists($file)) { |
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.
it should be if (!file_exists($file))
to follow the Symfony CS. We use the strict comparison with false
only for cases where it is necessary (such as strpos
which can return 0
with the opposite meaning)
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.
fixed. Thanks for the feedback
Commits ------- 38cad9d [Filesystem] added exists method Discussion ---------- [Filesystem] added exists method Bug fix: no Feature addition: yes Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: Todo: License of the code: MIT Documentation PR: --------------------------------------------------------------------------- by travisbot at 2012-06-15T16:29:20Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1629204) (merged ebd1a4c6 into f881d28). --------------------------------------------------------------------------- by sstok at 2012-06-16T09:05:48Z Shouldn't it be better to stop on the first failure? as all the others files will be false automatically. --------------------------------------------------------------------------- by stof at 2012-06-16T10:21:49Z indeed. We should avoid unnecessary filesystem IO by returning false as soon as it is known --------------------------------------------------------------------------- by aerialls at 2012-06-16T11:55:24Z Indeed it's better this way. fixed! --------------------------------------------------------------------------- by travisbot at 2012-06-16T12:01:16Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1634615) (merged 8d98f417 into 76b2ed4).
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets:
Todo:
License of the code: MIT
Documentation PR: