RE: [PHP-DEV] Coercive STH - some real world tests and updated RFC
| From: | François Laupretre | Date: | Sat, 28 Feb 2015 08:24:24 +0000 |
| Subject: | RE: [PHP-DEV] Coercive STH - some real world tests and updated RFC | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84073@lists.php.net to get a copy of this message | ||
> De : Damien Tournoud [mailto:damz@damz.org]
>
> All those are due to a bug in substr(), that we see now only thanks to
> proper type identification. There is no reason for substr() to ever return
> a boolean. It really needs to be fix to always return a string.
Sorry, not a bug. Documentation is clear. You get 'string|false' from substr() and send it
to a function expecting 'string'. Most languages will fail on this. It worked in PHP
because of implicit casting from bool to string. We just decided to deprecate this implicit cast.
Now, we can discuss about substr(), whether it should always return string or not. But that's
another subject.
Regards
François