vrana Thu Nov 3 05:45:49 2005 EDT
Modified files: /phpdoc/en/language/oop5 magic.xml /phpdoc/en/reference/var/functions var-export.xml Log: __set_state magic method (bug #33203) http://cvs.php.net/diff.php/phpdoc/en/language/oop5/magic.xml?r1=1.11&r2=1.12&ty=u Index: phpdoc/en/language/oop5/magic.xml diff -u phpdoc/en/language/oop5/magic.xml:1.11 phpdoc/en/language/oop5/magic.xml:1.12 --- phpdoc/en/language/oop5/magic.xml:1.11 Tue Sep 20 08:50:10 2005 +++ phpdoc/en/language/oop5/magic.xml Thu Nov 3 05:45:47 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.11 $ --> +<!-- $Revision: 1.12 $ --> <sect1 id="language.oop5.magic"> <title>Magic Methods</title> <para> @@ -16,6 +16,7 @@ <literal>__sleep</literal>, <literal>__wakeup</literal>, <literal>__toString</literal>, + <literal>__set_state</literal>, <link linkend="language.oop5.cloning">__clone</link> and <link linkend="language.oop5.autoload">__autoload</link> are magical in PHP classes. You @@ -166,6 +167,18 @@ </programlisting> </example> </sect2> + + <sect2 id="language.oop5.magic.set-state"> + <title><literal>__set_state</literal></title> + <para> + This <link linkend="language.oop5.static">static</link> method is called + for classes exported by <function>var_export</function> since PHP 5.1.0. + </para> + <para> + The only parameter of this method is an array containing exported + properties in the form <literal>array('property' => value, ...)</literal>. + </para> + </sect2> </sect1> <!-- Keep this comment at the end of the file http://cvs.php.net/diff.php/phpdoc/en/reference/var/functions/var-export.xml?r1=1.10&r2=1.11&ty=u Index: phpdoc/en/reference/var/functions/var-export.xml diff -u phpdoc/en/reference/var/functions/var-export.xml:1.10 phpdoc/en/reference/var/functions/var-export.xml:1.11 --- phpdoc/en/reference/var/functions/var-export.xml:1.10 Tue Jun 7 18:35:49 2005 +++ phpdoc/en/reference/var/functions/var-export.xml Thu Nov 3 05:45:48 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> +<!-- $Revision: 1.11 $ --> <!-- splitted from ./en/functions/var.xml, last change in rev 1.6 --> <refentry id="function.var-export"> <refnamediv> @@ -55,6 +55,32 @@ </para> </refsect1> + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.1.0</entry> + <entry> + Possibility to export classes and arrays containing classes using the + <link linkend="language.oop5.magic.set-state">__set_state</link> magic + method. + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </refsect1> + <refsect1 role="examples"> &reftitle.examples; <para> @@ -102,14 +128,37 @@ </screen> </example> </para> + <para> + <example> + <title>Exporting classes since PHP 5.1.0</title> + <programlisting role="php"> +<![CDATA[ +<?php +class A { public $var; } +$a = new A; +$a->var = 5; +var_export($a); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +A::__set_state(array( + 'var' => 5, +)) +]]> + </screen> + </example> + </para> </refsect1> <refsect1 role="notes"> &reftitle.notes; <note> <para> - Variables of type <type>resource</type> and arrays or objects containing - objects couldn't be exported by this function. + Variables of type <type>resource</type> couldn't be exported by this + function. </para> </note> </refsect1>