X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Factions%2FCachedAction.php;h=32efc6842782abaf5a2e94bf296dc71cdbdc0812;hb=f43fa6f4f0e2cb60b8543daad661b48a3e0653a9;hp=bfdda7b9393372582128dc11cc072c634acbf93c;hpb=d514374a0062202d680af131a8479eace677be70;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/CachedAction.php b/includes/actions/CachedAction.php index bfdda7b939..864094de7a 100644 --- a/includes/actions/CachedAction.php +++ b/includes/actions/CachedAction.php @@ -58,7 +58,7 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { * If the cache is enabled or not. * * @since 1.20 - * @var boolean + * @var bool */ protected $cacheEnabled = true; @@ -66,7 +66,7 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { * Sets if the cache should be enabled or not. * * @since 1.20 - * @param boolean $cacheEnabled + * @param bool $cacheEnabled */ public function setCacheEnabled( $cacheEnabled ) { $this->cacheHelper->setCacheEnabled( $cacheEnabled ); @@ -78,14 +78,14 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { * * @since 1.20 * - * @param integer|null $cacheExpiry Sets the cache expiry, either ttl in seconds or unix timestamp. - * @param boolean|null $cacheEnabled Sets if the cache should be enabled or not. + * @param int|null $cacheExpiry Sets the cache expiry, either ttl in seconds or unix timestamp. + * @param bool|null $cacheEnabled Sets if the cache should be enabled or not. */ public function startCache( $cacheExpiry = null, $cacheEnabled = null ) { $this->cacheHelper = new CacheHelper(); $this->cacheHelper->setCacheEnabled( $this->cacheEnabled ); - $this->cacheHelper->setOnInitializedHandler( array( $this, 'onCacheInitialized' ) ); + $this->cacheHelper->setOnInitializedHandler( [ $this, 'onCacheInitialized' ] ); $keyArgs = $this->getCacheKey(); @@ -110,13 +110,13 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { * * @since 1.20 * - * @param {function} $computeFunction + * @param callable $computeFunction * @param array|mixed $args * @param string|null $key * * @return mixed */ - public function getCachedValue( $computeFunction, $args = array(), $key = null ) { + public function getCachedValue( $computeFunction, $args = [], $key = null ) { return $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ); } @@ -128,12 +128,13 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { * * @since 1.20 * - * @param {function} $computeFunction + * @param callable $computeFunction * @param array $args * @param string|null $key */ - public function addCachedHTML( $computeFunction, $args = array(), $key = null ) { - $this->getOutput()->addHTML( $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ) ); + public function addCachedHTML( $computeFunction, $args = [], $key = null ) { + $html = $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ); + $this->getOutput()->addHTML( $html ); } /** @@ -147,11 +148,12 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { } /** - * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry. + * Sets the time to live for the cache, in seconds or a unix timestamp + * indicating the point of expiry. * * @since 1.20 * - * @param integer $cacheExpiry + * @param int $cacheExpiry */ public function setExpiry( $cacheExpiry ) { $this->cacheHelper->setExpiry( $cacheExpiry ); @@ -165,11 +167,11 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { * @return array */ protected function getCacheKey() { - return array( + return [ get_class( $this->page ), $this->getName(), $this->getLanguage()->getCode() - ); + ]; } /** @@ -177,12 +179,11 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper { * * @since 1.20 * - * @param boolean $hasCached + * @param bool $hasCached */ public function onCacheInitialized( $hasCached ) { if ( $hasCached ) { $this->getOutput()->setSubtitle( $this->cacheHelper->getCachedNotice( $this->getContext() ) ); } } - }