Re: Inconsistency in class definition/usage order
| From: | Joe Watkins | Date: | Fri, 05 Apr 2013 11:09:57 +0000 |
| Subject: | Re: Inconsistency in class definition/usage order | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-66975@lists.php.net to get a copy of this message | ||
On 04/05/2013 12:01 PM, Madara Uchiha wrote:
That's not the problem, the problem is when you extend a class with a (defined) interface, you can't use the class before it is defined (the class, not the interface). See the examples on the linked question. On Fri, Apr 5, 2013 at 1:48 PM, Joe Watkins <krakjoe@php.net> wrote:On 04/05/2013 11:39 AM, Madara Uchiha wrote:After I saw this question on Stack Overflow: http://stackoverflow.com/questions/15688642/how-does-a-class-extension-or-interface-work, I realized that the guy was right. Is there an explanation for this, or is it just one of those things that got overlooked? Should something be done? (i.e. enforcing class usage only after definition?)Interfaces must be declared before being referenced. Joe It is a logical extension, you declare a class to implement an interface it is subject to the same rules as declaring an interface - ... it must be declared before it is used.