====== Function Array Dereferencing (FAD) ====== * Version: 1.0 * Date: June 16, 2008 (added) * Date: May 01, 2009 (declined) * Date: June 07, 2010 (re-opened) * Author: Philip Olson , Felipe Pena * Status: Implemented in PHP 5.4 ===== Introduction ===== This RFC proposes the implementation of array dereferencing of method/function return. ===== Proposal and Patch ===== Patch: http://felipe.ath.cx/diff/array_dereference.diff ===== Examples ===== FAD adds the following: 'apple', 'b' => 'banana'); } echo fruit()['a']; // apple ?> Which is a quasi-replacement for this: 'apple', 'b' => 'banana'); } $fruits = fruit(); echo $fruits['a']; ?> Working with references: int(2) } ?> Chaining: array = array(1, 2.3); } public function bar() { return $this->array; } } $foo = new foo; var_dump($foo->bar()[1]); // float(2.3) $foo->array[] = $foo; var_dump($foo->bar()[2]->bar()[2]->array[0]); // int(1) ?> ===== Related discussion ===== The following discussions/threads have taken place: * April 3, 2004: http://markmail.org/message/sbnrb7nekwy7xt3x * November 9, 2006: http://markmail.org/message/5bv6mtd7zorni7gc * June 3, 2010: http://markmail.org/message/3ancnjwqhax47n2j * June 7, 2010: http://markmail.org/message/unplu5x3gjjjydwz [Patch proposal]