/** * Gets the 'baz' service. * * This service is shared. * This method always returns the same instance of the service. * * @return Baz A Baz instance. */ protected function getBazService() { $this->services['baz'] = $instance = new \Baz(); $instance->setFoo($this->get('foo_with_inline')); return $instance; }
function main() { $k = new Bar(); $y = new Baz(); foo(); $k->asd(); $y->k(); }
protected function eraseData() { Foo::truncate(); Bar::truncate(); Baz::truncate(); Bom::truncate(); }
use IterMethods; public static function hacklib_initialize_statics() { self::hacklib_initialize_statics_IterMethods(); } } Foo::hacklib_initialize_statics(); class Bar implements \HH\KeyedIterable, HH\Unrelated { use IterMethods; public static function hacklib_initialize_statics() { self::hacklib_initialize_statics_IterMethods(); } } Bar::hacklib_initialize_statics(); } namespace blah { class Baz implements \HH\KeyedIterable, \HH\Unrelated { use \IterMethods; public static function hacklib_initialize_statics() { self::hacklib_initialize_statics_IterMethods(); } } Baz::hacklib_initialize_statics(); testKeys(new \Foo()); testKeys(new \Bar()); testKeys(new Baz()); }
<?php /** * A simple test class */ class Baz { function bar() { } } $f = new Baz(); $b = $f->bar();
{ var_dump($this); } } class Foo extends Singleton { } class Bar extends Singleton { } class Baz extends Bar { } $u = Foo::getInstance(); $v = Bar::getInstance(); $w = Baz::getInstance(); $u->identify(); $v->identify(); $w->identify(); $x = Foo::getInstance(); $y = Bar::getInstance(); $z = Baz::getInstance(); $u->identify(); $v->identify(); $w->identify(); $x->identify(); $y->identify(); $z->identify(); ?> ===DONE===
<?php class Foo { public static function bar() { var_dump(Foo::class); var_dump(foo::class); var_dump(self::class); var_dump(Foo::CLASS); var_dump(foo::ClAsS); var_dump(seLF::CLass); } } class Baz extends Foo { public function qux() { var_dump(parENT::CLAss); var_dump(staTIC::claSS); } } foo::bar(); $b = new Baz(); $b->qux();
<?php /** * Another Foo file used for testing */ $b = Baz::bar();
public function bar() { if (self::$d[0] + self::$d[1] + 1 === self::$e[0] + self::$e[1]) { echo "it's all good\n"; } return $this->c; } } class Bar { private $x = array("hey ", "don't make "), $y = array("jude ", "it bad "); private $z; public function __construct() { $this->z = array("", "", ""); $this->z[0] = $this->x[0] . $this->y[0]; $this->z[1] = $this->x[1] . $this->y[1]; $this->z[2] = $this->z[0] . $this->z[1]; echo $this->z[2] . "\n"; } } class Baz extends Foo { } $f = new Foo(); list($s, $i) = $f->bar(); echo $s . $i . "\n"; $g = new Baz(); list($s, $i) = $g->bar(); echo $s . $i . "\n"; new Bar();