Re: BC break: ReflectionMethod::invoke() expects parameter1to be object, string given
| From: | Rowan Collins | Date: | Tue, 23 Aug 2016 13:11:25 +0000 |
| Subject: | Re: BC break: ReflectionMethod::invoke() expects parameter1to be object, string given | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95408@lists.php.net to get a copy of this message | ||
On 23/08/2016 13:56, Alexander Lisachenko wrote:
For static methods this could be object (why not - it will be ignored)Allowing a parameter and then completely ignoring it is what got us into this situation in the first place. Why does this... $a = new reflectionMethod('A', 'foo'); $a->invoke(new DateTime); ...make any more sense than this? $a = new reflectionMethod('A', 'foo'); $a->invoke(42); If you want to allow an object to be passed in, it should act the same way as a string - specify the binding context: $a = new reflectionMethod('A', 'foo'); $a->invoke(new B); // equivalent to $a->invoke('B'); It should also go through the same check as it would for a non-static method: must be an instance of the class being reflected. Regards, -- Rowan Collins [IMSoP]