function bar() { $obj = new A(); $obj->foo(); $obj = new B(); $obj->foo(); }
function test() { $v = 100; $arr['hello'] = $v; $a = new B(); $a->t($arr['hello'], $arr); }
function bar() { $obj = new A(); $obj->foo(123); $obj = new B(); $obj->foo(123, 456); }
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); }
function main() { $x = null; if (true) { $x = new A(); } else { $x = new B(); } //TODO: it should call both methods ... $x->foo(); //var_dump($x); }
function main() { $c = new C(); B::test($c); C::test($c); D::test($c); }
function test() { (new B())->foo(); (new B())->bar(); (new B())->baz(); B::baz(); }
public function foo2() { B::foo(); // B always changes 'static' self::foo(); // 'self' doesn't change 'static' }
public static function f() { B::g1(); parent::g1(); C::g2(); self::g2(); }
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)); }
function test() { A::test1(1, 'a'); B::test2(1, 'a'); self::test3(1, 'a'); parent::test4(1, 'a'); }
/** * Test the getInstance method */ public function testSingleton() { $a1 = A::getInstance(); $a2 = A::getInstance(); $this->assertEquals($a1, $a2); $b = B::getInstance(); $this->assertNotEquals($a1, $b); }
function test() { self::test1(); parent::test2(); static::test3(); A::test4(); B::test5(); C::test6(); }
function main() { $a = new A(); $b = new B(); $c = new C(); B::test($a); C::test($b); E::test($c); }
function cf() { A1::f(); A2::f(); \A1::f(); \A2::f(); B::f(); C::f(); }
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(); }
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")); }
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(); } } }
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"; }
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(); }
/** * 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()); }
class A { static function f() { class B { static function g() { echo __FUNCTION__; } } B::g(); } }
class A { static function f() { class B { static function g() { echo __CLASS__; } } B::g(); } }
class A { static function f() { class B { static function g() { echo __METHOD__; } } B::g(); } }
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(); } }