Re: [RFC] Scalar Type Hints v0.2
| From: | Dennis Birkholz | Date: | Thu, 15 Jan 2015 15:25:24 +0000 |
| Subject: | Re: [RFC] Scalar Type Hints v0.2 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80554@lists.php.net to get a copy of this message | ||
Hello together,
I have followed the discussion from the outside (as I am not to vote
here) but I am a (not representative) PHP developer.
I think the main problem here is that you mix two things up:
1. Scalar type hints for functions
2. Conversion rules
From what I have read, most of you agree that scalar type hints for
functions are really useful. If you define function foo(int $i) you
don't want is_int-checks and throw InvalidArgumentExceptions.
The real controversy is about what variables can be passed to the type
hinted functions. And that falls into 2)
There seem to be two types of conversion currently present in the code:
- the one used for arguments of build-in/extension functions
max("1", 2.0);
- the one used for implicit conversion in php code
$i = "1" + 2.0;
The discussion now revolves around: which of both conversions is right
if I typehint my pure PHP function? Or are both wrong? I feel there
should be a separate RFC that addresses a unification of implicit
conversion rules and that matter should not be in the type hinting
discussion.
Thanks for listening,
Dennis Birkholz