Re: svn: /phpdoc/en/trunk/language/oop5/ basic.xml
| From: | Dennis Birkholz | Date: | Fri, 15 Jan 2016 17:02:26 +0000 |
| Subject: | Re: svn: /phpdoc/en/trunk/language/oop5/ basic.xml | ||
| References: | 1 2 3 | Groups: | php.doc.cvs |
| Request: | Send a blank email to doc-cvs+get-13991@lists.php.net to get a copy of this message | ||
Hi,
Am 15.01.2016 um 17:48 schrieb Christoph Becker:
Peter Cowburn wrote:the context of this was a discussion where several people thought that writing Foo::class was actually something save to write that would trigger an error if the class did not exist. So my main point was to show that this is a false assumption as you can not rely on the string created by Foo::class to be anything except a string. Maybe static::class is kind of a special case here as it seems and maybe should be mentioned separately. As I am no native English speaker, maybe someone can come up with nicer/more concise wording though. Greets, DennisOn 15 January 2016 at 13:31, Christoph Michael Becker <cmb@php.net> wrote:This commit was actually contributed by Dennis Birkholz via PhDOE. If I remember correctly it was a follow up to some discussion on internals or a bug report, and the main point was the fact that classes are not checked for existance, i.e. Foo::class "works" even if class Foo is not defined. In my opinion this "detail" should be documented. I'm not sure about the wording, though. Maybe Dennis, whom I've CC'd has some idea/can clarify.I don't think we need to justify why the autoloader isn't called here. A sentence saying that the autoloader is not called would be sufficient in my eyes. Also, if you want to keep the justification description, note that "::class" is not compile-time only, it can also be used for runtime lookups such as "static::class".cmb Fri, 15 Jan 2016 13:31:35 +0000Revision: http://svn.php.net/viewvc?view=revision&revision=338498 Log: ::class is a compile time transformation Changed paths:U phpdoc/en/trunk/language/oop5/basic.xmlModified: phpdoc/en/trunk/language/oop5/basic.xml ===================================================================--- phpdoc/en/trunk/language/oop5/basic.xml 2016-01-15 13:24:06 UTC(rev 338497)+++ phpdoc/en/trunk/language/oop5/basic.xml 2016-01-15 13:31:35 UTC(rev 338498) @@ -380,6 +380,14 @@</screen> </example> </para>+ <note>+ <para>The class name resolution using <literal>::class</literal> is a + compile time transformation. That means at the time the class namestring+ is created no autoloading has happened yet. As a consequence, classnames+ are expanded even if the class does not exist. No error is issued in + that case. + </para>+ </note>