Re: [RFC] Scalar Type Hints
| From: | Stanislav Malyshev | Date: | Wed, 31 Dec 2014 21:12:43 +0000 |
| Subject: | Re: [RFC] Scalar Type Hints | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80031@lists.php.net to get a copy of this message | ||
Hi!
I like it, it's consistent and to the point. If we must have scalar
typed parameters (I'm not sure but if we do), IMO that's the way to do it.
The issue is the class names though. E.g. see:
https://github.com/ralphschindler/zf2-db/blob/master/research/ColumnType/Integer.php
and:
https://github.com/canaydogan/ObjectValidator/blob/master/src/ObjectValidator/Validator/Int.php
These are uppercase "I", but class names are not case-sensitive... So
we'll need to figure it out. Unfortunately, looking at github,
disallowing "class Int" looks like pretty bad idea. We can make it
lowercase-only, but this would be a bit weird since it's not sensitive
in all other places (unless we change that which is another huge can of
worms).
BTW, right now this code:
function foo(integer $a) { var_dump($a); }
foo(1);
produces this message:
Catchable fatal error: Argument 1 passed to foo() must be an instance of
integer, integer given
which is pretty confusing I'd say :) We'd probably want to rephrase that
message (yes, I know, patching all those tests yet again...)
--
Stas Malyshev
smalyshev@gmail.com