Re: [PHP-DEV] make casts more strict in PHP 7
[email protected] (Park Framework)
| Newsgroups | php.internals |
|---|---|
| Message-ID | <CAPRqa+FbfSNb2BDoPj_OoUCdQ_hFzqr3KwDdvLOQ8=ggCsLJ=w@mail.gmail.com> |
> 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.