On 16 September 2015 23:10:55 BST, Yasuo Ohgaki <yohg...@ohgaki.net> wrote: >The idea is as follows: > ><?php >declare(strict_types=1); > >function foo(int &$i) { > $i = "string"; // Raise error > $i = function_returns_string(); // Raise error > $i = 1234.5678; // Raise error > $i = function_returns_float(); // Raise error
I think the problem here would be the same as with declaring types on object properties - it would require a major change to how the engine works so that every assignment operation had a potential for type checking, and strictness could stick to variables. The reason the current type annotations can be enforced more easily is that they exist only on the boundary of a function, where variables are being copied into local parameters, and the function signature can readily hold the metadata. There is also the question from the language design point of view of whether this is too "un-PHP-like". If you want something like PHP but with full type annotations, try Hack. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php