Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69188 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71281 invoked from network); 18 Sep 2013 12:56:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2013 12:56:48 -0000 Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.52 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.212.52 mail-vb0-f52.google.com Received: from [209.85.212.52] ([209.85.212.52:35863] helo=mail-vb0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/F5-43258-F03A9325 for ; Wed, 18 Sep 2013 08:56:47 -0400 Received: by mail-vb0-f52.google.com with SMTP id f12so5274522vbg.11 for ; Wed, 18 Sep 2013 05:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=+aPTXHPRhXjbIZ1MygcTmRZ9s9CKScTA+HV0L0kiJSw=; b=XmcoW9c8QdEZMDiQ1GHgNKVL2h+1SLM2z685/6Q02TzY3j0eOZFrYOt859vZu5Jw3k khkw3L9sknU24Aia9aTt2XMQlWbOPUaiYo7wssdywBHZ/acyHj+ecxkqh15lC28BwwHb xWUfyAPOF0nGplCkwYaeX0GMd5t7J/+9Zj0/WJPzjr4fUCawQxwj3LFYpqCK49COtSSr EbyVUK6h0H0DOtWvs61OpeOSEhzNP+qnMuwAh1fvnmvVcasN8hLnbLHi6ibP0g4NUYMy D0paqXJ1z/xGGmy8yylGuJOcAf3u/Kn8gl1dKwkWknrplcNuD1C9Ya3/gspvDsKcCHcI cpGQ== X-Received: by 10.52.103.101 with SMTP id fv5mr391348vdb.31.1379509004823; Wed, 18 Sep 2013 05:56:44 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.220.73.197 with HTTP; Wed, 18 Sep 2013 05:56:04 -0700 (PDT) In-Reply-To: References: Date: Wed, 18 Sep 2013 14:56:04 +0200 X-Google-Sender-Auth: HdZ6rCdmWCzHkVbv20PHTaZ9NKA Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=047d7bacb98e326fc204e6a7f8f5 Subject: Re: [PHP-DEV] Signature compatibility: Number of arguments From: jpauli@php.net (Julien Pauli) --047d7bacb98e326fc204e6a7f8f5 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Aug 29, 2013 at 11:33 AM, Nikita Popov wrote: > Hi internals! > > This is a spinoff from the variadics thread. Quoting Stas: > > > I also think this: > > public function query($query, ...$params) > > public function query(...$params) > > should be legal too. > > This is a general issue in PHP that we might want to fix: Currently a > method A is not compatible with a method B if A has less arguments than B. > > E.g. both of the following are incompatible signatures: > > public function foo($bar) > public function foo() > > public function foo($bar = NULL) > public function foo() > I dont really agree. One could use reflection on the parameter, thus expecting it to be here on a child instance : class Foo { public function bar($arg = null) { } } class Foo2 extends Foo { public function bar() { } } $o = new Foo; /* Switching to Foo2 will lead to an Exception */ $r = new ReflectionParameter(array($o, 'bar'), 'arg'); echo $r->getName(); PS : I remember having a long discussion with Gustavo, some time ago, about LSP in PHP ; and we could not agree on some points, particularly concerning optional parameters. Julien.Pauli --047d7bacb98e326fc204e6a7f8f5--