Inconsistencies with constructors in SPL
| From: | Andrew Curioso | Date: | Mon, 16 May 2011 18:14:04 +0000 |
| Subject: | Inconsistencies with constructors in SPL | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-52399@lists.php.net to get a copy of this message | ||
So, I ran across bug #54631
A fatal error is thrown if you try to call parent::__construct() from a
subclass
of SplObjectStorage.
I was going to close it as "expected behavior" since that is pretty normal
if the parent class doesn't implement __construct().
Also, the docs don't list it as having a __construct() method.
But then look at SplDoublyLinkedList (and a bunch of others). They are
documented
as having a __construct() method, yet it triggers a fatal error when you try
to call
"parent::__construct()" from a subclass' constructor .
So it seems to me that there are two possible solutions:
- Update the docs to remove ::__construct() for classes that don't have one.
- Make sure __construct() is implemented in all SPL classes * and update the
docs.
* Even if it is empty.
What's everyone thinking?
I'd be more than happy to add the constructors to the code where needed, I
just
want to make sure that it is the right move first.
- Andrew