Re: BC break: ReflectionMethod::invoke() expects parameter1to be object, string given
| From: | Lauri Kenttä | Date: | Tue, 23 Aug 2016 18:19:43 +0000 |
| Subject: | Re: BC break: ReflectionMethod::invoke() expects parameter1to be object, string given | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95421@lists.php.net to get a copy of this message | ||
On 2016-08-23 18:45, Alexander Lisachenko wrote:
2016-08-23 18:05 GMT+03:00 Lauri Kenttä <lauri.kentta@gmail.com>:Ok, so I was wrong about it being impossible. Sorry about that. However, if you look at that example, does it look good and solid? It looks more like a weird hack to me. So I stand by my words: if there's a legitimate use for calling parent static methods with child context, there should also be simpler ways than reflection or strange closure hacks for doing it. There should be a syntax like ChildClass::ParentClass::method(), or at least call_user_func(["ChildClass", "ParentClass", "method"]), or call_user_func(["ChildClass", "ParentClass::method"]), since the ParentClass can be considered a qualifier for the method name. -- Lauri KenttäCould you do it without reflection, then? I don't think so. Thus, I think your "use case" is broken by design.FYI: This use case is used by Go! AOP Framework and AspectMock libraries that can mock even static methods in the classes, allowing testing legacy code and singletons. If you are interested in how it works, then you could look at this example: https://3v4l.org/TbS5V