Re: [RFC] Scalar Type Hints
| From: | Alexander Moskalev | Date: | Thu, 01 Jan 2015 16:27:05 +0000 |
| Subject: | Re: [RFC] Scalar Type Hints | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80053@lists.php.net to get a copy of this message | ||
genius and simple syntax!
int $a === assertInt($a)
(int)$a === (int)$a
2015-01-01 18:59 GMT+03:00 Marcio Almada <marcio.web2@gmail.com>:
> The battle between strict type declarations vs coercive has been here for a
> while. My problem with coercion in detriment of strictness is
> that sometimes you DON'T WANT TYPE CASTING AT ALL. This new feature would
> create serious impediments. So I wonder if we couldn't have both (strict
> and coercive types declarations) and leave the current proposed type
> hinting syntax reserved for strict type declarations? Like in:
>
> function(int $a, (int) $b) {
> // $a will be strict
> // $b will be type casted
> }
>
> This way we can actually choose when to cast and when to be strict and both
> features could be voted independently without affect each other possible
> future adoptions.
>
--
With regards, Alexander Moskalev
irker@irker.net
irker@php.net
a.moskalev@corp.badoo.com