[2006年07月16日 23:37 UTC] public at grik dot net
Description: ------------ Slightly modifying a Harry Fuecks's sample from sitepoint.com on implemening the ArrayAccess interface, I get some unrelated error. Maybe it's a documentation bug again... Reproduce code: --------------- <?php class Article implements ArrayAccess { public $title; function __construct($title) { $this->title = $title; } function offsetSet($key, $value){ $this->{$key} = &$value; } function offsetGet($key){ return $this->{$key}; } function offsetUnset($key){ unset($this->{$key}); } function offsetExists($offset) { return array_key_exists($offset,get_object_vars($this)); } } // Create the object $A = new Article('SPL Rocks'); // Change the title using array syntax using reference $str = 'SPL _really_ rocks'; $A['title'] =&$str; // Check what it looks like again print_r($A); ?> Expected result: ---------------- Article Object ( [title] => SPL _really_ rocks ) Actual result: -------------- Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in test.php on line 27 There was no increment/decrement operations used. It would be _much_ better if it would be allowed to write function offsetSet($key, &$value){...} PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006年07月16日 23:43 UTC] public at grik dot net
[2006年07月16日 23:55 UTC] helly@php.net
[2006年07月17日 00:42 UTC] public at grik dot net
[2006年07月17日 06:36 UTC] tony2001@php.net
[2006年07月24日 00:00 UTC] public at grik dot net
[2016年03月20日 13:06 UTC] nikic@php.net
-Package: Feature/Change Request
+Package: *General Issues
[2016年03月20日 13:06 UTC] nikic@php.net
[2016年03月20日 18:09 UTC] public at grik dot net
[2021年08月18日 14:55 UTC] cmb@php.net
-Package: *General Issues
+Package: Scripting Engine problem
|