Re: [RFC] Scalar Type Hinting With Casts (re-opening)

From: Date: Sun, 13 Jul 2014 13:54:14 +0000
Subject: Re: [RFC] Scalar Type Hinting With Casts (re-opening)
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-75397@lists.php.net to get a copy of this message
Le 13/07/2014 15:17, Andrea Faulds a écrit :
On 13 Jul 2014, at 14:13, Jocelyn Fournier <jocelyn.fournier@gmail.com> wrote:
Actually displaying a warning in E_STRICT but still doing the implicit cast would not change the function signature.
Sure. What I meant was more that we’re changing expectations based on php.ini/variable/etc., and I’d rather it’s always consistent.
Ok, in this case I would suggest always displaying a warning in E_STRICT since it's the whole purpose of the strict mode :)
Indeed :) But I have also performances in mind. Usually (at least in HACK / Zephir), "type hinting" is used to help the compiler optimize the code. If this type hinting could be useful to help my code working in a futur PHP->PECL compiler, or help the PHP opcache to do some optimisations, I'd like to use "type hinting" as much as possible. But with the above limitation, I'll not be able to do so.
I think this type hinting wouldn’t hinder optimisation. Casting means that it’s still guaranteed that the value you get is of the requested type.
If I'm not able to use type annotation because I *really* want to enforce the calling function variable type, I'm potentially missing some optimisations. (but with warning in strict mode, all is fine) Jocelyn

« previous php.internals (#75397) next »