Re: [RFC] Skipping parameters take 2
| From: | Marc Bennewitz | Date: | Fri, 16 Jan 2015 19:46:17 +0000 |
| Subject: | Re: [RFC] Skipping parameters take 2 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80660@lists.php.net to get a copy of this message | ||
Hi Robert
Am 16.01.2015 um 11:04 schrieb Robert Stoll:
Hi Stas,if there is no parent you have the following options: * Syntax error (I prefer) * If defined use from interface-----Ursprüngliche Nachricht----- Von: Stanislav Malyshev [mailto:smalyshev@gmail.com] Gesendet: Mittwoch, 14. Januar 2015 21:26 An: Marc Bennewitz; internals@lists.php.net Betreff: Re: [PHP-DEV] [RFC] Skipping parameters take 2 Hi!it's possible to doIs it possible to use the default parameter on inheritance? class Bar {It's not part of the original proposal, and I'm not sure how easy it would be to implement, but it sounds like a nice extension, I didn't think about it. Since the RFC is already in vote, I won't change it now, but I'll look into iffunction foo($a='a', $b='b') {}} class Baz extends Bar {function foo($a=default, $b=default) { // do something parent::foo($a, $b); }}it, and if the RFC is accepted, and it proves possible, I'll propose it separately. -- Stas Malyshev smalyshev@gmail.comThis would be quite a nice feature, even if this RFC does not pass. Just as hint, there are ambiguous case which need to be considered: interface A{ function foo($a=1); } interface B{ function foo($a="hi"); } class C implements A, B{ function foo($a=default){} //what would be the default value? } Cheers, Robert The default value have be the one of the parent.
* If ambiguous:
* Syntax error
* Choose one (bad in my opinion)
Marc