svn: /phpdoc/en/trunk/language/predefined/ arrayaccess/offsetset.xml arrayaccess.xml

From: Date: Mon, 12 Jul 2010 10:35:59 +0000
Subject: svn: /phpdoc/en/trunk/language/predefined/ arrayaccess/offsetset.xml arrayaccess.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-6884@lists.php.net to get a copy of this message
rquadling Mon, 12 Jul 2010 10:35:59 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=301180 Log: Show the use $obj[] within an ArrayAccess interface. Fix bug#52308 Bug: http://bugs.php.net/52308 (Closed) ArrayAccess does not automatically $obj[] = $x Changed paths: U phpdoc/en/trunk/language/predefined/arrayaccess/offsetset.xml U phpdoc/en/trunk/language/predefined/arrayaccess.xml Modified: phpdoc/en/trunk/language/predefined/arrayaccess/offsetset.xml =================================================================== --- phpdoc/en/trunk/language/predefined/arrayaccess/offsetset.xml 2010-07-12 09:08:47 UTC (rev 301179) +++ phpdoc/en/trunk/language/predefined/arrayaccess/offsetset.xml 2010-07-12 10:35:59 UTC (rev 301180) @@ -61,10 +61,22 @@ <programlisting role="php"> <![CDATA[ <?php -$arrayaccess[] = "value"; +$arrayaccess[] = "first value"; +$arrayaccess[] = "second value"; +print_r($arrayaccess); ?> ]]> </programlisting> + &example.output; + <screen> +<![CDATA[ +Array +( + [0] => first value + [1] => second value +) +]]> + </screen> </informalexample> </para> </note> Modified: phpdoc/en/trunk/language/predefined/arrayaccess.xml =================================================================== --- phpdoc/en/trunk/language/predefined/arrayaccess.xml 2010-07-12 09:08:47 UTC (rev 301179) +++ phpdoc/en/trunk/language/predefined/arrayaccess.xml 2010-07-12 10:35:59 UTC (rev 301180) @@ -55,7 +55,11 @@ ); } public function offsetSet($offset, $value) { - $this->container[$offset] = $value; + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } } public function offsetExists($offset) { return isset($this->container[$offset]); @@ -76,7 +80,10 @@ var_dump(isset($obj["two"])); $obj["two"] = "A value"; var_dump($obj["two"]); - +$obj[] = 'Append 1'; +$obj[] = 'Append 2'; +$obj[] = 'Append 3'; +print_r($obj); ?> ]]> </programlisting> @@ -87,6 +94,19 @@ int(2) bool(false) string(7) "A value" +obj Object +( + [container:obj:private] => Array + ( + [one] => 1 + [three] => 3 + [two] => A value + [0] => Append 1 + [1] => Append 2 + [2] => Append 3 + ) + +) ]]> </screen> </example><!-- }}} -->

« previous php.doc.cvs (#6884) next »