Re: Re: Improving PHP's type system

From: Date: Sun, 17 Apr 2016 01:29:56 +0000
Subject: Re: Re: Improving PHP's type system
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to internals+get-92373@lists.php.net to get a copy of this message
On Sat, Apr 16, 2016 at 5:06 PM, Ryan Pallas <derokorian@gmail.com> wrote: > On Sat, Apr 16, 2016 at 4:10 AM, Bastian Schneider < > bastian.schneider@commerce-plus.com> wrote: > > > > > Just a quick thought. I would prefer something like > > > > union Iterable { > > use array; > > use ArrayAccess; > > use Traversable; > > } > > > > function bla(Iterable $iterable) { > > foreach($iterable as $element) {} > > } > > > > Primitives like string, float, bool or int are not allowed in union. Only > > classes, interfaces and array. I doesn't see any benefit in combining > > string with int or int with float in one union. > > > > Here's an example that shows combining scalar maybe useful: > > union Numeric { > use int; > use float; > } > > Something I would very much like to use where types are allowed. Could also be used for solving the issue of coercing: union Numeric { use int; use float; use string as float; } Thoughts? - Davey

« previous php.internals (#92373) next »