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