3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait SomeTrait { public function __call($method, array $parameters) { // ... return is_callable(['parent', '__call']) ? parent::__call($method, $parameters) : null; } } class GreatParentClass { public function __call($method, array $parameters) { return 'bar'; } } class ParenClassWithoutCall { } class ProxyClass extends GreatParentClass { } class FooClass extends ProxyClass { use SomeTrait; } class BarClass extends GreatParentClass { use SomeTrait; } class BazClass extends ParenClassWithoutCall { use SomeTrait; } class SomeClassWithoutParent { use SomeTrait; } $class = new FooClass(); var_dump($class->foobar()); $class = new BarClass(); var_dump($class->foobar()); $class = new BazClass(); var_dump($class->foobar()); $class = new SomeClassWithoutParent(); var_dump($class->foobar());
Output for 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
Deprecated: Use of "parent" in callables is deprecated in /in/R8hI3 on line 8 string(3) "bar" Deprecated: Use of "parent" in callables is deprecated in /in/R8hI3 on line 8 string(3) "bar" Deprecated: Use of "parent" in callables is deprecated in /in/R8hI3 on line 8 NULL NULL
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31
string(3) "bar" string(3) "bar" NULL NULL

preferences:
78.94 ms | 409 KiB | 5 Q