Re: Reviving scalar type hints
| From: | Pavel Kouřil | Date: | Mon, 16 Feb 2015 19:11:39 +0000 |
| Subject: | Re: Reviving scalar type hints | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82878@lists.php.net to get a copy of this message | ||
On Mon, Feb 16, 2015 at 5:42 PM, François Laupretre <francois@php.net> wrote:
> Hi,
>
> - the fact that the RFC supports single types only, like the previous 'return type'
> RFC. While it is easier to implement, it opens several issues as multiply-typed arguments are an
> integral part of the PHP language (mostly completeness and compatibility with internal function
> hinting). If we want to support multiple types the same way for internal and userspace functions, we
> must extend the ZPP layer to support it.
>
> - the mechanism to check for type hints on internal functions, while easy to implement, is not
> sufficient, as a lot of internal functions get a bare zval from the parsing system and then convert
> it by themselves. With the proposed mechanism, there's no possible hinting on such argument,
> which will make the implementation different from the documentation. Even if the check is done by
> the function body, it won't be done in a consistent way with type hinting checks and won't
> raise a similar error. As most cases are related to multiply-typed args, the solution is in adding
> multiply-typed support to ZPP. Multiply-typed support needs to redefine scalar conversion rules, to
> take care of the target type being a combination of single types.
>
Hello,
I know this is probably a pretty unpopular opinion in PHP (based on
the replies I got in the other thread), but different values for
parameters should be IMHO solved by method overloading and such.
Regards
Pavel Kouril