-
Notifications
You must be signed in to change notification settings - Fork 235
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
#186 check if file exists before asking for mtime #436
#186 check if file exists before asking for mtime #436
Conversation
|
||
private static function getFileMtime(string $fileName): int | ||
{ | ||
return file_exists($fileName) && is_file($fileName) ? filemtime($fileName) : 0; |
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.
Why do we need to call both file_exists
and is_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.
return file_exists($fileName) ? filemtime($fileName) : 0;
should do the trick too, shouldn't it?
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 edge case that is_file
checks for here is if $fileName
is a directory. I guess it makes sense to return 0 in this case, but I don't know if :
- It's the focus of this PR
getFileMtime()
can get called with a directory name at all
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.
Isn't file_exists
redundant if we have is_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.
|
||
private static function getFileMtime(string $fileName): int | ||
{ | ||
return file_exists($fileName) && is_file($fileName) ? filemtime($fileName) : 0; |
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.
return file_exists($fileName) ? filemtime($fileName) : 0;
should do the trick too, shouldn't it?
doctrine/annotations
handles reading annotations from eval’ed code (as in mock objects) just fine, except that it attempts to determine the modification time viaReflectionClass::getFile()
which will return the file and line where theeval()
happened. This change adds fix and test for thePsrCachedReader
and also fixesCachedReader
but without a tests since it’s deprecated.Fixes #186