On Tue, Aug 23, 2016 at 2:56 PM, Alexander Lisachenko <lisachenko...@gmail.com> wrote: > > 2016-08-23 14:51 GMT+03:00 Christoph M. Becker <cmbecke...@gmx.de>: >> >> I suggest to deprecate all other types than NULL as first arg for static >> methods, because passing an int, for instance, makes even less sense as >> Rowan has already pointed out elsewhere in this thread. > > > > Alternative suggestion (vote for Julien's patch): use first argument as a > string with LSB scope name, see my message from late 2013 year: > http://markmail.org/message/ogeh33jedumgo5lx. > > I agree, that all other types don't make any sense. So my suggestion is > following: for dynamic methods it should accept object or null. Null can > mean that we want to unbind the method from the object and maybe call it > like a closure? (just compare this with Closure::bindTo behaviour). For > static methods this could be object (why not - it will be ignored), string > (in this case it will be a scope name if we want to call parent method with > preserving Late Static Binding) or just null (null will be equal to the > string with object class name) > > Thoughts? >
It makes no sense to change the scope of the method. A method is not a closure. A method is bound to a class , a closure is by default unbound. A method cannot be unbound. A method cannot change from one class to another. This : class A { public static function foo() { } } class B extends A { public static function foo() { } } $a = new reflectionMethod('A', 'foo'); $a->invoke('B'); would lead to the exact equivalent as this with my patch : $b = new reflectionMethod('B', 'foo'); $b->invoke(); So I don't see why we should change and patch the code to support such a strange use case ... If you want to call B's foo , create a ReflectionMethod from B, not from A. Julien -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php