|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-07-07 12:25 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2021-07-07 12:25 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 05:00:01 2025 UTC |
Description: ------------ If offsetGet() returns by-ref it should not be possible to assign to it by-ref. It does not even emit "Notice: Indirect modification of overloaded element of ArrayAccessImpl has no effect". It just silently does nothing. Test script: --------------- <?php // essentially tests/classes/array_access_012.phpt, with offsetGet returning by-ref class ArrayAccessImpl implements ArrayAccess { private $data = array(); public function offsetUnset($index) {} public function offsetSet($index, $value) { $this->data[$index] = $value; } public function &offsetGet($index) { return $this->data[$index]; } public function offsetExists($index) { return isset($this->data[$index]); } } $data = new ArrayAccessImpl(); $test = 'some data'; $data['element'] = NULL; // prevent notice $data['element'] = &$test; var_dump($data['element']); Expected result: ---------------- Fatal error: Uncaught Error: Cannot assign by reference to overloaded object ... Actual result: -------------- NULL