Re: Re: Scalar Type Declaration Syntax Weirdness

From: Date: Tue, 24 Nov 2015 17:16:22 +0000
Subject: Re: Re: Scalar Type Declaration Syntax Weirdness
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-89388@lists.php.net to get a copy of this message
Hi Stas, Stanislav Malyshev wrote:
Hi!
       <?php
       function a(\int $i) {}
Is it intentional that the \ in front of the "int" is allowed? IMHO, this confusing notation must not be allowed.
This is weird and I'd consider it a bug. You can't do \array or \callable, and if I saw \int, I'd think it meant a class of that name rather than a scalar type.
I would assume \int means class named "int", as opposed to "int" type.
That's also what I'd expect. However, "int" is not allowed as a class name in PHP 7. And unfortunately what the code Sebastian posted sctually does is act as an integer type hint, not as a class type hint.
Can this be fixed for 7.0.0?
I don't think this would be a good idea. We're in the final stretch of release cycle, and should not do any non-urgent fixes. This does not look urgent. It can wait for 7.0.1.
It can't wait for 7.0.1, because banning this would be a backwards-compatibility break with 7.0.0. We have to fix it in 7.0.0 or not fix it ever. Thanks. -- Andrea Faulds http://ajf.me/

« previous php.internals (#89388) next »