On Wed, Jul 1, 2009 at 10:53 PM, Hannes Magnusson<hannes.magnus...@gmail.com> wrote: > On Wed, Jul 1, 2009 at 23:36, Paul Biggar<paul.big...@gmail.com> wrote: >> On Wed, Jul 1, 2009 at 10:23 PM, Hannes >> Magnusson<hannes.magnus...@gmail.com> wrote: >>> On Wed, Jul 1, 2009 at 23:07, Paul Biggar<paul.big...@gmail.com> wrote: >>>> So, what you're saying is, the patch already handles coercion? If >>>> that's the case, then problem solved. >>> >>> The patch offers scalar type _hinting_. Not type _casting_. >>> >>> Type hinting in PHP works very simply: If the value doesn't type-match >>> the argument information (arginfo internally) then it will be rejected >>> and E_RECOVERABLE_ERROR thrown. >>> >>> In most circumstances that error is fatal. However. If the user >>> chooses then he can ignore that error (by creating his own error >>> handler) and continue the execution. >>> >>> Type _hinting_ is in no way related to type _casting_. >> >> >> It should be. > > function foo(string $str, array $arr) {} > > foo(false, "foobar"); > > You are saying that the first argument should be casted, but not the second? > Or are you planning on breaking pretty much every single application using > PHP5?
I'm sorry, I don't see what you're saying? >> Yes. Therefore only the scalar and numeric types are useful. Nobody >> wants to use an 'int' hint that fails on numeric strings. > > I do. I don't only deal with $_REQUEST stuff. > I don't have the resources to go the Y! route. I write bunch of stuff > in PHP. Real type hinting would help _alot_. My point is that type hints should be like what we've been using for years in the docs. There is obviously a tension here. People want two different features. I'm not sure I see a way to reconcile that (unless you'd like 'strict int' or 'is int'?) >> Also, I don't know what happens for string hints when you pass an >> object with a __toString handler, but it should be allowed. > > Apply the patch and try? > It would be neat if people would do a quick readthrough the patch > before arguing against it :) I did of course read the patch. I ask questions the way I do to avoid confrontation, which is all too prevalent on this list. I wanted to know what the code was intended to do, not what it does. The patch wasnt clear without context, and it had no comments or tests. (FYI, I did a fairly detailed review of the type hinting patch last year, which was ignored, so I'm reluctant to put the same effort in here). Thanks, Paul -- Paul Biggar paul.big...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php