Ejemplo n.º 1
0
 public static function testNoForward()
 {
     A::test();
     call_user_func("A::test");
     call_user_func(array("A", "test"));
     B::test();
     call_user_func("B::test");
     call_user_func(array("B", "test"));
 }
Ejemplo n.º 2
0
function main()
{
    call_user_func(array('A', 'private_func'), "1", "2", "3");
    call_user_func(array('A', 'protected_func'), "1", "2", "3");
    call_user_func(array('A', 'public_func'), "1", "2", "3");
    call_user_func(array('B', 'private_func'), "1", "2", "3");
    call_user_func(array('B', 'protected_func'), "1", "2", "3");
    call_user_func(array('B', 'public_func'), "1", "2", "3");
    A::test();
    B::test();
}
Ejemplo n.º 3
0
 public static function mycatch()
 {
     try {
         static::who();
         B::throwException_after();
     } catch (Exception $e) {
         static::who();
         A::test();
         static::who();
         B::test();
         static::who();
         self::simpleCatch();
         static::who();
     }
 }
Ejemplo n.º 4
0
function useObject(A $obj)
{
    $obj->test();
}
Ejemplo n.º 5
0
<?php

class A
{
    function test($arg1, $arg2, $arg3 = 0)
    {
    }
}
$a = new A();
$a->test(1);
Ejemplo n.º 6
0
<?php

trait TestTrait
{
    public static function test()
    {
        return 'Test';
    }
}
class A
{
    use TestTrait;
}
echo A::test();
Ejemplo n.º 7
0
<?php

final class A
{
    //final public $name = 'ss'; //Fatal error: Cannot declare property A::$name final, the final modifier is allowed only for methods and classes
    public function test()
    {
        ///$this->name = 'overrided name';
        return 'dd';
    }
}
$a = new A();
echo $a->test();
Ejemplo n.º 8
0
<?php

class A
{
    public $a = 1;
    public static $A = 2;
    private $b = 3;
    private static $B = 4;
    protected $c = 5;
    protected static $C = 6;
    public function __construct()
    {
        var_dump(get_class_vars('A'));
    }
    public static function test()
    {
        var_dump(get_class_vars('A'));
    }
}
var_dump(get_class_vars('A'));
new A();
var_dump(A::test());
Ejemplo n.º 9
0
<?php

interface I
{
    public function test($a);
}
class A
{
    public function test($a)
    {
        print 'A';
    }
}
class B extends A implements I
{
    public function test($a)
    {
        print 'B';
    }
}
$obj = new A();
$obj->test(1);
$obj = new B();
$obj->test(1);
Ejemplo n.º 10
0
<?php

interface I
{
    public function test($a);
}
class A implements I
{
    public function test($a)
    {
        print $a;
    }
}
$obj = new A();
var_dump($obj instanceof I);
$obj->test('cool');
Ejemplo n.º 11
0
<?php

class A
{
    function __call($a, $b)
    {
        $b = 'a';
        $b = 1;
        var_dump($a, $b[0], $b[1]);
    }
}
$obj = new A();
$a = 1;
$b = 'a';
$b = 2;
$obj->test($a, $b);
Ejemplo n.º 12
0
<?php

class A
{
    const T = 'test';
    public function test()
    {
        return self::T;
    }
}
$f = new A();
echo $f->test();
Ejemplo n.º 13
0
<?php

class A
{
    public static function test($x = null)
    {
        if (!is_null($x)) {
            echo "{$x}\n";
        }
        return get_called_class();
    }
}
class B extends A
{
}
class C extends A
{
}
class D extends A
{
}
echo A::test(B::test(C::test(D::test()))) . "\n";
?>
==DONE==
Ejemplo n.º 14
0
        var_dump(get_object_vars($b));
    }
}
class C extends B
{
    private $hiddenPriv = 'C::hiddenPriv';
    public static function test($b)
    {
        echo __METHOD__ . "\n";
        var_dump(get_object_vars($b));
    }
}
class X
{
    public static function test($b)
    {
        echo __METHOD__ . "\n";
        var_dump(get_object_vars($b));
    }
}
$b = new B();
echo "\n---( Global scope: )---\n";
var_dump(get_object_vars($b));
echo "\n---( Declaring class: )---\n";
B::test($b);
echo "\n---( Subclass: )---\n";
C::test($b);
echo "\n---( Superclass: )---\n";
A::test($b);
echo "\n---( Unrelated class: )---\n";
X::test($b);
Ejemplo n.º 15
0
Archivo: 18.php Proyecto: badlamer/hhvm
<?php

class A
{
    public function test($a)
    {
        var_dump(func_num_args());
        var_dump(func_get_args());
    }
}
$obj = new A();
$obj->test('test');
$obj->test(1, 2, 3);
Ejemplo n.º 16
0
<?php

class A
{
    public $prop = [1, 2, 3];
    function test(string $arg)
    {
        return $arg;
    }
}
$var = new A();
$var->test($var->prop);
Ejemplo n.º 17
0
<?php

class A
{
    function _test()
    {
        print 'ok';
    }
    function __call($name, $args)
    {
        $name = '_' . $name;
        $this->{$name}();
    }
}
$obj = new A();
$obj->test();
Ejemplo n.º 18
0
<?php

class A
{
    const myConst = "const in A";
    const myDynConst = self::myConst;
    public static function test()
    {
        var_dump(self::myDynConst);
    }
}
class B extends A
{
    const myConst = "const in B";
    public static function test()
    {
        var_dump(parent::myDynConst);
    }
}
A::test();
B::test();
}
EventLoop::$instance = new EventLoop();
class A
{
    protected $ev;
    public function __construct(EventLoop $ev)
    {
        $this->ev = $ev;
    }
    public function test()
    {
        return $this->ev;
    }
}
class B
{
    public function test()
    {
        return EventLoop::$instance;
    }
}
$aInstance = new A(new EventLoop());
$benchmark->add('without-static-normal-injection', function () use($aInstance) {
    return $aInstance->test();
});
$bInstance = new B();
$benchmark->add('with-static-global-state', function () use($bInstance) {
    return $bInstance->test();
});
$benchmark->setCount(10000000);
$benchmark->run();
Ejemplo n.º 20
0
 function foo(A $obj)
 {
     $obj->test();
 }
<?php

function &a($i)
{
    $a = "str" . $i . "ing";
    return $a;
}
class A
{
    public function test()
    {
        $this->a = a(1);
        unset($this->a);
    }
}
$a = new A();
$a->test();
$a->test();
echo "okey";
Ejemplo n.º 22
0
<?php

class A
{
    function __call($a, $b)
    {
        var_dump($a, $b[0], $b[1]);
    }
}
$obj = new A();
$a = 1;
$obj->test($a, 'ss');