Is there a way to pass additional parameters to a callback function?
class Bar{
public function test(){
$count = 0;
$foo = new Class();
$foo->calling([$this, 'barFunction']);
}
public function barFunction($data, $count){
//...
}
I want Foo's calling method to pass data in and to also pass $count as the second parameter.
Here is an example with a closure instead of a parameter. If I use a closure I can pass $count in but in this case I need to use Bar's class function.
class Bar{
public function test(){
$count = 0;
$foo = new Class();
$foo->calling(function($data) use($count){
//..some work
});
}