Esempio n. 1
0
function test_call_method_dataflow()
{
    $o = new B();
    $o->foo(1, 2);
    //SKIP: requires dataflow (simple here, but still)
    $o->foo();
}
Esempio n. 2
0
function test()
{
    $a = new A();
    echo $a->foo();
    $a = new B();
    echo $a->foo(555);
    echo $a->foo();
}
Esempio n. 3
0
File: 78.php Progetto: badlamer/hhvm
function bar()
{
    $obj = new A();
    $obj->foo(123);
    $obj = new B();
    $obj->foo(123, 456);
}
Esempio n. 4
0
File: 76.php Progetto: badlamer/hhvm
function bar()
{
    $obj = new A();
    $obj->foo();
    $obj = new B();
    $obj->foo();
}
Esempio n. 5
0
 public function foo2()
 {
     B::foo();
     // B always changes 'static'
     self::foo();
     // 'self' doesn't change 'static'
 }
Esempio n. 6
0
 public static function test()
 {
     $arr = array('foo');
     self::foo();
     parent::foo();
     self::$arr[0]();
     parent::$arr[0]();
     echo self::MYCONST . "\n";
     echo parent::MYCONST . "\n";
 }
Esempio n. 7
0
function main()
{
    $x = null;
    if (true) {
        $x = new A();
    } else {
        $x = new B();
    }
    //TODO: it should call both methods ...
    $x->foo();
    //var_dump($x);
}
Esempio n. 8
0
<?php

class A
{
}
class AA extends A
{
    function test()
    {
        print 'AA ok';
    }
}
class B
{
    function foo(A $obj)
    {
        $obj->test();
    }
}
$obj = new AA();
$b = new B();
$b->foo($obj);
Esempio n. 9
0
    {
        print "A::baz\n";
    }
    private function f()
    {
        echo "A::f\n";
    }
    public function g($a)
    {
        echo "A::g\n";
        $a->f();
    }
}
class B extends A
{
    protected function bar()
    {
        print "B::bar\n";
        $this->baz();
    }
    public function h($a)
    {
        print "B::g\n";
        $a->f();
    }
}
$a = new A();
$b = new B();
$b->foo();
$b->g($a);
#$b->h($a);
Esempio n. 10
0
function main()
{
    $b = new B();
    $b->foo();
}
Esempio n. 11
0
<?php

class A
{
    protected static $foo = 11;
    function foo()
    {
        var_dump(A::$foo);
    }
}
class B extends A
{
    public static $foo;
}
var_dump(B::$foo);
B::$foo = 123;
A::foo();
Esempio n. 12
0
<?php

// Make sure that we can tell which class was called for intercepted static
// methods
class A
{
    public function foo()
    {
        echo 'foo called';
    }
}
class B extends A
{
}
fb_intercept('A::foo', function ($_, $called_on) {
    var_dump($called_on);
});
A::foo();
B::foo();
// Trigger run_intercept_handler_for_invokefunc codepath
$class = 'B';
$c = 'call_user_fun';
$c .= 'c';
$c(array($class, 'foo'));
Esempio n. 13
0
<?php

// including scripts example
include "a.php";
require_once "b.php";
f(12345);
$a = new A("AAA");
$a->write();
$a->foo("hello");
$a->write();
$b = new B("BBB");
$b->write();
$b->foo("bye");
$b->write();
fgets(STDIN);
Esempio n. 14
0
<?php

class A
{
    function foo()
    {
        $f = static function () {
            return self::class;
        };
        return $f();
    }
}
class B extends A
{
}
$b = new B();
var_dump($b->foo());
Esempio n. 15
0
<?php

require "tests.php";
require "overload_return_type.php";
$b = new B();
check::equal($b->foo(1), 0, "");
check::classname("A", $b->foo("test"));
check::equal(overload_return_type::foo(), 1, "overload_return_type::foo() should be 1");
check::equal(overload_return_type::bar(), 1, "overload_return_type::bar() should be 1");
Esempio n. 16
0
<?php

class A
{
    public function foo(array $x)
    {
        return 1;
    }
}
class B extends A
{
    //override
    public function foo($x)
    {
        return 2;
    }
}
$o = new B();
$o->foo(4);
Esempio n. 17
0
 function foo()
 {
     $b = new B();
     $b->foo();
 }
Esempio n. 18
0
function test_method()
{
    $o = new B();
    $o->foo(1, 2);
}
Esempio n. 19
0
function main()
{
    return B::foo() + C::foo();
}
Esempio n. 20
0
<?php

class A
{
    public function foo()
    {
        echo "A::foo()\n";
    }
}
class B extends A
{
    public function __call($f, $args)
    {
        echo "B::__call({$f}, {$args})\n";
    }
}
$o = new B();
// this will call A::foo. The __call is used only when
// nothing was found in the whole hierarchy, not just
// when nothing was found in your class.
$o->foo();
// this will call B::__call
$o->bar();
Esempio n. 21
0
        $class = get_called_class();
        (yield $class);
    }
    public function foo()
    {
        return self::gen();
    }
}
class B extends A
{
}
function t($x)
{
    foreach ($x as $v) {
        var_dump($v);
    }
}
t(B::sgen());
t(B::sfoo());
t(A::sgen());
t(A::sfoo());
t(B::gen());
t(B::foo());
t(A::gen());
t(A::foo());
$b = new B();
t($b->gen());
t($b->foo());
$a = new A();
t($a->gen());
t($a->foo());
Esempio n. 22
0
function main()
{
    $b = new B();
    $b->foo();
    var_dump($b);
}
Esempio n. 23
0
 public function doFoo()
 {
     $this->foo();
     // G G G
     B::foo();
     // B B    (Zend: B G G) (Rule 1)
     C::foo();
     // C C    (Zend: C G G) (Rule 1)
     D::foo();
     // D D    (Zend: D G G) (Rule 1)
     F::foo();
     // F G G
     G::foo();
     // G G G
     H::foo();
     // H H    (Zend: H G G) (Rule 1)
     parent::foo();
     // F G G
     self::foo();
     // G G G
     static::foo();
     // G G G
     echo "****************\n";
 }
Esempio n. 24
0
<?php

class A
{
    function test()
    {
        print 'A';
    }
    function foo()
    {
        $this->test();
    }
}
class B extends A
{
    function test()
    {
        print 'B';
    }
}
$obj = new A();
$obj = new B();
$obj->foo();
}
?>
--FILE--
<?php 
class A
{
    function foo($arg1 = 1)
    {
    }
}
class B extends A
{
    function foo($arg1 = 2, $arg2 = 3)
    {
        var_dump($arg1);
        var_dump($arg2);
    }
}
class C extends A
{
    function foo()
    {
    }
}
$b = new B();
$b->foo(1);
// TODO: Strict Standards: Declaration of C::foo() should be compatible with A::foo($arg1 = 1) in %s on line %d
?>
--EXPECTF--
int(1)
int(3)
Esempio n. 26
0
[expect exact] ahoj

[file]
<?php 
include "b.inc";
class C extends B
{
}
$x = new B();
$x->x = "ahoj";
$x->foo();
Esempio n. 27
0
<?php

class A
{
    static function foo()
    {
        $f = static function () {
            return static::class;
        };
        return $f();
    }
}
class B extends A
{
}
var_dump(B::foo());