Re: make casts more strict in PHP 7
| From: | Park Framework | Date: | Thu, 11 Sep 2014 03:02:43 +0000 |
| Subject: | Re: make casts more strict in PHP 7 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77147@lists.php.net to get a copy of this message | ||
> You know, “int”, “float”, “string” etc. aren’t currently reserved words. We could
> add functions, or even make them reserved words and add internal functions (à la isset), so
> int(‘2’), float(‘2.0’), string(‘test’) etc.
>
> Or perhaps class-like constructors? $a = new int('2'); ? Would kinda make sense given
> some people want to add methods to primitive types.
+1
$int instanceof Int
$float instanceof Float
$num instanceof Numeric
$bool instanceof Boolean
$str instanceof String
$array instanceof Array
This makes it possible not to use the is_*() functions.
It is desirable to conduct instanceof fully consistent with behavior
hinting casts, it would be logical and correct.
Just wanted to be able to use these classes (or interfaces) to create
their objects, these objects would pass inspection in hinting casts.