svn: /phpdoc/en/trunk/language/predefined/arrayaccess/ offsetget.xml offsetset.xml
| From: | Gustavo André dos Santos Lopes | Date: | Thu, 18 Nov 2010 10:34:33 +0000 |
| Subject: | svn: /phpdoc/en/trunk/language/predefined/arrayaccess/ offsetget.xml offsetset.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-7434@lists.php.net to get a copy of this message | ||
cataphract Thu, 18 Nov 2010 10:34:33 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=305489
Log:
- Revision #305471 reverted and added a more detailed explanation of the
topic of indirect modification of overloaded array dimensions.
Bug: http://bugs.php.net/305471 (error getting bug
information)
Changed paths:
U phpdoc/en/trunk/language/predefined/arrayaccess/offsetget.xml
U phpdoc/en/trunk/language/predefined/arrayaccess/offsetset.xml
Modified: phpdoc/en/trunk/language/predefined/arrayaccess/offsetget.xml
===================================================================
--- phpdoc/en/trunk/language/predefined/arrayaccess/offsetget.xml 2010-11-18 10:13:58 UTC (rev
305488)
+++ phpdoc/en/trunk/language/predefined/arrayaccess/offsetget.xml 2010-11-18 10:34:33 UTC (rev
305489)
@@ -37,6 +37,36 @@
</para>
</refsect1>
+
+ <refsect1 role="notes">
+ &reftitle.notes;
+ <note>
+ <para>
+ Starting with PHP 5.3.4, the prototype checks were relaxed and it's
+ possible for implementations of this method to return by reference.
+ This makes indirect modifications to the overloaded array dimensions of
+ <classname>ArrayAccess</classname> objects possible.
+ </para>
+ <para>
+ A direct modification is one that replaces completely the value of
+ the array dimension, as in <literal>$obj[6] = 7</literal>. An
+ indirect modification, on the other hand, only changes part of the
+ dimension, or attempts to assign the dimension by reference to
+ another variable, as in <literal>$obj[6][7] = 7</literal> or
+ <literal>$var =& $obj[6]</literal>. Increments with
+ <literal>++</literal> and decrements with <literal>++</literal>
+ are also implemented in a way that requires indirect modification.
+ </para>
+ <para>
+ While direct modification triggers a call to
+ <function>ArrayAccess::offsetSet</function>, indirect modification
+ triggers a call to <function>ArrayAccess::offsetGet</function>.
+ In that case, the implementation of
+ <function>ArrayAccess::offsetGet</function> must be able to return by
+ reference, otherwise an <constant>E_NOTICE</constant> message is raised.
+ </para>
+ </note>
+ </refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
Modified: phpdoc/en/trunk/language/predefined/arrayaccess/offsetset.xml
===================================================================
--- phpdoc/en/trunk/language/predefined/arrayaccess/offsetset.xml 2010-11-18 10:13:58 UTC (rev
305488)
+++ phpdoc/en/trunk/language/predefined/arrayaccess/offsetset.xml 2010-11-18 10:34:33 UTC (rev
305489)
@@ -80,17 +80,22 @@
</informalexample>
</para>
</note>
+
+ <note>
+ <para>
+ This function is not called in assignments by reference and otherwise
+ indirect changes to array dimensions overloaded with
+ <classname>ArrayAccess</classname> (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, <function>ArrayAccess::offsetGet</function> is called. The
+ operation will only be successful if that method returns by reference,
+ which is only possible since PHP 5.3.4.
+ </para>
+ </note>
</refsect1>
- <refsect1 role="errors">
- &reftitle.errors;
- <para>
- Issues <constant>E_NOTICE</constant> in an attempt of indirect modification
- of overloaded element (like usage of <literal>++</literal> or
- <literal>--</literal>).
- </para>
- </refsect1>
-
<!--
<refsect1 role="examples">
&reftitle.examples;