(switching to php-dev) At 20:36 04.10.2002, Markus Fischer wrote: > Why this sudden change anyway? I mean I understand what you > mean. But this would mean to go through it everywhere or > again we will have inconsistency if me miss some. > > The (usual) developer knows (should know) that not setting > the return_value defaults to IS_NULL . Of course documenting > this (if not already, I don't know) is good [tm] and the way > I would prefer it.
I allways used to check for xxx() !== false since that is used in the documentation in some examples. See strpos() ... If the parser error is represented as NULL you cannot do something like: if (xxx() !== false) ... instead you would have to use for some function documentations about return values: array_flip() returns FALSE if it fails bool array_multisort ( array ar1 [, mixed arg [, mixed ... [, array ...]]]) [snip] Returns TRUE on success or FALSE on failure. array pop returns NULL in a normal opertion but also false or arrays... mixed array_search ( mixed needle, array haystack [, bool strict]) Searches haystack for needle and returns the key if it is found in the array, FALSE otherwise. Note: Prior to PHP 4.2.0, array_search() returns NULL on failure instead of FALSE string fgets ( int fp [, int length]) If an error occurs, returns FALSE. int filesize ( string filename) Returns the size of the file in bytes, or FALSE in case of an error. int fopen ( string filename, string mode [, int use_include_path [, resource zcontext]]) If the open fails, the function returns FALSE. Functions in question: getenv() returned FALSE before and that was documented. string getopt ( string options) Returns an associative array of option / argument pairs based on the options format specified in options, or FALSE on an error. mixed highlight_file ( string filename [, bool return]) ...then highlight_file() will return TRUE on success, FALSE on failure. mixed highlight_string ( string str [, bool return]) ...then highlight_string() will return TRUE on success, FALSE on failure. ini_get_all : no info about return value on failure getprotobyname : no info about return value on failure print_r: no info about the meaning of the boolean return value at all parse_ini_file : no info about return value on failure but php will exit is that really so? So i would go for changing all return values to FALSE on any error where possible. Possible means some functions may return FALSE but not NULL since their normal return value is boolean and false is a normal return value (so these should use NULL instead). Additionally i started to use a special documentation form false | returntype functionname(...) for some of my functions. >On Fri, Oct 04, 2002 at 08:33:42PM +0200, Marcus Börger wrote : > > In this case i would vote for RETURN_NULL(); instead > > of simply using return; > > > > At 20:20 04.10.2002, Markus Fischer wrote: > > > No function never called RETURN_FALSE if > > > zend_parse_parameters couldn't successfully parse the passed > > > parameters. > > > > > > Are we going to change this behaviour globally? > > > > > > Function up and including today returned NULL if there was a > > > problem with parsing the parameters. > > > > > > This could well break BC in my eyes. Is this absolutely > > > necessary ? > > > > > >On Fri, Oct 04, 2002 at 05:17:01PM -0000, Marcus Börger wrote : > > >> helly Fri Oct 4 13:17:01 2002 EDT > > >> > > >> Modified files: > > >> /php4/ext/standard basic_functions.c > > >> Log: > > >> return FALSE on error > > >> > > >> > > >> Index: php4/ext/standard/basic_functions.c > > >> diff -u php4/ext/standard/basic_functions.c:1.522 > > >php4/ext/standard/basic_functions.c:1.523 > > >> --- php4/ext/standard/basic_functions.c:1.522 Thu Oct 3 09:31:59 2002 > > >> +++ php4/ext/standard/basic_functions.c Fri Oct 4 13:17:01 2002 > > >> @@ -17,7 +17,7 @@ > > >> > > >+----------------------------------------------------------------------+ > > >> */ > > >> > > >> -/* $Id: basic_functions.c,v 1.522 2002/10/03 13:31:59 yohgaki Exp $ */ > > >> +/* $Id: basic_functions.c,v 1.523 2002/10/04 17:17:01 helly Exp $ */ > > >> > > >> #include "php.h" > > >> #include "php_streams.h" > > >> @@ -1377,7 +1377,7 @@ > > >> > > >> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", > > >> &options, > > >&options_len) == FAILURE) { > > >> - return; > > >> + RETURN_FALSE; > > >[...] > >-- >GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc ><rei_> Derick, while ($xml) $ass->get_new_ideas(); ><[James]> Markus: IE on_user_fart()???? >-- People doesn't seem to like the new XHTML2 specs :) -- > >-- >PHP CVS Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php