On 14.08.2016 at 13:00, Dan Ackroyd wrote:

> Following an earlier discussion in January, here is a small RFC to
> change get_class() to disallow null being passed as parameter.
> 
> https://wiki.php.net/rfc/get_class_disallow_null_parameter
> 
> Allowing null to be passed to get_class() is a 'gotcha' that is almost
> always a mistake in someone's code.
> 
> By preventing null being passed, get_class() will be far more likely
> to do what people think it should do, and so result in fewer bugs in
> code.
> 
> This RFC is a small change and so is appropriate for a point release.
> Other ways of making this function behave as people expect it to are
> not as small changes, and are probably not appropriate for point
> releases.

Prohibiting `get_class(NULL)` is certainly a good idea, but I have some
concerns regarding BC.  While `__CLASS__` has been introduced with PHP
4.3.0, it had the glitch to return the lower-cased class name before PHP
5.0.0.  So there *might* still be PHP 5 code around using `get_class(NULL)`.

The deprecation might be more appropriate, and could equally well catch
an inadvertent `get_class(NULL)`.

-- 
Christoph M. Becker


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to