> De : Patrick ALLAERT [mailto:patrickalla...@php.net]
>     ini_set("coercion_reporting", COERCION_ERROR); // Fail in case of
> potentially bad coercion
> 
>     foo(7);
>     // int(7)
>     foo("7");
>     // int(7)
>     foo("7 dogs");
>     // Catchable fatal error: Unsafe coercion transforming "7 dogs" to "7".
> 
> The biggest advantage, IMHO, is that you get the exact same result whether
> you do:
> 
>     foo((int) $value);
> 
> or:
> 
>     foo($value);
> 
> ... whatever the mode you are in.
> 
> Basically, this is weak type hints + something similar to what I
> contributed in the past with the "Array to string conversion" notice (see:
> https://github.com/php/php-src/commit/d81ea16e).
> 
> Care to share the pro's/con's you see with a solution like that?

That's a good idea, IMO. We can add an optional message when a conversion is 
executed in ZPP macros. It can help. The main drawback is that it is pure 
runtime check, not suitable for static analysis and related tools.

Regards

François



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to