Re: What do we need strict scalar type hints for?

From: Date: Thu, 05 Feb 2015 00:37:09 +0000
Subject: Re: What do we need strict scalar type hints for?
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi,

On Thu, Feb 5, 2015 at 2:06 AM, Stanislav Malyshev <[email protected]> wrote:
> Hi!
>
>>  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.
>
> That is contrary to the nature of PHP as it has been a weakly typed
> language for 20 years. I think it would be a big mistake to change one
> of the basic concepts of the language, that has worked pretty well
> judging from it adoption.

Adding another concept, not changing the existing ones. And really,
it's just simplifying what is already present via is_<typename>()
runtime checks, making our lives a little bit easier.

Though, I should re-iterate - I'm not in favor of picking just one of
the two possibilities.

> Especially given that all internal functions
> do not and will not work this way. Unless you propose make internal
> functions work this way too, in which case it'd be much better to change
> the name of the project, because there won't be much left that connects
> it to prior PHP and you can pretty much forget about BC.

Cheers,
Andrey.


Thread (78 messages)

« previous php.internals (#81849) next »