<?php
$anon = function($arg1, $arg2 = 2) {
var_dump($this->mine, $arg1, $arg2);
};
class Me {
protected $mine = 8;
}
$me = new Me;
$args = [4, 2];
// This is ugly, and doesn't take a variable number of args
$anon->call($me, $args[0], $args[1]);
// This doesn't exist =(
// $anon->apply($me, $args); // We took .bind() and .call() from JS, why not .apply()?
// This is ugly too, but takes a variable number of args
call_user_func_array(array($anon, 'call'), array_merge(array($me), $args));