Re: [PHP-DEV] [VOTE][RFC] Scalar Type Hinting with Cast

[email protected] (Matthew Leverton)
Newsgroups php.internals
Message-ID <CAN=kQJc8dLknXjfCBG_h8NjwcWHWnrzt=iNi6J7eFTFcwaESaA@mail.gmail.com>
On Sun, Sep 14, 2014 at 3:22 PM, Derick Rethans <[email protected]> wrote:
> We can either have casting where:
>
>         function bar(int $foo) { }
>         bar("42");
>
> Means the same as:
>
>         function bar($foo) { }
>         bar((int) "42");
>
> Or we can have it as a strict cast, or we can have it like it currently
> (ie, not at all). I can live with those three options, but not an
> option where casting/checking does something different again.
>

I totally agree with this. I can understand any of the following:

1) function f(int $a) { } == f( (int) $a); -- with NO notices
2) function f(int $a) {} means $a must be exactly type int -- or
recoverable error is thrown
3) current behavior (no scalar type hints)

But a new set of rules that require a 23x7 table to describe what's
going on ... not a big fan.

--
Matthew Leverton
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.