Re: [RFC] [PRE-VOTE] Union types

From: Date: Mon, 13 Jun 2016 12:36:41 +0000
Subject: Re: [RFC] [PRE-VOTE] Union types
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  Groups: php.internals 
Request: Send a blank email to internals+get-93935@lists.php.net to get a copy of this message
On 04.06.2016 at 16:37, Bob Weinand wrote: >> Am 4.6.2016 um 16:17 schrieb Christoph Becker <cmbecker69@gmx.de>: >> >> On 04.06.2016 at 14:15, Bob Weinand wrote: >> >>>> Am 04.06.2016 um 13:45 schrieb Niklas Keller <me@kelunik.com>: >>>> >>>> For Aerys\Host it could also be solved with an interface that just doesn't >>>> have any methods. With the disadvantage of callable not being in the same signature anymore. >>> >>> Additionally, this is only possible if you are actually in control on these classes and >>> can change them. If you pull them from a library, no chance. >> >> In which case it might make sense anyway to use adapters. > > For which you then need an adapter for each and every combination of interface (power set > without empty set; 2^n - 1 - 15 adapter classes for 4 interfaces). > That’s not a practical solution here. After having a closer look at the referenced code[1], I agree. However, in this case it would still be possible to avoid overloading the function by having a dedicated function for each type (i.e. useCallable(), useMiddleware() etc.) That doesn't appear bad to me. [1] <https://github.com/amphp/aerys/blob/2a4d626fb1b8b8ac9d91711085c04eaabdec7768/lib/Host.php#L87> -- Christoph M. Becker

« previous php.internals (#93935) next »