Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95400 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82045 invoked from network); 23 Aug 2016 11:37:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Aug 2016 11:37:33 -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 74.125.82.66 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 74.125.82.66 mail-wm0-f66.google.com Received: from [74.125.82.66] ([74.125.82.66:36064] helo=mail-wm0-f66.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/43-49014-D753CB75 for ; Tue, 23 Aug 2016 07:37:33 -0400 Received: by mail-wm0-f66.google.com with SMTP id i138so17689154wmf.3 for ; Tue, 23 Aug 2016 04:37:33 -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-transfer-encoding; bh=bSqgfDHXSgMycjZwTumMNWeJ2ElRPZwHX9ZR9TKbLTQ=; b=r+MCE70GDMyxFPFLPmHJuOA2SW8XhnsuKzR0kNETACmZ+YsIfjl0sLoqQUTLX8cJrs vOURV7gv3Lx9a0fLlZY/xcA1oNkfEEq6tmJ7VlO12iLg5fgztZV51QuCP0te2i5U6ew+ 5maoi60PF/CVNqY6Qrlr1dqnVaAtp3jecsHleEHV4JM+856Ln7t/NF2LmykjvqxFePjy n1s3JK+9LsURzOG41VowgkLpx8k+GUnxxoXOlOFxKmaU5hrB5dQtPL7E36QLBoX9JrUg PFOVFXBqzQEf+u+0sQTTt2EWZXPTcpbtrG1K5mXT+Cyeisp89i4f/NMLabyvWAsmhx97 PEiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=bSqgfDHXSgMycjZwTumMNWeJ2ElRPZwHX9ZR9TKbLTQ=; b=VSAnPhNZT9DilJJI9djgtm73vuwHpHKC9iJZv6bDFdWj1tzSuGvoKfudeHWvNyhnBo 8kpF7zspBUB9AdGTtZX81tHxe00foDbpjZiBplyIzdK/jTyBNr7j2kp4PeBIV7H1Ja10 lrdex+zdJzfNqulO16pMhswU8DiXY/Ad+PQTk6MehcEayCGrSf7Dr+8bKvsSB/DBnSJN kHDCSN3s56FsaVmjM5mAGv2BIb+VZUQH+1r1UZr3GP/Mz8j7/7QeSo/R5jmvh1P3dmmj Z7AQB7pMMenG5NUcbby1ScIBSI/6eWxlyO/D8dRU2t6idePS7YqvvGuoo8xYOZK4YjEj 31SA== X-Gm-Message-State: AEkoouuiTKU/9XkZsBiyQ1XvhjNL/3rRe2HWgVJNvnLcAr2rYJ52uzGPNUrUn0yoedSZd5Skw/NiVLPaCd2S1A== X-Received: by 10.28.39.133 with SMTP id n127mr20132220wmn.6.1471952250646; Tue, 23 Aug 2016 04:37:30 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.194.45.4 with HTTP; Tue, 23 Aug 2016 04:36:49 -0700 (PDT) In-Reply-To: <7b81c830-1d05-a4ac-4713-1bb67cbec12c@gmx.de> References: <031a2bf1-1996-1144-2b85-e10a40be9514@gmail.com> <7b81c830-1d05-a4ac-4713-1bb67cbec12c@gmx.de> Date: Tue, 23 Aug 2016 13:36:49 +0200 X-Google-Sender-Auth: Or_fNBjjxGACgqOpROXxc_FbsdY Message-ID: To: "Christoph M. Becker" Cc: Levi Morrison , Rowan Collins , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] BC break: ReflectionMethod::invoke() expects parameter1to be object, string given From: jpauli@php.net (Julien Pauli) On Tue, Aug 23, 2016 at 10:30 AM, Christoph M. Becker w= rote: > On 23.08.2016 at 00:25, Levi Morrison wrote: > >> On Mon, Aug 22, 2016 at 3:40 PM, Rowan Collins = wrote: >>> >>> 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 ignor= e the >>>> * first parameter. >>>> * >>>> * Else, we verify that the given object is an instance of the cla= ss.. >>>> */ >>> >>> A simple blame takes that comment back effectively unchanged to Nov 200= 5, when reflection was first moved to "ext/reflection": >>> https://github.com/php/php-src/blob/7cb0480d04933e3d27b75edf29822815a61= 08894/ext/reflection/php_reflection.c#L2163 >>> >>> Before that, it was in zend_reflection_api.c, and blames back to the ra= ther general "more of Timm's implementation" committed by George Schlossnag= le in July 2003: https://github.com/php/php-src/commit/84f5e4870e13f76a6223= a0a937809092ae70d543#diff-cf9733a6fe0eeed1f5a44b59667967baR984 >>> >>> The inconsistency then comes in when invokeArgs is added by Marcus Boer= ger over a year later: https://github.com/php/php-src/commit/41b87ab486c26f= 9b2d1bc315988b8e8271b6e06b >>> >>> 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 whe= n it is required: https://github.com/php/php-src/commit/63b288c4646d405d0ed= fb7657505b2acf5643514 >>> >>> Notably, the same comment completely ignoring the first parameter was p= resent in that first implementation of invokeArgs. > > Thanks for investigating on the history, Rowan! > >>> 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 pre= tty clear that the only thought put into the first argument with static met= hods is "ignore it". > > ACK > >>> None of which really answers what the behaviour should be, in my opinio= n. 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 t= o reject anything other than null; that anything else works appears to just= be an oversight. >> >> Anyone oppose to emitting E_DEPRECATED for a parameter other than an >> object or null? This opens up the possibility to use it for something >> no earlier than 8.0. > > That appears to be the most reasonable compromise presented yet. Thanks > Levi! I suggest to wait for Julian, though, who wrote: "I'll prepare a > patch exposing my ideas soon." All right. I was thinking something like this : https://github.com/jpauli/php-src/commit/8735d6b72de0edc3b370245737c0f4f204= fcbea0 But it makes no sense. It makes no sense to pass a class name as first param of invoke() , to target a specific function. Why not create the ReflectionClass instance using that latter so ? I'm OK to deprecate the first arg as a string, then remove such an usage in next major. I can make such a patch if consensus. Julien