rfc:hashkey

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:hashkey [2014/10/22 17:51] krakjoerfc:hashkey [2014/10/24 05:39] krakjoe
Line 1: Line 1:
-====== PHP RFC: __toKey magic method ====== +Merged to rfc/objkey
-  * Version: 0.9 +
-  * Date: 2014-10-22 +
-  * Author: Joe Watkins +
-  * Status: Draft +
-  * First Published at: http://wiki.php.net/rfc/hashkey +
- +
-===== Proposal ===== +
-A new magic toKey method, to resolve the problem of not being able to use Objects as array keys. +
- +
-<code php> +
-<?php +
-class Foo { +
-    public function __toKey() { +
-        return "Foo"; +
-    } +
-+
- +
-$foo = new Foo(); +
-$test = [ +
-    $foo => true +
-]; +
-</code> +
- +
-Inheritance shall work as any other magic method: +
- +
-<code php> +
-<?php +
-class Foo { +
-    public function __toKey() { +
-        return "Foo"; +
-    } +
-+
- +
-class Bar extends Foo { +
-    /* shall use Foo::__toKey unless Bar::__toKey is implemented */ +
-+
- +
-$bar = new Bar(); +
-$test = [ +
-    $bar => true +
-]; +
-</code> +
- +
-The current behaviour of __toString is unchanged. +
- +
-===== Proposed PHP Version(s) ===== +
-+
- +
-===== Open Issues ===== +
-Make sure there are no open issues when the vote starts! +
- +
-===== Proposed Voting Choices ===== +
-The language is changed, so requires a 2/3 majority to pass. +
- +
-A straight yes/no vote should be conducted. +
- +
-===== Patches and Tests ===== +
-http://github.com/krakjoe/php-src/compare/hashkey +
- +
-===== References ===== +
-Links to external references, discussions or RFCs +
- +
-===== Rejected Features ===== +
-Keep this updated with features that were discussed on the mail lists.+
rfc/hashkey.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1