On 6/3/2016 5:13 PM, Andrea Faulds wrote:
> The RFC uses simple rules, but the resulting behaviour is complex.
> 
> PHP's weak typing rules are complicated enough as they are, and cause
> enough problem, without the addition of yet more rules, this time for
> how weak typing should work within union types.
> 
> I don't think 2 days is enough time to discuss this before voting on it.
> 

I actually agree with Andrea on this. There are too many side effects
that are endlessly hard to cover; even if we put all our brain power
together.

I would actually propose to make them always strict. It should not be a
problem for people to simply cast them to the right type. Maybe it even
helps to prevent that people overuse union types (which I am a bit
afraid of too but the feature is too useful). In the end, anyone who
does not like it can always resort to using no type hint at all as they
could in the past.

I know that Bob already said that it is a no go but I do not quite agree
here.

That being said, there is another possible approach. Do nothing in weak
mode.

This might sound weird but the fact that the engine will coerce the
variables anyways as needed would help. Any union type would be mixed
again, like it always was up until now. A problem every PHP developer
knows about and knows how to handle.

In the end it is about relying on super type behavior. If I accept
float|int|string than I should only perform actions on them that all of
them support and I have to check the actual type anyways if I want to
change my behavior based on the specific type. Hence, I can also error
out if I do not receive the type I was expecting. As we are already
doing. :)

-- 
Richard "Fleshgrinder" Fussenegger

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to