class ScopedCallback {
/** @var callable */
protected $callback;
+ /** @var array */
+ protected $params;
/**
* @param callable $callback
+ * @param array $params Callback arguments (since 1.25)
* @throws Exception
*/
- public function __construct( $callback ) {
+ public function __construct( $callback, array $params = array() ) {
if ( !is_callable( $callback ) ) {
throw new InvalidArgumentException( "Provided callback is not valid." );
}
$this->callback = $callback;
+ $this->params = $params;
}
/**
*/
function __destruct() {
if ( $this->callback !== null ) {
- call_user_func( $this->callback );
+ call_user_func_array( $this->callback, $this->params );
}
}
}
protected $collateOnly = true;
/** @var array Cache of a standard broken collation entry */
protected $errorEntry;
+ /** @var callable Cache of a profile out callback */
+ protected $profileOutCallback;
/**
* @param array $params
public function __construct( array $params = array() ) {
$this->errorEntry = $this->getErrorEntry();
$this->collateOnly = empty( $params['trace'] );
+ $this->profileOutCallback = function ( $profiler, $section ) {
+ $profiler->profileOutInternal( $section );
+ };
}
/**
$this->profileInInternal( $section );
$that = $this;
- return new ScopedCallback( function () use ( $that, $section ) {
- $that->profileOutInternal( $section );
- } );
+ return new ScopedCallback( $this->profileOutCallback, array( $that, $section ) );
}
/**