2011/7/28 Frédéric Hardy <frederic.ha...@mageekbox.net>:
> 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.

I strongly agree. Throwing an exception ONLY because the parent constructor 
wasn't called is a serious departure from expectations. It is fine for other 
code in the parent class to fail later due to incomplete/improper 
initialization which may likely be caused by failure to call the parent 
constructor earlier, (In fact, that is even expected in many cases) but I 
cannot conceive of any acceptable reason for the error described here. Even 
though the change was certainly well intentioned, it clearly didn't account for 
the possibility of unusual but valid coding situations (such as mocks and other 
code generation tactics that should be able to reasonably depend on consistent 
language behaviors).

John Crenshaw
Priacta, Inc.

Reply via email to