Bug #74784 [NEW]: get_class(NULL) return current class

From: Date: Mon, 19 Jun 2017 20:38:19 +0000
Subject: Bug #74784 [NEW]: get_class(NULL) return current class
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209594@lists.php.net to get a copy of this message
From: jonathanschweder at gmail dot com Operating system: Ubuntu 16.04.2 LTS PHP version: 7.0.20 Package: Class/Object related Bug Type: Bug Bug description:get_class(NULL) return current class Description: ------------ This is more a doubt that a bug, when I don't pass any param to the function get_class() or pass a variable that it value is NULL the function return the current Class where the script run's, is this behavior correct ? I ask because some time when I try to debug something and use the function get_class() I will pass some var and sometimes this var is NULL, turning my debug a bit confuse because any other scalar value that I pass this will throw an exception saying that the param is not an object. Sorry for any noob question and thanks for any feedback. Test script: --------------- <?php class Foo { public function bar() { echo get_class(); } } $foo = new Foo; $foo->bar();// Foo Expected result: ---------------- Throw exception saying that the param is not a object instance. Actual result: -------------- Return the name of the current class -- Edit bug report at https://bugs.php.net/bug.php?id=74784&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74784&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74784&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74784&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74784&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74784&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74784&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74784&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74784&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74784&r=support Expected behavior: https://bugs.php.net/fix.php?id=74784&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74784&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74784&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74784&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74784&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74784&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74784&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74784&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74784&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74784&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74784&r=mysqlcfg

« previous php.bugs (#209594) next »