On 25.09.2016 at 14:20, Dan Ackroyd wrote: > On 25 September 2016 at 06:29, Pierre Joye <pierre....@gmail.com> wrote: > >> I am pretty sure it is by design (for what I can remember) > > I do not believe that is correct. > > The commit message* says: "Restore PHP-5.2 behaviour when passing null > inside object scope to get_class()" > > The commit does not restore the previous behaviour.** I'm pretty > certain it was just a mistake.
Indeed, the commit message doesn't fit to the commit. However, that does not necessarily mean that the behavior was deliberately changed. See cataphract's explanation in <https://bugs.php.net/bug.php?id=52605>: | The convention is to give internal functions that have optional | arguments a default value and have them behave the same way when the | default value is given and when the argument's not passed at all. IMHO, that's how it should be. Behaving otherwise would contradict the Principle of least astonishment. Perhaps we better should have two functions, say get_current_class(void) and get_class_of(object $object), and deprecate get_class(). > As Leigh noted, the behaviour is not clearly documented. In fact the > manual also says: "If get_class() is called with anything other than > an object, an E_WARNING level error is raised.". I'm pretty sure that > null is not an object, so this RFC actually moves the behaviour closer > to what the manual says. … but would contradict the changlog entry for PHP 5.3.0. -- Christoph M. Becker -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php