Changed closure to capital word Closure in doc and type hint, also changed callback in docs to callable Change-Id: I52c8e8f13d38a837052101c38b9986be780ca057
29 lines
513 B
PHP
29 lines
513 B
PHP
<?php
|
|
|
|
/**
|
|
* Deferrable Update for closure/callback
|
|
*/
|
|
class MWCallableUpdate implements DeferrableUpdate {
|
|
/**
|
|
* @var Closure|callable
|
|
*/
|
|
private $callback;
|
|
|
|
/**
|
|
* @param callable $callback
|
|
* @throws MWException
|
|
*/
|
|
public function __construct( $callback ) {
|
|
if ( !is_callable( $callback ) ) {
|
|
throw new MWException( 'Not a valid callback/closure!' );
|
|
}
|
|
$this->callback = $callback;
|
|
}
|
|
|
|
/**
|
|
* Run the update
|
|
*/
|
|
public function doUpdate() {
|
|
call_user_func( $this->callback );
|
|
}
|
|
}
|