RE: [PHP-DEV] Reviving scalar type hints

From: Date: Tue, 17 Feb 2015 18:33:00 +0000
Subject: RE: [PHP-DEV] Reviving scalar type hints
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-82996@lists.php.net to get a copy of this message
> De : Lester Caine [mailto:lester@lsces.co.uk] > > My current practice up until now has been to use 'return false' when an > action failed, but the main return would be a number of records or > string of data. So you are now blocking that activity ... I'm reading to > right, but you are not thinking all possibilities through. But I think > I'm starting to see it broken already with the other changes to the core > :( I'm not returning 'IS_FALSE' so I'm probably going to have to change > the 'false' to '0' anyway so as to avoid the bool? Hi Lester, I am not blocking anything. My objective is to provide union types. Using union types, you will declare your return type as 'int|bool'. That's why I was pushing to integrate this feature in the first release. It will be done if we have enough time, but it is a lot to integrate in a discussion that must be quite short, as time is restricted. I am surely not thinking all possibilities :) but returning integer or false is usual and in scope. The solution is not to authorize (bool -> int) conversion (as it would have to support (bool -> anything)), but support 'int|bool', 'resource|bool', and similar syntax. So, the solution is completely different from the (int -> bool) question. Even, if we don't release union types in 7.0, it will be clearly stated that it is a required follow-up. That's not perfect but we do it as fast as we can and everyone is welcome to help. What does this mean in your case ? Just that, as long as the feature is not available, your function won't have an explicit return type. Period. And, please, don't change false to 0 ;). Regards François

« previous php.internals (#82996) next »