Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95403 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88819 invoked from network); 23 Aug 2016 12:52:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Aug 2016 12:52:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.68 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 74.125.82.68 mail-wm0-f68.google.com Received: from [74.125.82.68] ([74.125.82.68:34720] helo=mail-wm0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/74-49014-1F64CB75 for ; Tue, 23 Aug 2016 08:52:02 -0400 Received: by mail-wm0-f68.google.com with SMTP id q128so18022596wma.1 for ; Tue, 23 Aug 2016 05:52:01 -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=AvHTuEI8bpGNC7ENCyRlWg8X+JrMBtrhQ7C/egOe0lQ=; b=YcotQ7J1PdViLivsLiIW0vvZMqREJ8Bio7ZSQOBuny6SFR7q6YUnZPy4qiUDz6VBiP HUpbPp84rBbs8fnUFXWChMOdDwab32X/H9rT66WC3xzY3cgEwgLiykDezbDXDtx6YOIq Ez3QnN90j0IHXghBhlly4Xw/w8GcvVlWsQByEBWd6BZb/xaQQ3PMAFFWg4hRhGMOO0eO 62GcmhgeDvYAz/H4yQO2MgEk1/upZUObxlDi+TX3PPaEBhNFgVCaB9Ha+nXL9nWU+xO1 TEBELa1S+sR+35lYvwiTNIXpwdKP+wEaNyiZuW4p87ZJ4JTLX85XkYJbjqnk6nuAfMsg VVrQ== 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=AvHTuEI8bpGNC7ENCyRlWg8X+JrMBtrhQ7C/egOe0lQ=; b=E3F30wheHVIU0X5SQ2bfshkSG5UPbSkRwReg0hx8rRsvdek4DZFB++PlXo5+ep4Iev o7WWn152XqK7rcwvLm5gLdPgKQJy+nAOba7ZpQAZ+6LB38xYfMDDUKTRoXV2CZHN2C14 KGO2oZ0EdMVKtwzmxt33T/fctDQGqnLXhFwpJ35EqTKXAoeQ1e25ujl8XkzBhugT4bTb wmMiHohxdPbNBbqXzsMp3BzDnfRmpfcpntcl96thW/aSIz4aVRV5rGu99oKbgZh/ufzF 5/7eosLxbftd3k9gmTu55LDY24X3Gd8/3XGqdSq9wqlVGpv/pGPc52lK3Le/ti8cSin5 2ruw== X-Gm-Message-State: AEkooutleBeRJK7WWk32uBqthjcQL1jQbXVTlLZk2N1cbHRCSlaB6tU3SUDUBds665QHEXx0PoBdY3CeZJk0dw== X-Received: by 10.28.39.133 with SMTP id n127mr20442191wmn.6.1471956718081; Tue, 23 Aug 2016 05:51:58 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.194.45.4 with HTTP; Tue, 23 Aug 2016 05:51:17 -0700 (PDT) In-Reply-To: References: <031a2bf1-1996-1144-2b85-e10a40be9514@gmail.com> <7b81c830-1d05-a4ac-4713-1bb67cbec12c@gmx.de> Date: Tue, 23 Aug 2016 14:51:17 +0200 X-Google-Sender-Auth: HDBFvpIt94Zcb8NTOV5hSQc8nqU 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 1:51 PM, Christoph M. Becker wr= ote: > On 23.08.2016 at 13:36, Julien Pauli wrote: > >> On Tue, Aug 23, 2016 at 10:30 AM, Christoph M. Becker wrote: >> >>> 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://githu= b.com/php/php-src/blob/PHP-7.0.10/ext/reflection/php_reflection.c#L3197-L32= 02]: >>>>> >>>>>> /* 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 ign= ore the >>>>>> * first parameter. >>>>>> * >>>>>> * Else, we verify that the given object is an instance of the c= lass.. >>>>>> */ >>>>> >>>>> A simple blame takes that comment back effectively unchanged to Nov 2= 005, when reflection was first moved to "ext/reflection": >>>>> https://github.com/php/php-src/blob/7cb0480d04933e3d27b75edf29822815a= 6108894/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 Schlossn= agle in July 2003: https://github.com/php/php-src/commit/84f5e4870e13f76a62= 23a0a937809092ae70d543#diff-cf9733a6fe0eeed1f5a44b59667967baR984 >>>>> >>>>> The inconsistency then comes in when invokeArgs is added by Marcus Bo= erger over a year later: https://github.com/php/php-src/commit/41b87ab486c2= 6f9b2d1bc315988b8e8271b6e06b >>>>> >>>>> The new methods made use of the (presumably new?) zend_parse_paramete= rs system, and specified the first argument as a mandatory object, which wa= s fixed a few days later to have an optional object, and a separate check w= hen it is required: https://github.com/php/php-src/commit/63b288c4646d405d0= edfb7657505b2acf5643514 >>>>> >>>>> Notably, the same comment completely ignoring the first parameter was= present 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 t= o be different, just different contributors at different times. It's also p= retty clear that the only thought put into the first argument with static m= ethods is "ignore it". >>> >>> ACK >>> >>>>> None of which really answers what the behaviour should be, in my opin= ion. 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 argumen= t 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 ju= st 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. Thank= s >>> 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/8735d6b72de0edc3b370245737c0f4f= 204fcbea0 >> >> 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. > > I suggest to deprecate all other types than NULL as first arg for static > methods, because passing an int, for instance, makes even less sense as > Rowan has already pointed out elsewhere in this thread. What about passing nothing ? $reflectionMeth->invoke(); Actually, this is not possible and a Warning: ReflectionMethod::invoke() expects at least 1 parameter, 0 given in %s on line %d is thrown. Should we keep that behavior as well ? Knowing that passing nothing, the function will get an IS_NULL zval. Julien