I came across an interesting problem today. In the context of a single file for multiple declarations, if class B implements interface A , and class C extends class A , class class B must be declared before class C
The following code does not work:
interface A {} class C extends B {}
This fixes:
interface A {} class B implements A {} class C extends B {}
But this works great:
class A {} class C extends B {}
These are my results on PHP 5.3.8 (Win32) and PHP 5.3.3-1ubuntu9.6 w / suhosin.
So the question is: is this documented behavior? . Why will it work with classes, but not with interfaces? Or should this be considered a mistake?
Let me know about your experience before I start digging the PHP source code and / or opening a ticket with a PHP error. :)
Thanks!
Note. I know this is just a matter of determining the order of the class, but it puzzles me ... If this is inappropriate, please feel free to close it.
source share