On Mon, 14 Jul 2014, Andrea Faulds wrote: > > On 14 Jul 2014, at 15:38, Derick Rethans <der...@php.net> wrote: > > > I am worried about this big casting conversion matrix. New rules should > > not be invented, and the following should *always* be equivalent: > > > > function foo(typehint $var) > > > > vs: > > > > function foo($var) { > > $var = typehint $var; > > > > In general, I am not in favour of casting typehints, as it would be a > > different behaviour from the hard-check typehints that we already have > > for classes and arrays. > > I’ve talked about this before in this thread, but the justification > for differing in behaviour from array and class hints is that these > types are scalars (which PHP routinely juggles) and arrays and objects > are not scalar (and not routinely juggled). While we are indeed > casting, we’re only doing so where the conversion would be lossless. > Sure, it’s not a hard check, but it is still quite strict. I don’t > like the idea of completely strict type hints here, but I also don’t > think that completely loose type hints that cast and do zero > validation are for the best either. This RFC tries to strike a > compromise.
A compromise by adding more inconsistencies. I can buy the cast of scalars vs hint--of-complex types, but definitely not the introduction of a new group of casting rules. Keep it simple. cheers, Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug Posted with an email client that doesn't mangle email: alpine
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php