示例#1
0
文件: call11.php 项目: badlamer/hhvm
 public static function test()
 {
     // FPushClsMethodD
     C::foo("a", "b", "c", "d");
     // FPushClsMethod
     $cls = 'C';
     $cls::foo("a", "b", "c", "d");
     $fn = 'foo';
     C::$fn("a", "b", "c", "d");
     $fn = 'foo';
     $cls::$fn("a", "b", "c", "d");
     // FPushClsMethodF
     self::foo("a", "b", "c", "d");
 }
示例#2
0
function main()
{
    $c = new C();
    $d = new D();
    $c->foo();
    $d->foo();
    echo "**************\n";
    $c->bar();
    $d->bar();
    echo "**************\n";
    C::foo();
    D::bar();
    echo "**************\n";
    $d->yar();
    D::yar();
}
示例#3
0
<?php

class C
{
    function foo()
    {
        if ($this) {
            return true;
        } else {
            return false;
        }
    }
}
var_dump(C::foo());
示例#4
0
 public static function callByParent()
 {
     parent::foo();
 }
示例#5
0
<?php

// Copyright 2004-2015 Facebook. All Rights Reserved.
echo "Starting\n";
class C
{
    public function foo()
    {
        echo "foo\n";
        $x = array();
        if ($x) {
            print_r($x);
        } else {
            print_r($x);
        }
    }
}
$c = new C();
$val = $c->foo();
echo $val;
echo "\n";
echo "Done\n";
示例#6
0
文件: 1960.php 项目: badlamer/hhvm
<?php

trait T
{
    function foo()
    {
        echo "Foo";
        $this->bar();
    }
    abstract function bar();
}
class C
{
    use T;
    function bar()
    {
        echo "BAR!\n";
    }
}
$x = new C();
$x->foo();
示例#7
0
{
    function foo($x, $y = 0);
}
interface J
{
    function foo($x, $y);
}
interface K
{
    function foo($x, $y = 0, array $z);
}
interface L
{
    function foo($x, $y, array $z = null);
}
interface M
{
    function foo($x, $y = 0, array $z = array());
}
class C implements I, J, K, L, M
{
    public function foo($x, $y = 0, array $z = null, array $a = null)
    {
        echo "{$x} {$y} {$z}\n";
    }
}
$obj = new C();
$obj->foo(1);
$obj->foo(1, 2);
$obj->foo(1, 2, null);
$obj->foo(1, 2, array());
示例#8
0
文件: 680.php 项目: badlamer/hhvm
<?php

class A
{
    public $a = null;
}
class B extends A
{
    public function foo()
    {
        var_dump($this->a);
    }
}
class C extends B
{
    public $a = 'test';
}
$obj = new C();
$obj->foo();
<?php

// Method invocation on $this
class C
{
    function foo($x, $y)
    {
        echo "C::foo({$x}, {$y})\n";
        $this->bar($y, $x);
    }
    function bar($x, $y)
    {
        echo "C::bar({$x}, {$y})\n";
    }
}
$c = new C();
$c->foo(1, 2);
示例#10
0
文件: cuf.php 项目: n3b/hiphop-php
 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";
 }
示例#11
0
  <?php 
abstract class A
{
    public abstract function foo(int $x);
}
interface I
{
    function foo(int $x);
}
abstract class B extends A implements I
{
}
class C extends B
{
    public function foo(array $x = null)
    {
    }
}
$c = new C();
$c->foo(null);
echo "OK\n";
示例#12
0
 function bar()
 {
     C::foo();
 }
示例#13
0
function main()
{
    return B::foo() + C::foo();
}
示例#14
0
<?php

class C
{
    public $y = 5;
    function foo($x)
    {
        return $x + $this->y;
    }
}
$o = new C();
echo $o->foo(3) . "\n";
示例#15
0
<?php

class C
{
    /**
     * @param string
     * @param array
     */
    public function __call($method, $args)
    {
    }
}
$c = new C();
$c->foo('asdf');
示例#16
0
    }
    public function foo($x)
    {
        $bar = function ($y) use($x) {
            return $this->stuff($x, $y);
        };
        return $bar(33);
    }
    public function bar($x)
    {
        $zeta = new_model($x);
        return function ($y) use($zeta) {
            return $this->stuff($y, $zeta);
        };
    }
}
function lam($b)
{
    $fn = function ($a) use($b) {
        return $a + $b;
    };
    $gn = function ($a) use($b) {
        $c = $b * 20;
        return $a + $b;
    };
    return $fn(10) + $gn(10);
}
var_dump(lam(42));
$c = new C();
var_dump($c->foo(20));
示例#17
0
function bar()
{
    $obj = new C();
    $obj->foo(123);
}
示例#18
0
文件: ternary.php 项目: badlamer/hhvm
<?php

class C
{
    public function foo($x, $str)
    {
        $y = $str ?: "Water";
        return $y . ": " . ($x < 100 ? ($x < 30 ? "cold" : "warm") . " water" : ($x > 200 ? "OMG" : "steam"));
    }
}
$c = new C();
echo $c->foo(17, "") . "\n";
示例#19
0
<?php

print "Test begin\n";
interface I
{
    public static function foo();
}
class C implements I
{
    public static function foo($x)
    {
        echo 'Hello ' . $x . "\n";
    }
}
C::foo("5");
print "Test end\n";
示例#20
0
<?php

print "Test begin\n";
interface I
{
    public function foo($x, $y);
}
class C implements I
{
    public function foo($x)
    {
        echo 'Hello ' . $x . "\n";
    }
}
$o = new C();
$o->foo("5");
print "Test end\n";
示例#21
0
文件: 2108.php 项目: badlamer/hhvm
<?php

trait T
{
    public abstract function foo($x);
}
interface I
{
    public function foo($x);
}
abstract class B implements I
{
    use T;
}
class C extends B
{
    public function foo($x)
    {
        echo "{$x} \n";
    }
}
$obj = new C();
$obj->foo(1);
示例#22
0
function foo()
{
    $k = new C();
    $k->foo();
}
示例#23
0
文件: 2056.php 项目: badlamer/hhvm
<?php

trait T
{
    public abstract function bar();
    public function foo()
    {
        $this->bar();
    }
}
class B
{
    public function bar()
    {
        echo "I'm bar\n";
    }
}
class C extends B
{
    use T;
}
$o = new C();
$o->foo();
示例#24
0
文件: 2121.php 项目: badlamer/hhvm
<?php

trait T1
{
    abstract function foo();
}
trait T2
{
    abstract function foo();
}
abstract class B
{
    use T1, T2;
}
class C extends B
{
    function foo()
    {
        return "hello\n";
    }
}
$o = new C();
echo $o->foo();
示例#25
0
文件: method3.php 项目: badlamer/hhvm
<?php

abstract class A
{
    protected abstract function foo();
}
class B extends A
{
    protected function foo()
    {
        echo "B::foo\n";
    }
}
class C extends A
{
    function foo()
    {
        $b = new B();
        $b->foo();
    }
}
$c = new C();
$c->foo();
示例#26
0
<?php

class C
{
    var $x;
    function __construct($x)
    {
        $this->x = $x;
    }
    function foo($that)
    {
        var_dump($this->x);
        $this = $that;
        var_dump($this->x);
    }
}
$c1 = new C(1);
$c2 = new C(2);
$c1->foo($c2);
<?php

abstract class C
{
    static abstract function foo();
}
function foo(callable $x)
{
}
try {
    C::foo();
} catch (Error $e) {
    echo "\nException: " . $e->getMessage() . " in ", $e->getFile() . " on line " . $e->getLine() . "\n";
}
try {
    foo("C::foo");
} catch (Error $e) {
    echo "\n";
    do {
        echo "Exception: " . $e->getMessage() . "\n";
        $e = $e->getPrevious();
    } while ($e instanceof Error);
}
C::foo();
示例#28
0
  <?php 
abstract class A
{
    public abstract function foo(int $x);
}
class B extends A
{
    public function foo(int $x)
    {
    }
}
class C extends B
{
    public function foo(array $x)
    {
    }
}
$o = new C();
$o->foo(array());
echo "OK\n";
示例#29
0
{
    echo $str . "\n";
}
class Bar
{
    public function bar()
    {
        return "zing";
    }
    public function baz($other)
    {
        echo $this === $other ? "me\n" : "not me\n";
    }
    public function garply($n, $s, $b)
    {
        echo \hacklib_cast_as_boolean($b) ? $s : $n;
        echo "\n";
    }
}
class C
{
    public function foo($x)
    {
        other_func("and now: " . \hacklib_nullsafe($x)->bar());
        \hacklib_nullsafe($x)->baz($x);
        \hacklib_nullsafe($x)->garply(1, "hi", true);
    }
}
$c = new C();
$c->foo(new Bar());
$c->foo(null);
示例#30
0
<?php

class C
{
    public static function foo()
    {
        return "world\n";
    }
    public static $foo = "hello";
}
echo C::$foo;
echo C::foo();