Showing posts with label arrayaccess. Show all posts
Showing posts with label arrayaccess. Show all posts

Thursday, April 19, 2012

ArrayAccess in PHP — assigning to offset by reference


First, a quote from the ole' manual on ArrayAccess::offsetSet() :




This function is not called in assignments by reference and otherwise indirect changes to array dimensions overloaded with ArrayAccess (indirect in the sense they are made not by changing the dimension directly, but by changing a sub-dimension or sub-property or assigning the array dimension by reference to another variable). Instead, ArrayAccess::offsetGet() is called. The operation will only be successful if that method returns by reference, which is only possible since PHP 5.3.4 .