> -----Original Message-----
> From: Alain Williams [mailto:addw@phcomp.co.uk]
> Sent: Wednesday, July 16, 2014 11:17 AM
> To: internals@lists.php.net
> Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening)
>
> On Wed, Jul 16, 2014 at 09:31:46AM +0100, Rowan Collins wrote:
>
> > Now, one form of compromise is to use variants of the syntax, such as...
> >
> > function foo((int) $bar)
> > function foo(-int $bar)
> > ...
>
> A slight tangent, but *if* this sort of syntax is adopted we need to think what
> will happen when someone puts a class name in there instead of a basic type.
>
> I would suggest that it be a compile error of some sort if the 'type' is
> anything other than int, float, .... The only one that may make sense is
>
> function foo((array) $bar)
>
> If $bar is not an array it would make an array containing one element with value $bar.
>
> --
> Alain Williams
> Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
> +44 (0) 787 668 0256 http://www.phcomp.co.uk/
> Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
> #include <std_disclaimer.h>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
In case this RFC should go with a compromise and introduces two syntax (one for strict check, one
which includes
casting) it might be worth considering to use the same syntax as TSPHP. TSPHP has introduced a cast
modifier also for
function/method parameters which has the effect, that actual parameters are casted to the formal
parameter type if
necessary and applicable:
https://tsphp.ch/wiki/display/TSPHP/cast+modifier