Behavior of classes type hinting together with the error handler

From: Date: Fri, 13 Mar 2015 11:48:55 +0000
Subject: Behavior of classes type hinting together with the error handler
Groups: php.internals 
Request: Send a blank email to internals+get-84677@lists.php.net to get a copy of this message
Hello internals! My name is Andrew and I write php literally since childhood (something around 10 years), now PHP - is my profession. And today once again debugging foreign code, I was ready to go to the hospital to see a psychiatrist. First, some of the code: Do you think that can output this feature? function test(A $a) { var_dump(get_class($a)); } I always thought that only 'string (1) "A"', I have never been so wrong (c). The code below will display 'string (1) "B"' class A { } class B { public $id = 1; } set_error_handler(function () { return true; }); function test(A $a) { var_dump(get_class($a)); } test(new B()); I think this is very unexpected behavior, and suggest you to consider the possibility of removing this behavior in PHP7. Best regards. Andrew Kluev.

« previous php.internals (#84677) next »