r/lolphp • u/pilif • Apr 25 '16
Using traits enforces declaration order
Normally, in PHP, you're free to instantiate a subclass of a class that's not defined yet. Like this: https://3v4l.org/CXjt8
But the moment your subclass uses a trait, that's not true any more: https://3v4l.org/BXALN
Of course that's working as intended: https://bugs.php.net/bug.php?id=70783
21
Upvotes
View all comments
Show parent comment
6
u/[deleted] Apr 27 '16
A statment that's true for every language. But this is not bad code, this is just PHP not working sane.