Exception throwed if parent::__construct() not called in \DirectoryIterator subclass
| From: | Frédéric Hardy | Date: | Thu, 28 Jul 2011 09:57:32 +0000 |
| Subject: | Exception throwed if parent::__construct() not called in \DirectoryIterator subclass | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-54227@lists.php.net to get a copy of this message | ||
Hello !
In PHP 5.4 alpha, an exception is throwing if a subclass of \DirectoryIterator not called the parent constructor.
Moreover, this exception can not be catched in the constructor of the subclass.
This behavious seems to be a good idea, because \DirectoryIterator may be in an inconsistant state if the parent constructor is not called.
But i think that it's not a good idea, because it's a BC break.
It's not the case in 5.3 and i have unit test cases which fail by this new behavior, because moked \DirectoryIterator class does not call the parent constructor.
In context of unit test, the fact that \DirectoryIterator is inconsistant may be not a problem and can be the desired behavior.
There is a bug report : https://bugs.php.net/bug.php?id=55300
Best regards,
Fred
--
========================================================================
Frédéric Hardy : Architecte d'application/Admin. système/Ergonome
CV : http://blog.mageekbox.net/public/cv.frederic.hardy.pdf
Blog : http://blog.mageekbox.net
Twitter : http://twitter.com/mageekguy
========================================================================