====== PHP RFC: Collections ====== * Version: 0.1.0 * Date: 2023-04-24 * Author: Derick Rethans * Status: Very Early Draft * First Published at: http://wiki.php.net/rfc/collections ===== Introduction ===== This RFC suggests to introduce a new ==== Definitions ==== ^ Term ^ Description ^ | Biscuits | Better than cookies | ===== Proposal ===== ==== Basics ==== Design Goals: * Non Design Goals: * ==== Syntax ==== collection Articles(int => Article) { } Is short hand for, but acts like ArrayAccess too: class Articles { private array $__collection_items; public function __construct() { $this->__collection_items = []; } public function offsetExists(int $offset): bool { return array_key_exists($offset, $this->__collection_items); } public function offsetGet(int $offset) : ?Article { return $this->offsetExists($offset) ? $this->__collection_items[$offset] : NULL; } public function offsetSet(int $offset, Article $item) : void { $this->__collection_items[$offset] = $item; } public function offsetUnset(int $offset): void { unset($this->__collection_items[$offset]); } } ===== Implementation Details ===== ===== Backward Incompatible Changes ===== ===== Proposed PHP Version(s) ===== Next PHP 8.x ===== RFC Impact ===== There will be no impact to SAPIs, existing extensions, nor Opcache. ===== Open Issues ===== ===== Questions and Answers ===== ==== Why is this not a composer package? ==== ===== Future Scope ===== ===== Proposed Voting Choices ===== Either "yes" or "no" on including the proposed class. ===== Patches and Tests ===== There is no patch yet. ===== Implementation ===== After the project is implemented, this section should contain - the version(s) it was merged into - a link to the git commit(s) - a link to the PHP manual entry for the feature - a link to the language specification section (if any) ===== References ===== ===== Rejected Features ===== Nothing rejected yet. ===== Changes ===== 0.1.0 — 2023-04-24 * Initial Draft