Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95393 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40106 invoked from network); 22 Aug 2016 21:40:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Aug 2016 21:40:17 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.66 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.66 mail-wm0-f66.google.com Received: from [74.125.82.66] ([74.125.82.66:34147] helo=mail-wm0-f66.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/17-33251-1417BB75 for ; Mon, 22 Aug 2016 17:40:17 -0400 Received: by mail-wm0-f66.google.com with SMTP id q128so15336241wma.1 for ; Mon, 22 Aug 2016 14:40:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:to:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=IsOsnoOxubpOKKX/3i8EGn1t7v8FgKPqBVDnX85eKBM=; b=uMTvePFaqmQHjShOWTxv2UnRNH6QaElft19s65ntSDU+7dx6acKI9JnhqvR5jNqJl3 ZSz53TBNJMeGzAG7sXBy5KFm7N+Tz1F2wWgEBzOqhC459ajCBb270xr8KWi1lYHqK7wr WtOyCU0MWzdeLlEyLA1aJHVlkpzfF3p9d5SCGj0dJcJPekj/752We3HUTTw8xC+cptLM y0VFl16bEJp2BdTaDZo+xon3KLHDayKtXzcNhWM/2PO17O3kxgUp8El6eJhl/V7AiRXn InFvDmzXxHVeZNcP5122d9JexXtgf9IcUD9x4nF+apPz+YP1gV27zwttwxcJBOagrWXR +e/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:references:from:to:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=IsOsnoOxubpOKKX/3i8EGn1t7v8FgKPqBVDnX85eKBM=; b=JW07pfEARl5WE0J0bOZa1VTv9AFuIkk0gKDS9fP4Phoe1Of+rvoKmFguWC24P4e0Pc qRUVMmrfEeBfuSh0FUedJMt8s7j3GZ2wOL1IIAiaAT3Fdd5nTm0/ocKN9YpgWG6qQcC8 UmHM/m6N3BCStUzHqFivqQE2o/ZMsGRErN2T57QgDmjczdRNuUpUKUTOmViWXQTV7YJ2 Wk2/kosP7LdvUD1GIp15v3nW0kNusFgD7MTdkQSi1EUVFRDdu2YeO1RKUe+xrXfKXvSD qsHqkVIZEBkEAtM/kqkDjkTs0m2tbP5tNlcVW6x37VTK2cmIRqEq7iktIORJwhoeatir 1K1g== X-Gm-Message-State: AEkoouuHnHP8i3/uSsvlvpyFD3Y9cttCPwyJqu2VDyOdE7zuR9JkmmxH2488VlkyV8i4uQ== X-Received: by 10.28.167.135 with SMTP id q129mr16417725wme.82.1471902013686; Mon, 22 Aug 2016 14:40:13 -0700 (PDT) Received: from [192.168.1.5] ([95.148.161.240]) by smtp.googlemail.com with ESMTPSA id jv9sm29655wjb.45.2016.08.22.14.40.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Aug 2016 14:40:12 -0700 (PDT) References: To: "internals@lists.php.net" Message-ID: <031a2bf1-1996-1144-2b85-e10a40be9514@gmail.com> Date: Mon, 22 Aug 2016 22:40:11 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.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] BC break: ReflectionMethod::invoke() expects parameter1 to be object, string given From: rowan.collins@gmail.com (Rowan Collins) On 22/08/2016 20:57, Levi Morrison wrote: > I think the ideal but difficult path forward is to find where it was > introduced and pray the commit log or something else will indicate the > behavior. OK, I'll bite. Christoph already linked to this comment in the source [https://github.com/php/php-src/blob/PHP-7.0.10/ext/reflection/php_reflection.c#L3197-L3202]: > /* In case this is a static method, we should'nt pass an object_ptr > * (which is used as calling context aka $this). We can thus > ignore the > * first parameter. > * > * Else, we verify that the given object is an instance of the class. > */ A simple blame takes that comment back effectively unchanged to Nov 2005, when reflection was first moved to "ext/reflection": https://github.com/php/php-src/blob/7cb0480d04933e3d27b75edf29822815a6108894/ext/reflection/php_reflection.c#L2163 Before that, it was in zend_reflection_api.c, and blames back to the rather general "more of Timm's implementation" committed by George Schlossnagle in July 2003: https://github.com/php/php-src/commit/84f5e4870e13f76a6223a0a937809092ae70d543#diff-cf9733a6fe0eeed1f5a44b59667967baR984 The inconsistency then comes in when invokeArgs is added by Marcus Boerger over a year later: https://github.com/php/php-src/commit/41b87ab486c26f9b2d1bc315988b8e8271b6e06b The new methods made use of the (presumably new?) zend_parse_parameters system, and specified the first argument as a mandatory object, which was fixed a few days later to have an optional object, and a separate check when it is required: https://github.com/php/php-src/commit/63b288c4646d405d0edfb7657505b2acf5643514 Notably, the same comment completely ignoring the first parameter was present in that first implementation of invokeArgs. So, it's pretty clear to me that there was no intention for the two to be different, just different contributors at different times. It's also pretty clear that the only thought put into the first argument with static methods is "ignore it". None of which really answers what the behaviour should be, in my opinion. We still have to decide 3 things: - Is there a compelling reason to change the current behaviour? - What error or behaviour should a string or other non-object argument give? - What error or behaviour should an object argument give? In my opinion, the best "fix", if something needs to change, would be to reject anything other than null; that anything else works appears to just be an oversight. Regards, -- Rowan Collins [IMSoP]