Exemplo n.º 1
0
 function foo($int) : int
 {
     return parent::foo($int);
 }
Exemplo n.º 2
0
<?php

class Test
{
    protected static $color = array('gray' => 30);
    public static function foo($type, $key)
    {
        return isset(self::${$type}[$key]);
    }
}
var_dump(Test::foo('color', 'gray'));
Exemplo n.º 3
0
<?php

class Test
{
    public function foo()
    {
        return $this++;
    }
}
$t = new Test();
var_dump($t->foo());
Exemplo n.º 4
0
<?php

class Test extends mysqli
{
    public $test = array();
    function foo()
    {
        $ar_test = array("foo", "bar");
        $this->test =& $ar_test;
    }
}
$my_test = new Test();
$my_test->foo();
var_dump($my_test->test);
Exemplo n.º 5
0
    public function __call($method, $args)
    {
    }
}
function do_throw()
{
    throw new Exception();
}
try {
    Test::foo(do_throw());
} catch (Exception $e) {
    echo "Caught!\n";
}
try {
    (new Test())->bar(do_throw());
} catch (Exception $e) {
    echo "Caught!\n";
}
try {
    $f = function () {
    };
    $f->__invoke(do_throw());
} catch (Exception $e) {
    echo "Caught!\n";
}
try {
    $t = new Test();
    $f->__invoke($t->bar(Test::foo(do_throw())));
} catch (Exception $e) {
    echo "Caught!\n";
}
Exemplo n.º 6
0
Arquivo: 2.php Projeto: badlamer/hhvm
function test4(Test $x)
{
    $x->foo(12);
}
Exemplo n.º 7
0
<?php

interface TestInterface
{
    public function foo();
    public function bar(array $bar);
}
class Test implements TestInterface
{
    public function foo(...$args)
    {
        echo __METHOD__, "\n";
    }
    public function bar(array $bar, ...$args)
    {
        echo __METHOD__, "\n";
    }
}
$obj = new Test();
$obj->foo();
$obj->bar([]);
Exemplo n.º 8
0
<?php

interface ITest
{
    const ITestConst = 42;
}
class Test implements ITest
{
    public function foo($y = 'Test', $x = self::ITestConst)
    {
        var_dump($y::ITestConst);
        var_dump(static::ITestConst);
        var_dump(self::ITestConst);
        var_dump($x);
    }
}
$t = new Test();
$t->foo();
$rc = new ReflectionClass('Test');
$method = $rc->getMethod('foo');
foreach ($method->getParameters() as $param) {
    var_dump($param->getDefaultValue());
}