ArrayObject docs

From: Date: Sun, 05 Apr 2009 05:33:47 +0000
Subject: ArrayObject docs
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969380309@lists.php.net to get a copy of this message
Hi I've documented the ArrayObject methods that were tagged with the 'not documented' warning. Also documented iterator_to_array and iterator_count. That should be all the SPL docs tagged as not documented, so I'm now continuing with the rest of ArrayObject. Let me know if something needs fixing. Thanks, Juliette

? en/reference/spl/.DS_Store Index: en/reference/spl/arrayobject.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/arrayobject.xml,v retrieving revision 1.4 diff -u -u -r1.4 arrayobject.xml --- en/reference/spl/arrayobject.xml 23 Aug 2008 14:09:14 -0000 1.4 +++ en/reference/spl/arrayobject.xml 5 Apr 2009 05:03:23 -0000 @@ -10,7 +10,7 @@ <section xml:id="arrayobject.intro"> &reftitle.intro; <para> - ... + The ArrayObject class provides objects with similar iteration and sorting characteristics as arrays. </para> </section> <!-- }}} --> @@ -40,14 +40,31 @@ <oointerface> <interfacename>ArrayAccess</interfacename> </oointerface> - + + <oointerface> + <interfacename>Serializable</interfacename> + </oointerface> + <oointerface> <interfacename>Countable</interfacename> </oointerface> </classsynopsisinfo> <!-- }}} --> - + <classsynopsisinfo role="comment">Constants</classsynopsisinfo> + <fieldsynopsis> + <modifier>const</modifier> + <type>integer</type> + <varname linkend="arrayobject.constants.std-prop-list">ArrayObject::STD_PROP_LIST</varname> + <initializer>1</initializer> + </fieldsynopsis> + <fieldsynopsis> + <modifier>const</modifier> + <type>integer</type> + <varname linkend="arrayobject.constants.array-as-props">ArrayObject::ARRAY_AS_PROPS</varname> + <initializer>2</initializer> + </fieldsynopsis> + <!-- {{{ If the property is documented below (xml:id=arrayobject.props) use this <classsynopsisinfo role="comment">Properties</classsynopsisinfo> <fieldsynopsis> @@ -63,6 +80,32 @@ </classsynopsis> </section> + + <!-- {{{ ArrayObject constants --> + <section xml:id="arrayobject.constants"> + &reftitle.constants; + <section xml:id="arrayobject.constants.types"> + <title>ArrayObject Node Types</title> + <variablelist> + + <varlistentry xml:id="arrayobject.constants.std-prop-list"> + <term><constant>ArrayObject::STD_PROP_LIST</constant></term> + <listitem> + <para>Array indices can be accessed as properties in read/write.</para> + </listitem> + </varlistentry> + + <varlistentry xml:id="arrayobject.constants.array-as-props"> + <term><constant>ArrayObject::ARRAY_AS_PROPS</constant></term> + <listitem> + <para>Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.)</para> + </listitem> + </varlistentry> + + </variablelist> + </section> + </section> +<!-- }}} --> <!-- {{{ ArrayObject properties <section xml:id="arrayobject.props"> Index: en/reference/spl/arrayobject/append.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/arrayobject/append.xml,v retrieving revision 1.4 diff -u -u -r1.4 append.xml --- en/reference/spl/arrayobject/append.xml 20 Mar 2008 01:25:03 -0000 1.4 +++ en/reference/spl/arrayobject/append.xml 5 Apr 2009 05:03:23 -0000 @@ -9,15 +9,33 @@ &reftitle.description; <methodsynopsis> <type>void</type><methodname>ArrayObject::append</methodname> - <methodparam><type>mixed</type><parameter>newval</parameter></methodparam> + <methodparam><type>mixed</type><parameter>value</parameter></methodparam> </methodsynopsis> - - &warn.undocumented.func; + <para> + Appends a new value as the last element. + </para> + <note> + <para> + This method cannot be called when the <classname>ArrayObject</classname> was constructed from an object. + Use <methodname>ArrayObject::offsetset</methodname> instead. + </para> + </note> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; - &no.function.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>value</parameter></term> + <listitem> + <para> + The value being appended. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> </refsect1> <refsect1 role="returnvalues"> @@ -27,6 +45,56 @@ </para> </refsect1> +<refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><methodname>ArrayObject::append</methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$arrayobj = new ArrayObject(array('first','second','third')); +$arrayobj->append('fourth'); +$arrayobj->append(array('five', 'six')); +var_dump($arrayobj); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +object(ArrayObject)#1 (5) { + [0]=> + string(5) "first" + [1]=> + string(6) "second" + [2]=> + string(5) "third" + [3]=> + string(6) "fourth" + [4]=> + array(2) { + [0]=> + string(4) "five" + [1]=> + string(3) "six" + } +} +]]> + </screen> + </example> + </para> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><methodname>ArrayObject::offsetset</methodname></member> + </simplelist> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Index: en/reference/spl/arrayobject/construct.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/arrayobject/construct.xml,v retrieving revision 1.4 diff -u -u -r1.4 construct.xml --- en/reference/spl/arrayobject/construct.xml 20 Mar 2008 01:25:03 -0000 1.4 +++ en/reference/spl/arrayobject/construct.xml 5 Apr 2009 05:03:23 -0000 @@ -11,6 +11,8 @@ <constructorsynopsis> <methodname>ArrayObject::__construct</methodname> <methodparam><type>mixed</type><parameter>input</parameter></methodparam> + <methodparam><type>int</type><parameter>flags</parameter></methodparam> + <methodparam><type>string</type><parameter>iterator_class</parameter></methodparam> </constructorsynopsis> <para> This constructs a new array <type>object</type>. @@ -26,7 +28,24 @@ <listitem> <para> The <parameter>input</parameter> parameter accepts an - <type>array</type> or another <classname>ArrayObject</classname>. + <type>array</type> or an <type>Object</type>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>flags</parameter></term> + <listitem> + <para> + Flags to control the behaviour of the <classname>ArrayObject</classname> object. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>iterator_class</parameter></term> + <listitem> + <para> + Specify the class that will be used for iteration of the <classname>ArrayObject</classname> object. + <classname>ArrayIterator</classname> is the default class used. </para> </listitem> </varlistentry> Index: en/reference/spl/arrayobject/count.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/arrayobject/count.xml,v retrieving revision 1.4 diff -u -u -r1.4 count.xml --- en/reference/spl/arrayobject/count.xml 20 Mar 2008 01:25:03 -0000 1.4 +++ en/reference/spl/arrayobject/count.xml 5 Apr 2009 05:03:23 -0000 @@ -3,7 +3,7 @@ <refentry xml:id="arrayobject.count" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::count</refname> - <refpurpose>Get the number of elements in the Iterator</refpurpose> + <refpurpose>Get the number of public properties in the ArrayObject</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -11,8 +11,9 @@ <type>int</type><methodname>ArrayObject::count</methodname> <void/> </methodsynopsis> - - &warn.undocumented.func; + <para> + Get the number of public properties in the <classname>ArrayObject</classname>. + </para> </refsect1> <refsect1 role="parameters"> @@ -23,10 +24,48 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - The number of elements in the Iterator. + The number of public properties in the <classname>ArrayObject</classname>. </para> + <note> + <para> + When the <classname>ArrayObject</classname> is constructed from an array all properties are public. + </para> + </note> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><methodname>ArrayObject::count</methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +class Example { + public $public = 'prop:public'; + private $prv = 'prop:private'; + protected $prt = 'prop:protected'; +} + +$arrayobj = new ArrayObject(new Example()); +var_dump($arrayobj->count()); + +$arrayobj = new ArrayObject(array('first','second','third')); +var_dump($arrayobj->count()); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +int(1) +int(3) +]]> + </screen> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Index: en/reference/spl/arrayobject/offsetexists.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/arrayobject/offsetexists.xml,v retrieving revision 1.4 diff -u -u -r1.4 offsetexists.xml --- en/reference/spl/arrayobject/offsetexists.xml 20 Mar 2008 01:25:03 -0000 1.4 +++ en/reference/spl/arrayobject/offsetexists.xml 5 Apr 2009 05:03:23 -0000 @@ -3,7 +3,7 @@ <refentry xml:id="arrayobject.offsetexists" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::offsetExists</refname> - <refpurpose>Returns whether the requested $index exists</refpurpose> + <refpurpose>Returns whether the requested index exists</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -11,8 +11,6 @@ <type>bool</type><methodname>ArrayObject::offsetExists</methodname> <methodparam><type>mixed</type><parameter>index</parameter></methodparam> </methodsynopsis> - - &warn.undocumented.func; </refsect1> <refsect1 role="parameters"> @@ -34,7 +32,34 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - &true; if the requested $index exists, otherwise &false; + &true; if the requested index exists, otherwise &false; + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><methodname>ArrayObject::offsetexists</methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$arrayobj = new ArrayObject(array('zero', 'one', 'example'=>'e.g.')); +var_dump($arrayobj->offsetexists(1)); +var_dump($arrayobj->offsetexists('example')); +var_dump($arrayobj->offsetexists('notfound')); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +bool(true) +bool(true) +bool(false) +]]> + </screen> + </example> </para> </refsect1> Index: en/reference/spl/arrayobject/offsetget.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/arrayobject/offsetget.xml,v retrieving revision 1.4 diff -u -u -r1.4 offsetget.xml --- en/reference/spl/arrayobject/offsetget.xml 20 Mar 2008 01:25:03 -0000 1.4 +++ en/reference/spl/arrayobject/offsetget.xml 5 Apr 2009 05:03:23 -0000 @@ -3,7 +3,7 @@ <refentry xml:id="arrayobject.offsetget" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::offsetGet</refname> - <refpurpose>Returns the value at the specified $index</refpurpose> + <refpurpose>Returns the value at the specified index</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -11,8 +11,6 @@ <type>mixed</type><methodname>ArrayObject::offsetGet</methodname> <methodparam><type>mixed</type><parameter>index</parameter></methodparam> </methodsynopsis> - - &warn.undocumented.func; </refsect1> <refsect1 role="parameters"> @@ -34,7 +32,32 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - The value at the specified $index. + The value at the specified index. + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><methodname>ArrayObject::offsetget</methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$arrayobj = new ArrayObject(array('zero', 'one', 'example'=>'e.g.')); +var_dump($arrayobj->offsetget(1)); +var_dump($arrayobj->offsetget('example')); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +string(3) "one" +string(4) "e.g." +]]> + </screen> + </example> </para> </refsect1> Index: en/reference/spl/arrayobject/offsetset.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/arrayobject/offsetset.xml,v retrieving revision 1.4 diff -u -u -r1.4 offsetset.xml --- en/reference/spl/arrayobject/offsetset.xml 20 Mar 2008 01:25:03 -0000 1.4 +++ en/reference/spl/arrayobject/offsetset.xml 5 Apr 2009 05:03:23 -0000 @@ -3,7 +3,7 @@ <refentry xml:id="arrayobject.offsetset" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::offsetSet</refname> - <refpurpose>Sets the value at the specified $index to $newval</refpurpose> + <refpurpose>Sets the value at the specified index to newval</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -13,8 +13,6 @@ <methodparam><type>mixed</type><parameter>newval</parameter></methodparam> </methodsynopsis> - &warn.undocumented.func; - <para> Sets the value at the specified index to newval. </para> @@ -51,6 +49,67 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><methodname>ArrayObject::offsetset</methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +class Example { + public $myProperty = 'p1'; +} +$arrayobj = new ArrayObject(new Example()); +$arrayobj->offsetset(4, 'four'); +$arrayobj->offsetset('group', array('g1', 'g2')); +var_dump($arrayobj); + +$arrayobj = new ArrayObject(array('zero','one')); +$arrayobj->offsetset(null, 'last'); +var_dump($arrayobj); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +object(ArrayObject)#1 (3) { + ["myProperty"]=> + string(2) "p1" + [4]=> + string(4) "four" + ["group"]=> + array(2) { + [0]=> + string(2) "g1" + [1]=> + string(2) "g2" + } +} +object(ArrayObject)#3 (3) { + [0]=> + string(4) "zero" + [1]=> + string(3) "one" + [2]=> + string(4) "last" +} +]]> + </screen> + </example> + </para> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><methodname>ArrayObject::append</methodname></member> + </simplelist> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: Index: en/reference/spl/arrayobject/offsetunset.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/arrayobject/offsetunset.xml,v retrieving revision 1.4 diff -u -u -r1.4 offsetunset.xml --- en/reference/spl/arrayobject/offsetunset.xml 20 Mar 2008 01:25:03 -0000 1.4 +++ en/reference/spl/arrayobject/offsetunset.xml 5 Apr 2009 05:03:23 -0000 @@ -3,7 +3,7 @@ <refentry xml:id="arrayobject.offsetunset" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::offsetUnset</refname> - <refpurpose>Unsets the value at the specified $index</refpurpose> + <refpurpose>Unsets the value at the specified index</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; @@ -11,9 +11,6 @@ <type>void</type><methodname>ArrayObject::offsetUnset</methodname> <methodparam><type>mixed</type><parameter>index</parameter></methodparam> </methodsynopsis> - - &warn.undocumented.func; - <para> Unsets the value at the specified index. </para> @@ -42,6 +39,33 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><methodname>ArrayObject::offsetunset</methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$arrayobj = new ArrayObject(array(0=>'zero',2=>'two')); +$arrayobj->offsetunset(2); +var_dump($arrayobj); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +object(ArrayObject)#1 (1) { + [0]=> + string(4) "zero" +} +]]> + </screen> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Index: en/reference/spl/functions/iterator-count.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/functions/iterator-count.xml,v retrieving revision 1.8 diff -u -u -r1.8 iterator-count.xml --- en/reference/spl/functions/iterator-count.xml 30 Nov 2008 00:26:49 -0000 1.8 +++ en/reference/spl/functions/iterator-count.xml 5 Apr 2009 05:03:23 -0000 @@ -10,11 +10,8 @@ &reftitle.description; <methodsynopsis> <type>int</type><methodname>iterator_count</methodname> - <methodparam><type>Traversable</type><parameter>iterator</parameter></methodparam> + <methodparam><type>Object</type><parameter>iterator</parameter></methodparam> </methodsynopsis> - - &warn.undocumented.func; - <para> Count the elements in an iterator. </para> @@ -29,6 +26,8 @@ <listitem> <para> The iterator being counted. + The iterator must either implement or inherit from a class implementing the + <classname>Iterator</classname> or <classname>IteratorAggregate</classname> interface. </para> </listitem> </varlistentry> @@ -43,6 +42,29 @@ </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>iterator_count</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$iterator = new ArrayIterator(array('recipe'=>'pancakes', 'egg', 'milk', 'flour')); +var_dump(iterator_count($iterator)); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +int(4) +]]> + </screen> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Index: en/reference/spl/functions/iterator-to-array.xml =================================================================== RCS file: /repository/phpdoc/en/reference/spl/functions/iterator-to-array.xml,v retrieving revision 1.11 diff -u -u -r1.11 iterator-to-array.xml --- en/reference/spl/functions/iterator-to-array.xml 16 Jan 2009 12:08:50 -0000 1.11 +++ en/reference/spl/functions/iterator-to-array.xml 5 Apr 2009 05:03:23 -0000 @@ -10,14 +10,11 @@ &reftitle.description; <methodsynopsis> <type>array</type><methodname>iterator_to_array</methodname> - <methodparam><type>Traversable</type><parameter>iterator</parameter></methodparam> + <methodparam><type>Object</type><parameter>iterator</parameter></methodparam> <methodparam choice="opt"><type>bool</type><parameter>use_keys</parameter><initializer>true</initializer></methodparam> </methodsynopsis> - - &warn.undocumented.func; - <para> - Count the elements in an iterator. + Copy the elements of an iterator into an array. </para> </refsect1> @@ -29,7 +26,7 @@ <term><parameter>iterator</parameter></term> <listitem> <para> - The iterator being counted. + The iterator being copied. </para> </listitem> </varlistentry> @@ -37,7 +34,7 @@ <term><parameter>use_keys</parameter></term> <listitem> <para> - <!-- FIXME --> + Whether to use the iterator element keys as index. </para> </listitem> </varlistentry> @@ -48,7 +45,50 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - The number of elements in <parameter>iterator</parameter>. + An <type>array</type> containing the elements of the <parameter>iterator</parameter>. + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>iterator_to_array</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$iterator = new ArrayIterator(array('recipe'=>'pancakes', 'egg', 'milk', 'flour')); +var_dump(iterator_to_array($iterator, true)); +var_dump(iterator_to_array($iterator, false)); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +array(4) { + ["recipe"]=> + string(8) "pancakes" + [0]=> + string(3) "egg" + [1]=> + string(4) "milk" + [2]=> + string(5) "flour" +} +array(4) { + [0]=> + string(8) "pancakes" + [1]=> + string(3) "egg" + [2]=> + string(4) "milk" + [3]=> + string(5) "flour" +} +]]> + </screen> + </example> </para> </refsect1>
« previous php.doc (#969380309) next »