On Sat, 23 Mar 2019 at 20:17, dj.drezyna <dj_drez...@wp.pl> wrote:
>
> I wish have opportunity to set types not only like:   function a(): string {} 
>  or  function b(): ?string {}
> but also as:  function c(): string | int {}  or  function d(): ?string | 
> ?array {}// all of them should mark
> that null is accepted.

Looks like you're asking for union types. There was an RFC about this
before but it didn't pass, I don't know why.

https://wiki.php.net/rfc/union_types

I would also like to see union types added, as I can't type hint most
of my code in absence of them.

Regarding the type coalescing problem noted in that RFC, my solution
to that would be to do noting. If a function accepts float or int, it
should just pass either through unchanged. Passing any other type
should be an error without an explicit cast IMO.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to