Zeev Suraski wrote on 15/01/2015 11:56:
PLUS have the ability to radically
change how it behaves based on a runtime option.  It's so bad that we
decided more than a decade ago that we want to refrain from ever introducing
such elements to PHP again (e.g. magic_quotes_runtime), and I'm not sure why
we're even discussing it.

Just on this point, I do think declare() is potentially less evil than ini_set() / php.ini. A declare() directive is scoped to a particular section of code, so library authors shouldn't need to care which setting their users prefer, only the version they themselves wish to use. This contrasts completely with things like mbstring.func_overload, which makes shared library code run differently in different configurations.

As has been clarified elsewhere on this thread, under this proposal a library author writing function foo(int $foo) will ALWAYS receive an integer, regardless of how that integer is arrived at. Very approximately, the declare() directive effectively gives the caller a choice between two pieces of syntactic sugar, both of which guarantee that the callee's contract will be met:

if ( is_int($foo) ) { foo($foo); } else { raise_type_error($foo); }

or

foo ( (int)$foo );

So, just to repeat, this is NOT like register_globals or mbstring.func_overload, because shared code never needs to handle both settings.

That's not to say I'm 100% convinced that this is the right way to go, just that it's not as abominable as some people are making out.

Regards,
--
Rowan Collins
[IMSoP]

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

Reply via email to