Closed edannenberg closed 4 years ago
This is definitely a change in behavior; we have tests that verify that the validator returns false
when the file does not exist (which you can see in the test results).
That said, looking through the code, you are absolutely correct - the validators are not testing any of the file contents, just the file name.
For BC purposes, this needs to be opt-in behavior, with the current behavior being the default. We can revisit that when we consider a new major version.
I'll push a change shortly to enable this.
I've pushed a change to make this optional behavior, and added documentation on how to enable the option.
Currently the validator fails if the given filename is not readable. This prevents valid use cases like checking if a user configurable filename has an allowed file extension before creating said file.
As the validator only operates on the given string there is no need for the current readable check.
Also fixes File\ExcludeExtension which suffers from the same issue.
In theory it's a BC breaking change, personally I would consider any code that (ab)uses this validator as a file_is_readable validator to be smelly/buggy.