Re: Re: PHP 8 is_file/is_dir input handling
| From: | Rowan Tommins | Date: | Thu, 03 Dec 2020 09:40:58 +0000 |
| Subject: | Re: Re: PHP 8 is_file/is_dir input handling | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112393@lists.php.net to get a copy of this message | ||
On 03/12/2020 06:52, Stanislav Malyshev wrote:
PHP functions always returned null on bad parameters, so it's not exactly unexpected.and On 02/12/2020 23:49, Christoph M. Becker wrote:
Just to reiterate, the former behavior was documented[1], and the return value was*undefined*. Instead of returning NULL, the erroneous function call could have returned anything, even TRUE. Relying on undefined behavior is bad.The note on https://www.php.net/manual/en/functions.internal.php says:
If the parameters given to a function are not what it expects...But the prototype on https://www.php.net/manual/en/function.is-file.php is:
is_file ( string $filename ) : boolAnd the description says only:
filename: Path to the file.While it's clear that passing e.g. an array falls into the scope of that general note, it doesn't say anywhere on that page that a string value which contains "\0" is "not what it expects", and I don't think I would ever have guessed that before reading this thread. So I stand by my assertion that this behaviour was both undocumented and unexpected. Regards, -- Rowan Tommins (né Collins) [IMSoP]