rfc:instance-method-call
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:instance-method-call [2010/11/26 19:12] – update felipe | rfc:instance-method-call [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2010-11-26 | * Date: 2010-11-26 | ||
* Author: Felipe Pena < | * Author: Felipe Pena < | ||
- | * Status: | + | * Status: |
===== Introduction ===== | ===== Introduction ===== | ||
- | The purpose of RFC is to presents the support | + | The purpose of RFC is to presents the support |
+ | We could use one of two syntaxes below: | ||
+ | |||
+ | ===== Syntax 1 (without brackets) ===== | ||
+ | |||
+ | * %%new foo-> | ||
+ | * %%new $foo()-> | ||
+ | * %%new $bar-> | ||
+ | |||
+ | ===== Syntax 2 (with brackets) ===== | ||
+ | |||
+ | * %%(new foo())-> | ||
+ | * %%(new $foo())-> | ||
+ | * %%(new $bar-> | ||
+ | * %%(new foo)[0]%% | ||
===== Examples ===== | ===== Examples ===== | ||
+ | |||
+ | === Using brackets === | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | class foo extends ArrayObject { | ||
+ | public function __construct($arr) { | ||
+ | parent:: | ||
+ | } | ||
+ | } | ||
+ | |||
+ | var_dump( (new foo( array(1, array(4, 5), 3) ))[1][0] ); // int(4) | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | class foo { | ||
+ | public $x = 1; | ||
+ | } | ||
+ | |||
+ | class bar { | ||
+ | public $y = ' | ||
+ | } | ||
+ | |||
+ | $x = ' | ||
+ | |||
+ | $bar = new bar; | ||
+ | |||
+ | var_dump((new bar)-> | ||
+ | var_dump((new $x)-> | ||
+ | var_dump((new $bar-> | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | class bar { | ||
+ | public $z; | ||
+ | |||
+ | public function __construct() { | ||
+ | $this-> | ||
+ | } | ||
+ | public function getZ() { | ||
+ | return $this-> | ||
+ | } | ||
+ | } | ||
+ | |||
+ | var_dump(clone (new bar)-> | ||
+ | var_dump(clone (new bar)-> | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | === Without brackets === | ||
<code php> | <code php> | ||
Line 26: | Line 100: | ||
} | } | ||
- | $X = new foo()-> | + | $X = new foo-> |
var_dump($X); | var_dump($X); | ||
Line 67: | Line 141: | ||
try { | try { | ||
- | $X = new foo()-> | + | $X = new foo-> |
} catch (Exception $e) { | } catch (Exception $e) { | ||
- | var_dump($e-> | + | var_dump($e-> |
} | } | ||
Line 75: | Line 149: | ||
</ | </ | ||
- | ===== Proposal and Patch ===== | + | ===== Patch ===== |
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | ===== Changelog ===== | ||
+ | * 08/04/2014 - Closed as " | ||
+ | * 06/11/2011 - Implemented (Syntax 2) in [[http:// | ||
+ | * 26/11/2010 - Posted RFC on internals | ||
+ | * 27/11/2010 - New syntax proposed | ||
+ | * 29/11/2010 - Added array dereferencing support (e.g. %%(new foo)[0]%%) |
rfc/instance-method-call.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1