Пример #1
0
function test()
{
    $x = new X();
    $y = new Y();
    $x->f();
    $y->f();
}
Пример #2
0
function test()
{
    $x = new X();
    $c = $x->f();
    var_dump($c(true));
    $y = new Y();
    $c = $y->f();
    var_dump($c("foo"));
}
Пример #3
0
 */
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;
Пример #4
0
[expect] 1

[file]
<?php 
if ($a == $b) {
    class X
    {
        static function f($a)
        {
            echo 1;
        }
    }
}
X::f(1);
Пример #5
0
<?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();
Пример #6
0
<?php

class X
{
    static function f($o)
    {
        $s = 'self';
        return $o instanceof $s;
    }
}
var_dump(X::f(new X()));
Пример #7
0
<?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());
Пример #8
0
<?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);
Пример #9
0
<?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'));
Пример #10
0
<?php

class X
{
    function f($x)
    {
        var_dump(${$x});
    }
}
$x = new X();
$x->f("this");