Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89031 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58949 invoked from network); 2 Nov 2015 09:23:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Nov 2015 09:23:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.181 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.181 mail-wi0-f181.google.com Received: from [209.85.212.181] ([209.85.212.181:36733] helo=mail-wi0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/91-42726-A9B27365 for ; Mon, 02 Nov 2015 04:23:38 -0500 Received: by wicfx6 with SMTP id fx6so45423840wic.1 for ; Mon, 02 Nov 2015 01:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=TV6EYJFyN3VSFsj7BqbvBoKMzKeIvVVP3S/SsCmJ0tc=; b=AH/WDSvd72f1uFfOyCQg0KhhX75Cnmc4ZYVqloshWGIIXFoNOlAMFyMWcg3Iw00+vF B6V9NTVHkeeU0dKFpGHAnmLbHkDG80xCiWMqaRJFFeETmQGK3bk0sIWzoXSrIZeCkrIb BbNbW1bkBP8AP32fScRXGiVbk06OOLUGLR/AtMLTpM45PyKoAYzBTQqHbho5TrgPBXfu zJ5aUtljl8Rmi/jJFmXKBXayhaeg0y23kQF3M4xzy04rZbGI9xpH4G50um70zN0qgOM3 uFx/S1lYp/1wk2KNteSUN8H9ODxAhgL2ohhni9Zg+FFTEwxKAprH6swZJ9bSQzSprp3E cHRQ== X-Received: by 10.195.13.38 with SMTP id ev6mr22161352wjd.150.1446456214704; Mon, 02 Nov 2015 01:23:34 -0800 (PST) Received: from [192.168.0.136] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id jq10sm14528872wjc.37.2015.11.02.01.23.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Nov 2015 01:23:33 -0800 (PST) To: internals@lists.php.net References: Message-ID: <56372B62.1000206@gmail.com> Date: Mon, 2 Nov 2015 09:22:42 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [Question] Variadic method signature compatibility between 5.6 and 7.0 From: rowan.collins@gmail.com (Rowan Collins) Alexander Lisachenko wrote on 01/11/2015 21:49: > class Foo { > public static function test($bar = null) { > var_dump(func_get_args()); > } > } > > class Baz extends Foo { > public static function test(...$args) { > parent::test(...$args); > } > } [...] > From userland point of view, these signatures should be compatible, so I > decided to check this behavior, was it intended or not. Should they? func_get_args() can be used to simulate any function signature, so you could equally say that the following are "compatible": class Foo { public static function test($foo, $bar, $baz) { } } class Baz extends Foo { public static function test() { list($foo, $bar, $baz) = var_dump(func_get_args()); parent::test($foo, $bar, $baz); } } Clearly, from the language's point of view, class Baz is missing the parameters in its function signature that Foo specifies, so the warning seems perfectly correct to me. In your example, you've replaced a single optional parameter ($bar = null) with a specification of variadic parameters (...$args); these are clearly not interchangeable, so again, the signature is different. Regards, -- Rowan Collins [IMSoP]