Hey Stas, > On 31 Dec 2014, at 21:12, Stanislav Malyshev <smalys...@gmail.com> wrote: > > 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.
Glad you like 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). Yeah, it’s a problem. I think some breakage here is inevitable, unfortunately. Some of the classes with these names are stand-ins for scalar type hints, so that code can “just” migrate to using actual hints. But this doesn’t apply to all of them. We could choose to simply not prohibit them as class names, but that creates a weird inconsistency where you can make ‘class Integer’ yet ‘function foo(Integer $a)’ hints against the integer type, not your class. Type hints are very widely used, so I doubt this would help anyone, and we’d still be breaking existing code type hinting against such classes. There’s not much we can do really. I suppose there is one positive outcome, in that hopefully when broken code is updated to work, it might have more descriptive class names. :) > 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…) We could rephrase it, but I don’t think it’s that bad. Once scalar hints are in, you won’t get that error any more. I think it could be worse as errors go, at least it distinguishes semi-clearly between objects (“instance of integer”) and other types (“integer”). Thanks! -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php