Hi all, On Tue, Mar 3, 2015 at 4:27 PM, Michael Wallner <m...@php.net> wrote:
> > > >> Do you know of any other case where a `new` operator in an object > >> oriented context can return NULL, except C++ where you have to > >> explicitly ask for that behavior? > > > > I can't say I am familiar with every OO language's implementation > > details, so I don't know. But I don't see why, if we think it's useful, > > we can not do it - especially given our factory methods/functions > > already do it. I think it's useful. > > > That’s okay, but do you think the majority of PHP developers finds that > undocumented and unexpected behaviour useful? > To me this is as useful as an internal class crashing because it doesn’t > check if it was instantiated correctly. Let's be consistent. If error happened during object instantiation, raise exceptions. Returning NULL for this case would be OK. We may be better to be consistent because exceptions can be ignored. There are 2 possibilities, return NULL or FALSE Always return NULL or FALSE for errors? Many procedural functions return FALSE for error. Most notable exceptions are argument count errors that return NULL. It may be better cleanup these inconsistent behaviors also. Regards, -- Yasuo Ohgaki yohg...@ohgaki.net