Re: BC break: ReflectionMethod::invoke() expects parameter 1 to beobject, string given
| From: | Christoph M. Becker | Date: | Mon, 22 Aug 2016 15:32:48 +0000 |
| Subject: | Re: BC break: ReflectionMethod::invoke() expects parameter 1 to beobject, string given | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95379@lists.php.net to get a copy of this message | ||
On 22.08.2016 at 13:17, Nicolas Grekas wrote:
> 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.
The BC break is caused by implementing feature requrest #38992
(<https://bugs.php.net/bug.php?id=38992>),
which has been posted nearly
10 years ago.
My analysis as posted in the bug report:
| Actually, the first parameter to ReflectionMethod::invoke() is
| completely ignored, if the method is a static method, see
| <https://3v4l.org/e9h1S>. A comment in the sources[1]
also
| explains the reasoning.
|
| This doesn't make any sense, however, because for static methods
| to be invoked, NULL is supposed to be passed as first parameter to
| ::invoke() as well as ::invokeArgs(). Allowing an arbitrary
| argument is confusing at best.
|
| Changing the behavior would introduce a BC break, though, so it
| appears to be reasonable to do that for PHP 7.1 only.
|
| [1]
<https://github.com/php/php-src/blob/PHP-7.0.10/ext/reflection/php_reflection.c#L3197-L3202>
If so desired, I can revert that commit, but I wouldn't be happy with
sticking with a completely unused parameter, which obviously has been
and still is misunderstood.
--
Christoph M. Becker