AW: [PHP-DEV] Reviving scalar type hints

From: Date: Fri, 20 Feb 2015 19:48:08 +0000
Subject: AW: [PHP-DEV] Reviving scalar type hints
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to internals+get-83351@lists.php.net to get a copy of this message
Hi Dmitry and Anthony, I was skimming through your conversation about JIT/AOT and that type hints would allow to optimise few things. I do not know if you are aware of the following but type hints can be passed by. Hence neither weak or strict type hints allow to predict the type (even if only locally): function handler($errno, $errstr, $errfile, $errline){ return true; } set_error_handler("handler"); class Foo{} function foo(int $x, Foo $f){ var_dump($x, $f); $y = $x; //should be int as well, right? } foo(new Foo(), 1); Sure, this is something which is hopefully never ever done but anyway, a language needs to be able to handle all cases. As a side notice, if the exceptions in the engine RFC is accepted, then this would not be a problem anymore: https://wiki.php.net/rfc/engine_exceptions_for_php7 Personally, I would expect that the execution is stopped after the error_handler was called (after user was able to log etc.) - at least in strict mode. Cheers, Robert

« previous php.internals (#83351) next »