Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68985 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13415 invoked from network); 9 Sep 2013 22:27:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Sep 2013 22:27:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.172 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.172 mail-ob0-f172.google.com Received: from [209.85.214.172] ([209.85.214.172:36181] helo=mail-ob0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 95/FF-03199-C4B4E225 for ; Mon, 09 Sep 2013 18:27:25 -0400 Received: by mail-ob0-f172.google.com with SMTP id er7so6509616obc.31 for ; Mon, 09 Sep 2013 15:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=89HW+7us+c7Z/usJEodKASsyZO/el+jYEhdvHMjrL3A=; b=1JhKWX0NtodHNk04woLUW2BSdiFPMfmfVw/oESy98CDZ6Jp1ubuMDNi2STynmTKc8C x5Qi2Gy/pS47tt6uV1896opQJXOYVrbxFGUCxhCSw3VIx83M8gQLPe/kGEnFbpGOpqkN 4U6SXP3lHUMdyd1Shi7vnax/45a110hX8AxUT0SbkOHyYbk3PBNg/bf1OJzsugS2WgUy fKrF5fsNYlwz3CNRvAECJmNvaXF1Aoa8gobnKYM1L4YR77M3KwUHnEdqUvnK+dqx67FL +LgCyraSAT7jo4feaQI+LMuMLAlMQuAKoPXm7EhVXYfNK1t/WsUbbDgStuQq+iDDqTSq VBlQ== MIME-Version: 1.0 X-Received: by 10.60.102.237 with SMTP id fr13mr12805015oeb.20.1378765642370; Mon, 09 Sep 2013 15:27:22 -0700 (PDT) Received: by 10.182.98.8 with HTTP; Mon, 9 Sep 2013 15:27:22 -0700 (PDT) In-Reply-To: References: Date: Tue, 10 Sep 2013 00:27:22 +0200 Message-ID: To: Daniel Macedo Cc: PHP internals Content-Type: multipart/alternative; boundary=089e011830665792e704e5fae470 Subject: Re: [PHP-DEV] Re: [RFC] Named parameters From: nikita.ppv@gmail.com (Nikita Popov) --089e011830665792e704e5fae470 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Sep 9, 2013 at 9:39 PM, Daniel Macedo wrote: > Nikita, > > I agree with your views, although, I think your last suggestion comes > close to being close to some sort of weird method overloading (the way > I understood it). > Uh, I think this is a misunderstanding caused by my bad phrasing. I'll try to clarify: class A { public function foo($oldBar) { ... } } class B extends A { public function foo($newBar) { ... } } $b->foo(oldBar => $xyz); Here `$b->foo()` will call `B::foo()`, *not* `A::foo()`. The thing about looking at the parameter names of the parent methods is just to make sure calls are compatible with the parameter names of parent methods, even if those names were changed during inheritance. We do not actually call the parent method, we just borrow the parameter name from there. In fact I'm not sure if the other way around should be the norm; where > we'd force the dev to implement the *same* args as the parent (like it > is now: i.e. type hinting, same signature, etc); even if it's just to > do an unset($oldbar) inside something like B::foo($newBar, $oldBar = > NULL) Yes, throwing an error during the signature validation is the "right" thing to do from a theoretic point of view. The issue is just that it breaks old code which didn't make sure that parameter names between parent and child lined up. "Break" is a bit too much here as it would still run, just throwing an E_STRICT. This is what I'd like to go for, but others disagree so I tried to offer an alternative solution. Nikita --089e011830665792e704e5fae470--