On 12/24/2017 5:30 PM, Nikita Popov wrote: > I think this RFC could benefit from displaying some use-cases for this type > annotation. I can't recall any recent instance where I would have found > this specific type combination useful, though I'm sure there are good > examples. > > I also wonder whether in weak typing mode, scalar should also accept > __toString objects (and cast them to string), similarly to how a > bool|int|float|string union would behave. > > Nikita >
I will extend it with some examples. I guess that that would be useful in weak mode. Will try to hack it in. I am currently also working on another RFC that adds a `Convertible` interface with a single `into` method that has its return type set to `scalar` where objects can opt-in to become `scalar` compatible. Even in strict mode. The idea is that the object's `into` method is automatically called by the engine and the receiver gets the canonical `scalar` value that represents the object. This is specifically useful for value objects that often represent single `scalar` values in a type safe manner. -- Richard "Fleshgrinder" Fussenegger -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php