Re: invalid params return value

From: Date: Thu, 31 Dec 2009 09:44:34 +0000
Subject: Re: invalid params return value
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-46581@lists.php.net to get a copy of this message
On Thu, Dec 31, 2009 at 7:10 AM, Stanislav Malyshev <stas@zend.com> wrote: > Hi! > > One of the many things that is chaotic in PHP is what internal function > returns when invalid parameters are given (i.e. params parsing fails). Most > of those functions do one of: > > 1a. just return - this happens with most standard ext code, which was > converted from old params parsing to a new one. > 1b. RETURN_NULL() - this is effectively the same as 1a, but the code is > different. > > 2. RETURN_FALSE - some random set of functions does that, e.g. some of PDO > functions (PDO::prepare, PDO::setAttribute, etc.). NB: I'm not singling out > PDO here, it happens all over the code, it's just first thing that came to > my mind. > > So, both of the values are kind of OK and both have the same flaw - function > could legitimately return both NULL and false. I don't have good argument > for either of these as opposed to another one. However, I think we should > have ONE standard return value in this case - even better, some macro like > RETURN_ARGS_FAIL() (if you have a better name, ok). > > So, what do you think of that? standard macro is a good idea. I also think, that NULL makes more sense in this case. NULL kinda means "nothing was returned", which should be the case exactly (as function didn't start to work, actually) -- Alexey Zakhlestin http://www.milkfarmsoft.com/ Sent from Prague, Czech Republic

« previous php.internals (#46581) next »