コード例 #1
0
ファイル: 2058.php プロジェクト: badlamer/hhvm
<?php

error_reporting(E_ALL | E_STRICT);
trait T
{
    protected function f()
    {
        return 1;
    }
    private function p()
    {
        return 2;
    }
    function g()
    {
        return $this->f();
    }
    function h()
    {
        return $this->p();
    }
}
class C
{
    use T;
}
$c = new C();
echo $c->g();
echo $c->h();
コード例 #2
0
{
    /**
     * @return self
     */
    function f()
    {
        return $this;
    }
    /**
     * @return static
     */
    function g()
    {
        return $this;
    }
    /**
     * @return $this
     */
    function h()
    {
        return $this;
    }
    function test(C $c)
    {
    }
}
$c = new C();
$f = $c->test($c->f());
$g = $c->test($c->g());
$h = $c->test($c->h());
コード例 #3
0
ファイル: static_properties.php プロジェクト: n3b/hiphop-php
$c = new C();
$c->aFunc();
$c->bFunc();
$c->cFunc();
print "isset(C::\$h): " . (isset(C::$h) ? "true" : "false") . "\n";
print "empty(C::\$h): " . (empty(C::$h) ? "true" : "false") . "\n";
print "isset(C::\$i): " . (isset(C::$i) ? "true" : "false") . "\n";
print "empty(C::\$i): " . (empty(C::$i) ? "true" : "false") . "\n";
print "C::\$h: " . C::$h . "\n";
C::$h = 42;
print "C::\$h: " . C::$h . "\n";
C::$h += 42;
print "C::\$h: " . C::$h . "\n";
print "C::\$h: " . ++C::$h . "\n";
print "C::\$h: " . C::$h++ . "\n";
print "C::\$h: " . C::$h-- . "\n";
print "C::\$h: " . --C::$h . "\n";
$x = 1234;
C::$h =& $x;
print "C::\$h: " . C::$h . "\n";
$x++;
print "C::\$h: " . C::$h . "\n";
C::$h = 5678;
print "x: " . $x . "\n";
C::$h = array(0, 1, 2);
$y = C::$h[1];
print "\$y: {$y}\n";
C::$h[2] = 42;
$y = C::$h[2];
print "\$y: {$y}\n";
print "Test end\n";
コード例 #4
0
ファイル: static_properties.php プロジェクト: badlamer/hhvm
 static function main()
 {
     $a = new A();
     $a->aFunc();
     $b = new B();
     $b->aFunc();
     $b->bFunc();
     $c = new C();
     $c->aFunc();
     $c->bFunc();
     $c->cFunc();
     print "isset(C::\$h): " . (isset(C::$h) ? "true" : "false") . "\n";
     print "empty(C::\$h): " . (empty(C::$h) ? "true" : "false") . "\n";
     print "isset(C::\$i): " . (isset(C::$i) ? "true" : "false") . "\n";
     print "empty(C::\$i): " . (empty(C::$i) ? "true" : "false") . "\n";
     print "C::\$h: " . C::$h . "\n";
     C::$h = 42;
     print "C::\$h: " . C::$h . "\n";
     C::$h += 42;
     print "C::\$h: " . C::$h . "\n";
     print "C::\$h: " . ++C::$h . "\n";
     print "C::\$h: " . C::$h++ . "\n";
     print "C::\$h: " . C::$h-- . "\n";
     print "C::\$h: " . --C::$h . "\n";
     $x = 1234;
     C::$h =& $x;
     print "C::\$h: " . C::$h . "\n";
     $x++;
     print "C::\$h: " . C::$h . "\n";
     C::$h = 5678;
     print "x: " . $x . "\n";
     C::$h = array(0, 1, 2);
     $y = C::$h[1];
     print "\$y: {$y}\n";
     C::$h[2] = 42;
     $y = C::$h[2];
     print "\$y: {$y}\n";
     C::$h = 20;
     $w =& C::$h;
     $w = 5;
     print "C::\$h: " . C::$h . "\n";
     print "Test end\n";
 }