svn: /phpdoc/en/trunk/language/oop5/ anonymous.xml
| From: | Christoph Michael Becker | Date: | Wed, 22 Jun 2016 17:10:57 +0000 |
| Subject: | svn: /phpdoc/en/trunk/language/oop5/ anonymous.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-14233@lists.php.net to get a copy of this message | ||
cmb Wed, 22 Jun 2016 17:10:57 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=339452
Log:
Integrated user notes 119153 and 119475 into the manual proper
Changed paths:
U phpdoc/en/trunk/language/oop5/anonymous.xml
Modified: phpdoc/en/trunk/language/oop5/anonymous.xml
===================================================================
--- phpdoc/en/trunk/language/oop5/anonymous.xml 2016-06-22 16:28:02 UTC (rev 339451)
+++ phpdoc/en/trunk/language/oop5/anonymous.xml 2016-06-22 17:10:57 UTC (rev 339452)
@@ -125,6 +125,56 @@
]]>
</screen>
</informalexample>
+
+ <para>
+ All objects created by the same anonymous class declaration are instances of
+ that very class.
+ </para>
+
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php
+function anonymous_class()
+{
+ return new class {};
+}
+
+if (get_class(anonymous_class()) === get_class(anonymous_class())) {
+ echo 'same class';
+} else {
+ echo 'different class';
+}]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+same class
+]]>
+ </screen>
+ </informalexample>
+
+ <note>
+ <para>
+ Note that anonymous classes are assigned a name by the engine, as
+ demonstrated in the following example. This name has to be regarded an
+ implementation detail, which should not be relied upon.
+ </para>
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php
+echo get_class(new class {});
+]]>
+ </programlisting>
+ &example.outputs.similar;
+ <screen>
+<![CDATA[
+class@anonymous/in/oNi1A0x7f8636ad2021
+]]>
+ </screen>
+ </informalexample>
+ </note>
</sect1>
<!-- Keep this comment at the end of the file