Add missing public visibility on methods of cache related classes

Change-Id: I8c85b6d7757c6b87ab0a72363c6d1571f0bfe67a
This commit is contained in:
Umherirrender 2020-05-09 11:29:01 +02:00
parent 06a884c9ee
commit 5b55e2eded
9 changed files with 21 additions and 22 deletions

View file

@ -22,7 +22,6 @@
<!-- TODO Still to be done --> <!-- TODO Still to be done -->
<rule ref="Squiz.Scope.MethodScope.Missing"> <rule ref="Squiz.Scope.MethodScope.Missing">
<exclude-pattern>includes/actions/</exclude-pattern> <exclude-pattern>includes/actions/</exclude-pattern>
<exclude-pattern>includes/cache/</exclude-pattern>
<exclude-pattern>includes/deferred/</exclude-pattern> <exclude-pattern>includes/deferred/</exclude-pattern>
<exclude-pattern>includes/diff/</exclude-pattern> <exclude-pattern>includes/diff/</exclude-pattern>
<exclude-pattern>includes/export/</exclude-pattern> <exclude-pattern>includes/export/</exclude-pattern>

View file

@ -34,7 +34,7 @@ interface ICacheHelper {
* @since 1.20 * @since 1.20
* @param bool $cacheEnabled * @param bool $cacheEnabled
*/ */
function setCacheEnabled( $cacheEnabled ); public function setCacheEnabled( $cacheEnabled );
/** /**
* Initializes the caching. * Initializes the caching.
@ -45,7 +45,7 @@ interface ICacheHelper {
* @param int|null $cacheExpiry Sets the cache expiry, either ttl in seconds or unix timestamp. * @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. * @param bool|null $cacheEnabled Sets if the cache should be enabled or not.
*/ */
function startCache( $cacheExpiry = null, $cacheEnabled = null ); public function startCache( $cacheExpiry = null, $cacheEnabled = null );
/** /**
* Get a cached value if available or compute it if not and then cache it if possible. * Get a cached value if available or compute it if not and then cache it if possible.
@ -61,7 +61,7 @@ interface ICacheHelper {
* *
* @return mixed * @return mixed
*/ */
function getCachedValue( $computeFunction, $args = [], $key = null ); public function getCachedValue( $computeFunction, $args = [], $key = null );
/** /**
* Saves the HTML to the cache in case it got recomputed. * Saves the HTML to the cache in case it got recomputed.
@ -69,7 +69,7 @@ interface ICacheHelper {
* *
* @since 1.20 * @since 1.20
*/ */
function saveCache(); public function saveCache();
/** /**
* Sets the time to live for the cache, in seconds or a unix timestamp * Sets the time to live for the cache, in seconds or a unix timestamp
@ -79,5 +79,5 @@ interface ICacheHelper {
* *
* @param int $cacheExpiry * @param int $cacheExpiry
*/ */
function setExpiry( $cacheExpiry ); public function setExpiry( $cacheExpiry );
} }

View file

@ -28,11 +28,11 @@ abstract class CacheDependency {
/** /**
* Returns true if the dependency is expired, false otherwise * Returns true if the dependency is expired, false otherwise
*/ */
abstract function isExpired(); abstract public function isExpired();
/** /**
* Hook to perform any expensive pre-serialize loading of dependency values. * Hook to perform any expensive pre-serialize loading of dependency values.
*/ */
function loadDependencyValues() { public function loadDependencyValues() {
} }
} }

View file

@ -36,7 +36,7 @@ class ConstantDependency extends CacheDependency {
/** /**
* @return bool * @return bool
*/ */
function isExpired() { public function isExpired() {
return constant( $this->name ) != $this->value; return constant( $this->name ) != $this->value;
} }
} }

View file

@ -52,7 +52,7 @@ class DependencyWrapper {
* *
* @return bool * @return bool
*/ */
function isExpired() { public function isExpired() {
foreach ( $this->deps as $dep ) { foreach ( $this->deps as $dep ) {
if ( $dep->isExpired() ) { if ( $dep->isExpired() ) {
return true; return true;
@ -66,7 +66,7 @@ class DependencyWrapper {
* Initialise dependency values in preparation for storing. This must be * Initialise dependency values in preparation for storing. This must be
* called before serialization. * called before serialization.
*/ */
function initialiseDeps() { public function initialiseDeps() {
foreach ( $this->deps as $dep ) { foreach ( $this->deps as $dep ) {
$dep->loadDependencyValues(); $dep->loadDependencyValues();
} }
@ -76,7 +76,7 @@ class DependencyWrapper {
* Get the user-defined value * Get the user-defined value
* @return bool|mixed * @return bool|mixed
*/ */
function getValue() { public function getValue() {
return $this->value; return $this->value;
} }
@ -87,7 +87,7 @@ class DependencyWrapper {
* @param string $key * @param string $key
* @param int $expiry * @param int $expiry
*/ */
function storeToCache( $cache, $key, $expiry = 0 ) { public function storeToCache( $cache, $key, $expiry = 0 ) {
$this->initialiseDeps(); $this->initialiseDeps();
$cache->set( $key, $this, $expiry ); $cache->set( $key, $this, $expiry );
} }
@ -109,7 +109,7 @@ class DependencyWrapper {
* @return mixed The value, or null if it was not present in the cache and no * @return mixed The value, or null if it was not present in the cache and no
* callback was defined. * callback was defined.
*/ */
static function getValueFromCache( $cache, $key, $expiry = 0, $callback = false, public static function getValueFromCache( $cache, $key, $expiry = 0, $callback = false,
$callbackParams = [], $deps = [] $callbackParams = [], $deps = []
) { ) {
$obj = $cache->get( $key ); $obj = $cache->get( $key );

View file

@ -54,7 +54,7 @@ class FileDependency extends CacheDependency {
return [ 'filename', 'timestamp' ]; return [ 'filename', 'timestamp' ];
} }
function loadDependencyValues() { public function loadDependencyValues() {
if ( $this->timestamp === null ) { if ( $this->timestamp === null ) {
Wikimedia\suppressWarnings(); Wikimedia\suppressWarnings();
# Dependency on a non-existent file stores "false" # Dependency on a non-existent file stores "false"
@ -67,7 +67,7 @@ class FileDependency extends CacheDependency {
/** /**
* @return bool * @return bool
*/ */
function isExpired() { public function isExpired() {
Wikimedia\suppressWarnings(); Wikimedia\suppressWarnings();
$lastmod = filemtime( $this->filename ); $lastmod = filemtime( $this->filename );
Wikimedia\restoreWarnings(); Wikimedia\restoreWarnings();

View file

@ -36,7 +36,7 @@ class GlobalDependency extends CacheDependency {
/** /**
* @return bool * @return bool
*/ */
function isExpired() { public function isExpired() {
if ( !isset( $GLOBALS[$this->name] ) ) { if ( !isset( $GLOBALS[$this->name] ) ) {
return true; return true;
} }

View file

@ -41,7 +41,7 @@ class MainConfigDependency extends CacheDependency {
/** /**
* @return bool * @return bool
*/ */
function isExpired() { public function isExpired() {
if ( !$this->getConfig()->has( $this->name ) ) { if ( !$this->getConfig()->has( $this->name ) ) {
return true; return true;
} }

View file

@ -42,18 +42,18 @@ interface LCStore {
* @param string $code Language code * @param string $code Language code
* @param string $key Cache key * @param string $key Cache key
*/ */
function get( $code, $key ); public function get( $code, $key );
/** /**
* Start a write transaction. * Start a write transaction.
* @param string $code Language code * @param string $code Language code
*/ */
function startWrite( $code ); public function startWrite( $code );
/** /**
* Finish a write transaction. * Finish a write transaction.
*/ */
function finishWrite(); public function finishWrite();
/** /**
* Set a key to a given value. startWrite() must be called before this * Set a key to a given value. startWrite() must be called before this
@ -61,6 +61,6 @@ interface LCStore {
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*/ */
function set( $key, $value ); public function set( $key, $value );
} }