Bug #74784 [Opn->Nab]: get_class(NULL) return current class
Edit report at https://bugs.php.net/bug.php?id=74784&edit=1
ID: 74784
Updated by: peehaa@php.net
Reported by: jonathanschweder at gmail dot com
Summary: get_class(NULL) return current class
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: Ubuntu 16.04.2 LTS
PHP Version: 7.0.20
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2017-06-19 20:38:16] jonathanschweder at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=74784&edit=1
Thread (2 messages)