Re: [RFC] Scalar Type Hints

From: Date: Fri, 02 Jan 2015 00:21:18 +0000
Subject: Re: [RFC] Scalar Type Hints
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-80075@lists.php.net to get a copy of this message
Hi Stas, > On 2 Jan 2015, at 00:15, Stanislav Malyshev <smalyshev@gmail.com> wrote: > > Hi! > >> 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. > > Breaking ZF2 and all software built on it is not "some breakage", it's a > serious issue which would produce a big barrier for PHP 7 migration. And > looks like there are more frameworks that do the same. This would be a > barrier to PHP 7 adoption, and note that is even for people that > couldn't care less for scalar typing. We'd find ourselves in python 3 > situation - where people would be glad to upgrade but they use library X > and it doesn't work and they have no idea how to fix it and they keep > all their development on the old version and the new one never catches > on. It'd be a shame if we spend all this effort on PHP 7 and get no > adoption since people can't run their existing code on it. I wouldn’t say it’s impossible to work around. You could rename the class to something which doesn’t conflict, but add a conditional class_alias for PHP 5. Codebases needing to work on both PHP 5 and PHP 7 can switch to the new name, codebases only needing to work on PHP 5 can stick with the old name. Does that sound workable? > >> 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. > > I'd rather make the hints case sensitive. In fact, of two BC breakages > making classes case sensitive may be the lesser one (I'm not a big fan > of either but at least the modern frameworks would probably all work and > if some code does not it's possible to auto-fix it). If they were case-sensitive, this would be inconsistent with other type names like array and callable. Thanks! -- Andrea Faulds http://ajf.me/

« previous php.internals (#80075) next »