Re: Return value of convert_to_*()

From: Date: Wed, 27 Dec 2006 21:12:10 +0000
Subject: Re: Return value of convert_to_*()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-27206@lists.php.net to get a copy of this message
Why do you want that? "Bad" conversion is failed conversion, that's the case when you get E_RECOVERABLE_ERROR and it bails out.
Yes, I want that function to return FAILURE when we issue E_RECOVERABLE_ERROR. Exactly what I was talking about.
One such place is zend_parse_parameters(). If you say zpp(..., "s", &str, &str_len) and the user passes an object without __toString() method, zpp() should issue an error saying that it expected a string and got an object instead, even if we "forced" the conversion result to be a string in convert_to_string().
An error? You mean this one: zend_error(E_NOTICE, "Object of class %v to string conversion", Z_OBJCE_P(op)->name); ? We already have it, no need for a new error.
I want zend_parse_parameters() to issue a warning, saying "foo() expects parameter 1 to be string, object given". I do not consider "Object" to be a valid conversion for this purpose.
It's perfectly legal to do it in 5.2 and I don't see why PHP6 is different. IMO it's same as changing the E_RECOVERABLE to E_ERROR - users won't have any way to "workaround" it, even though this was the original intention of E_RECOVERABLE.
It is not the same. E_ERROR stops execution. Returning FAILURE from convert_to_string() is simply a flag that lets calling code know what happened. -Andrei

« previous php.internals (#27206) next »