Hi!
In PHP 7, this returns FALSE:
php -r 'var_dump(is_file("ab\0c"));'
In PHP 8, the same code throws a ValueException. Problem is now that
I think this is a mistake. Exceptions should not be thrown on such
values, it only breeds boilerplate code (now you'd have to wrap each
call to is_* into try/catch or add another pre-call validator just to
ensure it doesn't throw). PHP type system is not robust enough to
support fine-grained types like "string that has certain format", and
pretending we do have this as a type and throwing typing error on it
only makes the consumer work harder for no additional gain. In almost
every situation I can imagine, string that is not the name of the file
is equivalent to string that is not the name of the file and also has \0
in it. However, this setup forces me to treat them differently and add
additional validation step to it. While to some functions it may be a
useful functionality - specifically to constructor functions expected to
return an object, so they can't really tell "you gave me invalid data"
other than throwing - for something like is_file it will only be annoying.
--
Stas Malyshev
smalys...@gmail.com
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php