<?php
function f ($name, $vars) {
var_dump($vars);
return $name;
}
trait A { function bar() { var_dump(get_class(), get_class(null), get_class(self), get_class(${f('this', array_merge(get_defined_vars(), array()))})); } } class B { use A; } $f = new B; $f->bar();
Deprecated: Calling get_class() without arguments is deprecated in /in/25QP5 on line 6
Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, null given in /in/25QP5:6
Stack trace:
#0 /in/25QP5(6): B->bar()
#1 {main}
thrown in /in/25QP5 on line 6
Process exited with code 255.
Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, null given in /in/25QP5:6
Stack trace:
#0 /in/25QP5(6): B->bar()
#1 {main}
thrown in /in/25QP5 on line 6
Process exited with code 255.
Warning: get_class() expects parameter 1 to be object, null given in /in/25QP5 on line 6
Warning: Use of undefined constant self - assumed 'self' (this will throw an Error in a future version of PHP) in /in/25QP5 on line 6
Warning: get_class() expects parameter 1 to be object, string given in /in/25QP5 on line 6
array(0) {
}
string(1) "B"
bool(false)
bool(false)
string(1) "B"
Output for 7.1.0 - 7.1.33
Notice: Use of undefined constant self - assumed 'self' in /in/25QP5 on line 6
Warning: get_class() expects parameter 1 to be object, string given in /in/25QP5 on line 6
array(0) {
}
string(1) "B"
string(1) "B"
bool(false)
string(1) "B"
Output for 7.0.0 - 7.0.20
Notice: Use of undefined constant self - assumed 'self' in /in/25QP5 on line 6
Warning: get_class() expects parameter 1 to be object, string given in /in/25QP5 on line 6
array(1) {
["this"]=>
object(B)#1 (0) {
}
}
string(1) "B"
string(1) "B"
bool(false)
string(1) "B"
Notice: Use of undefined constant self - assumed 'self' in /in/25QP5 on line 6
Warning: get_class() expects parameter 1 to be object, string given in /in/25QP5 on line 6
array(0) {
}
Notice: Undefined variable: this in /in/25QP5 on line 6
string(1) "B"
string(1) "B"
bool(false)
string(1) "B"