Re: What do we need strict scalar type hints for?
| From: | Dmitry Stogov | Date: | Wed, 04 Feb 2015 10:13:46 +0000 |
| Subject: | Re: What do we need strict scalar type hints for? | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-81800@lists.php.net to get a copy of this message | ||
This won't fit into "loosely-typed" PHP, and will lead to writing -
sin((float)$x).
We have this in PHP sources :) (in C)
Thanks. Dmitry.
On Wed, Feb 4, 2015 at 12:31 PM, Sebastian Bergmann <sebastian@php.net>
wrote:
> Am 04.02.2015 um 10:25 schrieb Dmitry Stogov:
> > Do you like the proposal with declare() switch?
>
> No, I do not like that.
>
> We are talking about adding support for scalars (string, integer, ...)
> to the list of optional type declarations already supported (array,
> callable, interface name, class name) by PHP. When a developer chooses
> to use a scalar type in the signature of a function or method then it
> should be enforced as strictly as the already supported types. It should
> be up the caller to perform explicit type casting when required.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>