Exemple #1
0
 public function fiz()
 {
     self::test();
     parent::test();
     static::test();
     bar::test();
 }
Exemple #2
0
--TEST--
Trying to override final method
--FILE--
<?php 
trait foo
{
    public function test()
    {
        return 3;
    }
}
class baz
{
    public final function test()
    {
        return 4;
    }
}
class bar extends baz
{
    use foo {
        test as public;
    }
}
$x = new bar();
var_dump($x->test());
?>
--EXPECTF--

Fatal error: Cannot override final method baz::test() with foo::test() in %s on line %d, position %d
Exemple #3
0
{
    function test()
    {
        var_dump(property_exists("foo", "pp1"));
        var_dump(property_exists("foo", "pp2"));
        var_dump(property_exists("foo", "pp3"));
    }
}
var_dump(property_exists());
var_dump(property_exists(""));
var_dump(property_exists("foo", "pp1"));
var_dump(property_exists("foo", "pp2"));
var_dump(property_exists("foo", "pp3"));
var_dump(property_exists("foo", "nonexistent"));
var_dump(property_exists("fo", "nonexistent"));
var_dump(property_exists("foo", ""));
var_dump(property_exists("", "test"));
var_dump(property_exists("", ""));
$foo = new foo();
var_dump(property_exists($foo, "pp1"));
var_dump(property_exists($foo, "pp2"));
var_dump(property_exists($foo, "pp3"));
var_dump(property_exists($foo, "nonexistent"));
var_dump(property_exists($foo, ""));
var_dump(property_exists(array(), "test"));
var_dump(property_exists(1, "test"));
var_dump(property_exists(true, "test"));
$foo->bar();
$bar = new bar();
$bar->test();
echo "Done\n";
Exemple #4
0
class bar
{
    public function __call($a, $b)
    {
        print "__call:\n";
        var_dump($a);
    }
    public static function __callstatic($a, $b)
    {
        print "__callstatic:\n";
        var_dump($a);
    }
    public function test()
    {
        self::ABC();
        bar::ABC();
        call_user_func(array('BAR', 'xyz'));
        call_user_func('BAR::www');
        call_user_func(array('self', 'y'));
        call_user_func('self::y');
    }
    static function x()
    {
        print "ok\n";
    }
}
$x = new bar();
$x->test();
call_user_func(array('BAR', 'x'));
call_user_func('BAR::www');
call_user_func('self::y');
Exemple #5
0
<?php

class foo
{
    public function __construct()
    {
        echo get_called_class(), "\n";
    }
    public static function test()
    {
        echo get_class(), "\n";
    }
}
class_alias('foo', 'bar');
new bar();
class baz extends bar
{
}
new baz();
baz::test();
bar::test();