Example #1
0
File: 76.php Project: badlamer/hhvm
function bar()
{
    $obj = new A();
    $obj->foo();
    $obj = new B();
    $obj->foo();
}
Example #2
0
function test()
{
    $v = 100;
    $arr['hello'] = $v;
    $a = new B();
    $a->t($arr['hello'], $arr);
}
Example #3
0
File: 78.php Project: badlamer/hhvm
function bar()
{
    $obj = new A();
    $obj->foo(123);
    $obj = new B();
    $obj->foo(123, 456);
}
Example #4
0
function test()
{
    $a = new A();
    echo $a->foo();
    $a = new B();
    echo $a->foo(555);
    echo $a->foo();
}
 public function test_update_propertys_set_class()
 {
     // Mock
     $csvArray = ['a' => 'a', 'b' => 'b'];
     // Test
     $b = new B();
     $b->updateFromCSVArray($csvArray, 'B');
     $this->assertEquals($b->getA(), null);
     $this->assertEquals($b->getB(), 'b');
 }
 public function buildDashboard()
 {
     $a = new A();
     $b = new B();
     $c = new C();
     $b->setActive();
     $this->addDashboardTab($a);
     $this->addDashboardTab($b);
     $this->addDashboardTab($c);
 }
Example #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);
}
Example #8
0
function main()
{
    $c = new C();
    B::test($c);
    C::test($c);
    D::test($c);
}
Example #9
0
function test()
{
    (new B())->foo();
    (new B())->bar();
    (new B())->baz();
    B::baz();
}
Example #10
0
 public function foo2()
 {
     B::foo();
     // B always changes 'static'
     self::foo();
     // 'self' doesn't change 'static'
 }
Example #11
0
 public static function f()
 {
     B::g1();
     parent::g1();
     C::g2();
     self::g2();
 }
Example #12
0
 public function testAppendChild()
 {
     $node = new Node();
     $node->appendChild($a = new A());
     $b = new B($node);
     $node->prependChild($c = new C());
     $node->appendChild($d = new D());
     $this->assertEquals(1, $a->getIndex());
     $this->assertEquals(2, $b->getIndex());
     $this->assertEquals(0, $c->getIndex());
     $this->assertEquals(3, $d->getIndex());
     $this->assertInstanceOf(A::class, $node->getChildAt(1));
     $this->assertInstanceOf(B::class, $node->getChildAt(2));
     $this->assertInstanceOf(C::class, $node->getChildAt(0));
     $this->assertInstanceOf(D::class, $node->getChildAt(3));
 }
Example #13
0
 function test()
 {
     A::test1(1, 'a');
     B::test2(1, 'a');
     self::test3(1, 'a');
     parent::test4(1, 'a');
 }
Example #14
0
 /**
  * Test the getInstance method
  */
 public function testSingleton()
 {
     $a1 = A::getInstance();
     $a2 = A::getInstance();
     $this->assertEquals($a1, $a2);
     $b = B::getInstance();
     $this->assertNotEquals($a1, $b);
 }
Example #15
0
 function test()
 {
     self::test1();
     parent::test2();
     static::test3();
     A::test4();
     B::test5();
     C::test6();
 }
Example #16
0
function main()
{
    $a = new A();
    $b = new B();
    $c = new C();
    B::test($a);
    C::test($b);
    E::test($c);
}
Example #17
0
 function cf()
 {
     A1::f();
     A2::f();
     \A1::f();
     \A2::f();
     B::f();
     C::f();
 }
Example #18
0
 public function __construct()
 {
     self::callNonStaticMethod();
     static::callNonStaticMethod();
     parent::callNonStaticMethod();
     \NS1\A::callNonStaticMethod();
     \NS1\A::callNonStaticMethod();
     \NS2\B::callNonStaticMethod();
 }
 public function nonStaticMethod()
 {
     self::nonStaticMethod();
     self::staticMethod();
     parent::nonStaticMethod();
     parent::staticMethod();
     static::nonStaticMethod();
     static::staticMethod();
 }
Example #20
0
 public static function testNoForward()
 {
     A::test();
     call_user_func("A::test");
     call_user_func(array("A", "test"));
     B::test();
     call_user_func("B::test");
     call_user_func(array("B", "test"));
 }
Example #21
0
 public function callStatics()
 {
     self::callNonStaticMethod();
     static::callNonStaticMethod();
     parent::callNonStaticMethod();
     \NS1\A::callNonStaticMethod();
     \NS1\A::callNonStaticMethod();
     \NS2\B::callNonStaticMethod();
 }
 public function __construct()
 {
     if (null === self::$a) {
         if (!$foo) {
             self::$a = false;
         } else {
             self::$a = new A();
         }
     }
 }
Example #23
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";
 }
Example #24
0
function main()
{
    call_user_func(array('A', 'private_func'), "1", "2", "3");
    call_user_func(array('A', 'protected_func'), "1", "2", "3");
    call_user_func(array('A', 'public_func'), "1", "2", "3");
    call_user_func(array('B', 'private_func'), "1", "2", "3");
    call_user_func(array('B', 'protected_func'), "1", "2", "3");
    call_user_func(array('B', 'public_func'), "1", "2", "3");
    A::test();
    B::test();
}
Example #25
0
 /**
  * Under Zend, forward_static_call(array($obj, 'f1')) will pass in $obj
  * as the current instance ($obj is of class B) but it sets the late bound
  * class to C. This violates an invariant stated in Zend PHP's documentation
  * at http://us.php.net/lsb which states "In non-static contexts, the called
  * class will be the class of the object instance." For these cases, HipHop
  * reconciles this issue by setting the late bound class to the class of the
  * current instance if there is one.
  */
 public function g()
 {
     $obj = new B();
     $obj->f1();
     // B B
     B::f1();
     // C C
     forward_static_call(array($obj, 'f1'));
     // B B (Zend PHP 5.3 outputs C B)
     forward_static_call(array('B', 'f1'));
     // C C
     echo "***************\n";
     $obj->f2();
     // B
     B::f2();
     // B
     forward_static_call(array($obj, 'f2'));
     // C
     forward_static_call(array('B', 'f2'));
     // C
 }
 public function expectreplacedBehavior()
 {
     $mock = new ClassMethodReplacementGuard();
     $mock->replace('StaticMock\\MethodReplacer\\A', 'a', function () {
         return 3;
     });
     $mock->replace('StaticMock\\MethodReplacer\\B', 'b', function () {
         return 4;
     });
     $this->assertEquals(3, A::a());
     $this->assertEquals(4, B::b());
     $this->assertEquals(3, C::bar());
 }
Example #27
0
class A
{
    static function f()
    {
        class B
        {
            static function g()
            {
                echo __FUNCTION__;
            }
        }
        B::g();
    }
}
Example #28
0
class A
{
    static function f()
    {
        class B
        {
            static function g()
            {
                echo __CLASS__;
            }
        }
        B::g();
    }
}
Example #29
0
class A
{
    static function f()
    {
        class B
        {
            static function g()
            {
                echo __METHOD__;
            }
        }
        B::g();
    }
}
Example #30
0
 public static function mycatch()
 {
     try {
         static::who();
         B::throwException_after();
     } catch (Exception $e) {
         static::who();
         A::test();
         static::who();
         B::test();
         static::who();
         self::simpleCatch();
         static::who();
     }
 }