Re: Re: [RFC] get_class() disallow null parameter

From: Date: Mon, 15 Aug 2016 10:38:17 +0000
Subject: Re: Re: [RFC] get_class() disallow null parameter
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-95181@lists.php.net to get a copy of this message
On 15.08.2016 at 02:09, Stanislav Malyshev wrote: >> 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). > > I note that this (i.e. behavior proposed in the RFC) was briefly the > case for 5.3.0 and was changed to current behavior for 5.3.1. But > pre-5.3 versions return false when NULL is passed to get_class, with no > message. > > So, old PHP code doesn't seem to be a problem only one that was written > after 5.3.1, because it doesn't look like get_class(NULL) worked before > it: https://3v4l.org/4QvCs Thanks for pointing this out. Interestingly, indicated by a changelog entry in the get_class() manual, the behavior is somewhat different when no argument is passed, see <https://3v4l.org/sWX9X>. That works as least as of PHP 5.2.0; not sure why 5.0 and 5.1 fail here. As the proposed behavior had been introduced with 5.3.0 and reverted shortly after, indicates that we should be careful here. Deprecating for 7.2 and removing with 8.0 seems to be the safer way. -- Christoph M. Becker

« previous php.internals (#95181) next »