Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95376 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98976 invoked from network); 22 Aug 2016 14:32:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Aug 2016 14:32:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=lisachenko.it@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=lisachenko.it@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.52 as permitted sender) X-PHP-List-Original-Sender: lisachenko.it@gmail.com X-Host-Fingerprint: 209.85.215.52 mail-lf0-f52.google.com Received: from [209.85.215.52] ([209.85.215.52:32850] helo=mail-lf0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/00-33251-5EC0BB75 for ; Mon, 22 Aug 2016 10:32:06 -0400 Received: by mail-lf0-f52.google.com with SMTP id b199so79353605lfe.0 for ; Mon, 22 Aug 2016 07:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ogey/wDFLu2TdQvOkDw/+MbOIcS7Yra7+aIu4kTHJQQ=; b=JNzkKNdKTq3ED5b3Rag3VfZ7kfUWUie9u+AEF46gLDBOvq9DyWQ0T2U/MQJ2XKjcNP 2MnSfYqawrt3P539674R24QgbYgpV8Wd8GQ57/io2QrM54Z8HIOj2fETHEaCc78Jt/Hd toK1amQ4flOOaSp8AmKblGeYCY5q0i7K3HJSLESbMrRYYoegNwY/jc3oGw8UEoyavYx2 rM3pi9NQmfKF9ELkp6RH6vYTZkTfLCNwbKFEv6V2+FcXnIxiEgh7ZwkIGQK00vsTjmOY 4idoVSAddRyFfPijODqXwsjXiBKvR6zc59Jh+H0P1MrS6GnnhJ1oTHGgsr0Y248AvHwg 2g3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ogey/wDFLu2TdQvOkDw/+MbOIcS7Yra7+aIu4kTHJQQ=; b=Z1ippZVuWNMsWodg1IWSWt6gQpMZeXLMX7OjuTe+YSZ3AAV0GTb0JSMqgJaVRNMpzh bM5lQDz4ZM1rV9cvVkW9OgK15Le8JN84wRKNOEncWKyC1fyB6fWUyYwDR6ekOM1Qra+N 9OXQNtZ/ViGJsyTGzoMQfVBh2Uh5XgS8vo+fk0v/lOirS5CiaClTBDrVFAE3yTq4luxI yKG8qldhj43YPMur9Owbr0z2a6BEBDwWlV2TErOTVeBXyPaBkRp7P3H8nLAAk3cONcW8 R2XN+DlAOHG+7RWA+croi//CZujOowuohc9yY3lJIQyIfAE75QnDqeVAXpQdeU6JHVSH 64gw== X-Gm-Message-State: AEkoouuv2Do50WC/rSHRIzxDJhjinwsVC6SnD7uHix4pdK+ygZkpFpUhpLxjhXjmUFuz3vkVmoaVt6adAMLYKA== X-Received: by 10.46.1.149 with SMTP id f21mr5502113lji.25.1471876322909; Mon, 22 Aug 2016 07:32:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.196.144 with HTTP; Mon, 22 Aug 2016 07:32:02 -0700 (PDT) In-Reply-To: References: Date: Mon, 22 Aug 2016 17:32:02 +0300 Message-ID: To: Levi Morrison Cc: Nicolas Grekas , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11498684616186053aa9e936 Subject: Re: [PHP-DEV] BC break: ReflectionMethod::invoke() expects parameter 1 to be object, string given From: lisachenko.it@gmail.com (Alexander Lisachenko) --001a11498684616186053aa9e936 Content-Type: text/plain; charset=UTF-8 If the first argument for invoke() and invokeArgs() for static methods will be a string with compatible class name for the scope, then it can be used as a scope modifier (like second argument for Closure::bind($instance, $scopeClassName)) 2016-08-22 17:29 GMT+03:00 Alexander Lisachenko : > Hello, there is one more issue with ReflectionMethod::invoke() for static > methods: it's impossible to call an overridden parent static method and > preserve a scope information: > > // https://3v4l.org/ASntq > > class foo > { > static function bar() > { > echo self::class, ' vs ', static::class, PHP_EOL; > } > > static function bar1() > { > echo self::class, ' vs ', static::class, PHP_EOL; > } > } > > class baz extends foo > { > static function bar() > { > echo self::class, ' vs ', static::class, PHP_EOL; > } > } > > $r = new ReflectionClass('baz'); > $m = $r->getMethod('bar1'); // without overriden method - it's ok, our > static scope is preserved > $m->invoke(null); // foo vs baz > > $r = new ReflectionClass('baz'); > $m = $r->getMethod('bar'); // with overriden method it's impossible to > call parent static method, no way to specify a scope. > $m->invoke(null); // baz vs baz > > // how to statically call the parent static method bar() with scope == > baz?? > > 2016-08-22 17:00 GMT+03:00 Levi Morrison : > >> On Mon, Aug 22, 2016 at 5:17 AM, Nicolas Grekas < >> nicolas.grekas+php@gmail.com> wrote: >> >> > Hello, >> > >> > now that the BC break on ReflectionType has been reverted, another one >> > remains in ReflectionMethod::invoke(): >> > >> > the method doesn't accept a string as first argument anymore, see e.g.: >> > >> > https://3v4l.org/pImmv >> > >> > As you can see, this worked since 5.0 and even in HHVM. >> > >> > It would be great to fix this BC break please. >> > >> > Regards, >> > Nicolas >> > >> >> According to the [documentation][1] it requires an object. If the >> documentation has not been altered recently to make it this way then I'm >> inclined to keep the backward compatibility break. Your example uses a >> static method - you should be passing null and not the name of the class >> (this is also in the documentation). >> >> [1]: http://php.net/manual/en/reflectionmethod.invoke.php >> > > --001a11498684616186053aa9e936--