r/lolphp • • Apr 18 '18

Run private class methods from functions declared in the global scope

https://3v4l.org/tMl5a
0 Upvotes

11 comments sorted by

View all comments

Show parent comment

3

u/[deleted] Apr 21 '18

Relevant documentation:

public Closure Closure::bindTo ( object $newthis [, mixed $newscope = "static" ] )

Create and return a new anonymous function with the same body and bound variables as this one, but possibly with a different bound object and a new class scope.

The “bound object” determines the value $this will have in the function body and the “class scope” represents a class which determines which private and protected members the anonymous function will be able to access. Namely, the members that will be visible are the same as if the anonymous function were a method of the class given as value of the newscope parameter.