X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiContinuationManager.php;h=6601fb7463e18b95c19bf8dc17d5c08b05e6dba2;hb=81fddcf9e4ff1a66f107260628736788f4601e08;hp=354f4e7de10105003e5588a301b674501abbcf8d;hpb=6b1a173f07f1a04188735f4688ce6335da14c3b7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiContinuationManager.php b/includes/api/ApiContinuationManager.php index 354f4e7de1..6601fb7463 100644 --- a/includes/api/ApiContinuationManager.php +++ b/includes/api/ApiContinuationManager.php @@ -26,31 +26,32 @@ class ApiContinuationManager { private $source; - private $allModules = array(); - private $generatedModules = array(); + private $allModules = []; + private $generatedModules = []; - private $continuationData = array(); - private $generatorContinuationData = array(); + private $continuationData = []; + private $generatorContinuationData = []; - private $generatorParams = array(); + private $generatorParams = []; private $generatorDone = false; /** * @param ApiBase $module Module starting the continuation * @param ApiBase[] $allModules Contains ApiBase instances that will be executed * @param array $generatedModules Names of modules that depend on the generator + * @throws UsageException */ public function __construct( - ApiBase $module, array $allModules = array(), array $generatedModules = array() + ApiBase $module, array $allModules = [], array $generatedModules = [] ) { $this->source = get_class( $module ); $request = $module->getRequest(); $this->generatedModules = $generatedModules ? array_combine( $generatedModules, $generatedModules ) - : array(); + : []; - $skip = array(); + $skip = []; $continue = $request->getVal( 'continue', '' ); if ( $continue !== '' ) { $continue = explode( '||', $continue ); @@ -136,7 +137,7 @@ class ApiContinuationManager { } $paramName = $module->encodeParamName( $paramName ); if ( is_array( $paramValue ) ) { - $paramValue = join( '|', $paramValue ); + $paramValue = implode( '|', $paramValue ); } $this->continuationData[$name][$paramName] = $paramValue; } @@ -151,7 +152,7 @@ class ApiContinuationManager { $name = $module->getModuleName(); $paramName = $module->encodeParamName( $paramName ); if ( is_array( $paramValue ) ) { - $paramValue = join( '|', $paramValue ); + $paramValue = implode( '|', $paramValue ); } $this->generatorContinuationData[$name][$paramName] = $paramValue; } @@ -166,10 +167,10 @@ class ApiContinuationManager { /** * Fetch continuation result data - * @return array Array( (array)$data, (bool)$batchcomplete ) + * @return array [ (array)$data, (bool)$batchcomplete ] */ public function getContinuation() { - $data = array(); + $data = []; $batchcomplete = false; $finishedModules = array_diff( @@ -192,18 +193,18 @@ class ApiContinuationManager { $data += $kvp; } $data += $this->generatorParams; - $generatorKeys = join( '|', array_keys( $this->generatorParams ) ); + $generatorKeys = implode( '|', array_keys( $this->generatorParams ) ); } elseif ( $this->generatorContinuationData ) { // All the generator-using modules are complete, but the // generator isn't. Continue the generator and restart the // generator-using modules - $generatorParams = array(); + $generatorParams = []; foreach ( $this->generatorContinuationData as $kvp ) { $generatorParams += $kvp; } $data += $generatorParams; $finishedModules = array_diff( $finishedModules, $this->generatedModules ); - $generatorKeys = join( '|', array_keys( $generatorParams ) ); + $generatorKeys = implode( '|', array_keys( $generatorParams ) ); $batchcomplete = true; } else { // Generator and prop modules are all done. Mark it so. @@ -214,10 +215,10 @@ class ApiContinuationManager { // Set 'continue' if any continuation data is set or if the generator // still needs to run if ( $data || $generatorKeys !== '-' ) { - $data['continue'] = $generatorKeys . '||' . join( '|', $finishedModules ); + $data['continue'] = $generatorKeys . '||' . implode( '|', $finishedModules ); } - return array( $data, $batchcomplete ); + return [ $data, $batchcomplete ]; } /**