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 <lisachenko...@gmail.com>: > 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 <le...@php.net>: > >> On Mon, Aug 22, 2016 at 5:17 AM, Nicolas Grekas < >> nicolas.grekas+...@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 >> > >