function test() { $a = X::foo(); $a(); $a = Y::foo(); $a(); $a = X::bar(); $a(); $a = Y::bar(); $a(); $x = new X(); $a = $x->bar(); $a(); $x = new Y(); $a = $x->bar(); $a(); $a = X::bar_nonstatic(); $a(); $a = Y::bar_nonstatic(); $a(); $x = new X(); $a = $x->bar_nonstatic(); $a(); $x = new Y(); $a = $x->bar_nonstatic(); $a(); }
function test($a) { $x = new X(); while (true) { $x->foo(new Exception()); } }
function test() { $x = new X(); $x->foo(); $s = serialize($x); var_dump($s); $y = unserialize($s); var_dump($y); }
function test() { $x = new X(); var_dump($x->foo()->bar); var_dump($x->foo()->bar); var_dump($x->foo()->bar); var_dump(foo()->bar); foo()->bar = 6; var_dump(foo()->bar); foo()->bar = 7; var_dump(foo()->bar); foo()->bar = 8; var_dump(foo()->bar); bar()->bar = 6; var_dump(bar()->bar); bar()->bar = 7; var_dump(bar()->bar); bar()->bar = 8; var_dump(bar()->bar); }
var $f; var $a; function X() { $this->f = "foo"; $this->a = array("foo"); } function foo() { echo "X::foo\n"; } } function foo() { echo "foo\n"; } $f = "foo"; $a = array("foo"); $x = new X(); foo(); // foo $x->foo(); // X::foo $x->{$f}(); // X::foo $x->{"f" . "oo"}(); // X::foo $x->a[0](); // foo $x->{$a}[0](); // X::foo
<?php class X { function foo($t) { ${$t} = 5; (yield $this); } } $x = new X(); foreach ($x->foo('this') as $v) { var_dump($v); }
function test() { X::foo(); }
<?php class X { public $a = 3; function foo($t) { ${$t} = 5; var_dump($this->a); var_dump($this); } } $x = new X(); $x->foo('this');
function bar(X $a) { $a->foo(); }
<?php class X { static function foo() { return false; } static function bar() { return 5.5; } static function baz() { return time(); } } var_dump(X::foo()); var_dump(X::bar()); var_dump(gettype(X::baz()));
<?php class X { public function foo($y) { call_user_func(array($y, 'foo')); $y::foo(); } } class Y { public static function foo() { var_dump(__METHOD__); static::bar(); } public static function bar() { var_dump(__METHOD__); } } $x = new X(); $x->foo('y'); $x->foo(new Y());
function test() { id(X::foo(1))->bar(); }
<?php class X { function foo($x, $y) { $a = null; if ($x) { $a = new X(); } new X($y ? null : $a); return $a; } } $x = new X(); var_dump($x->foo(false, true));
function test() { $x = new X(); $x->foo('hello'); var_dump($x); }
function bar(X $x) { $x->foo(); $x->foo(); }
function test() { X::foo(); fb_intercept('X::foo', 'bar', 'bar'); X::foo(); }
$e = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT); } function foo($ids) { return array($this->bar, $ids, $this->bar, $this->bar, $this->bar, $this->bar); } } function test() { $a = new X(); (yield 1); (yield $a); global $g; $g = null; (yield 2); } function main() { global $g; $g = test(); for ($g->rewind(); $g && $g->valid(); $g->next()) { var_dump($g->current()); } var_dump($g); global $e; $e = null; } main(); $a = new X(); var_dump($a->foo(1)); $a = null;
<?php function f() { throw new Exception('foo'); } class X { function foo() { try { f(); } catch (Exception $this) { return $this; } } } $x = new X(); $ex = $x->foo(); var_dump($ex->getMessage());
function test(X $x) { $y = $x->foo(5); return ++$y; }
<?php function __autoload($x) { var_dump('AUTOLOAD:' . $x); } class X { public $foo = Y::FOO; function foo() { var_dump(__METHOD__, $this); } } X::foo();
<?php class X { private $foo; function foo(&$b) { $this->foo = $b; } } $x = new X(); $t = null; $x->foo($t);