function test() { $x = new X(); $y = new Y(); $x->f(); $y->f(); }
function test() { $x = new X(); $c = $x->f(); var_dump($c(true)); $y = new Y(); $c = $y->f(); var_dump($c("foo")); }
*/ ext_func(); new ExtClass(); class L implements ExtInterface { } function f() { } function () { // Anonymous function. }; g(); $g(); ${$g}(); X::f(); call_user_func(); call_user_func('h'); call_user_func($var); class A { } class C extends B { } class D extends C { } new U(); V::m(); W::$n;
[expect] 1 [file] <?php if ($a == $b) { class X { static function f($a) { echo 1; } } } X::f(1);
<?php const X = 1; class X { function f() { if (isset(X[$a])) { } if (isset(Y::X[$b])) { } if (isset(Y::$x[$b])) { } } } $x = new X(); $x->f();
<?php class X { static function f($o) { $s = 'self'; return $o instanceof $s; } } var_dump(X::f(new X()));
<?php function f($x) { (yield $x); } $c = f(32); var_dump($c->getOrigFuncName()); var_dump($c->getCalledClass()); trait T { function f($x) { (yield get_called_class()); } } class X { use T; } $x = new X(); $c = $x->f(32); var_dump($c->getOrigFuncName()); var_dump($c->getCalledClass()); $fcn = function ($x) { (yield $x); }; $c = $fcn(32); var_dump($c->getOrigFuncName()); var_dump($c->getCalledClass());
<?php function fcn() { return true; } class X { function f($x) { goto over_switch; switch ($this) { case fcn(): echo 'fcn'; default: echo 'fun'; } over_switch: var_dump($x); } } $x = new X(); $x->f(42);
<?php class X { static function f($o, $s) { return $o instanceof $s; } } $x = new X(); var_dump(X::f($x, 'self')); var_dump(X::f($x, 'X'));
<?php class X { function f($x) { var_dump(${$x}); } } $x = new X(); $x->f("this");