On Sun, Dec 24, 2017 at 3:34 PM, Fleshgrinder <p...@fleshgrinder.com> wrote:
> Hi Internals! > > I prepared a PR to add the `scalar` pseudo-type to PHP after the > discussions around adding a `mixed` pseudo-type. I strongly believe that > it makes sense to provide the most common primitive union types with > handy aliases even if we are going to add union types in the future to PHP. > > https://github.com/php/php-src/pull/2987 > > I added support for parameter type covariance and return type > contravariance to make it as useful in daily development as possible. > > I will provide the RFC write-up asap at: > > https://wiki.php.net/rfc/scalar-pseudo-type > 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