aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/Cache
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2023-09-02 14:42:51 +0200
committerGitHub <noreply@github.com>2023-09-02 14:42:51 +0200
commit5ff5424d8c81c7123d8656a787af2ff85b3dec21 (patch)
tree322929ee01d892bb3c927e7fe1238369c647f820 /inc/Cache
parent0613df3287b82a98b1e97cf86ed9d4c8fbd16f1c (diff)
parent91560755291852b8302767d454183a7662666f7e (diff)
downloaddokuwiki-5ff5424d8c81c7123d8656a787af2ff85b3dec21.tar.gz
dokuwiki-5ff5424d8c81c7123d8656a787af2ff85b3dec21.zip
Merge pull request #4045 from dokuwiki/autofix
Use Rector to autofix code smell
Diffstat (limited to 'inc/Cache')
-rw-r--r--inc/Cache/Cache.php10
-rw-r--r--inc/Cache/CacheImageMod.php2
-rw-r--r--inc/Cache/CacheInstructions.php5
-rw-r--r--inc/Cache/CacheParser.php29
-rw-r--r--inc/Cache/CacheRenderer.php18
5 files changed, 28 insertions, 36 deletions
diff --git a/inc/Cache/Cache.php b/inc/Cache/Cache.php
index af82e6bf6..e304943eb 100644
--- a/inc/Cache/Cache.php
+++ b/inc/Cache/Cache.php
@@ -15,7 +15,7 @@ class Cache
public $key = ''; // primary identifier for this item
public $ext = ''; // file ext for cache data, secondary identifier for this item
public $cache = ''; // cache file name
- public $depends = array(); // array containing cache dependency information,
+ public $depends = []; // array containing cache dependency information,
// used by makeDefaultCacheDecision to determine cache validity
// phpcs:disable
@@ -73,7 +73,7 @@ class Cache
*
* @return bool true if cache can be used, false otherwise
*/
- public function useCache($depends = array())
+ public function useCache($depends = [])
{
$this->depends = $depends;
$this->addDependencies();
@@ -83,7 +83,7 @@ class Cache
Event::createAndTrigger(
$this->getEvent(),
$this,
- array($this, 'makeDefaultCacheDecision')
+ [$this, 'makeDefaultCacheDecision']
)
);
}
@@ -212,7 +212,7 @@ class Cache
}
if (isset($stats[$this->ext])) {
- list($ext, $count, $hits) = explode(',', $stats[$this->ext]);
+ [$ext, $count, $hits] = explode(',', $stats[$this->ext]);
} else {
$ext = $this->ext;
$count = 0;
@@ -225,7 +225,7 @@ class Cache
}
$stats[$this->ext] = "$ext,$count,$hits";
- io_saveFile($file, join("\n", $stats));
+ io_saveFile($file, implode("\n", $stats));
return $success;
}
diff --git a/inc/Cache/CacheImageMod.php b/inc/Cache/CacheImageMod.php
index 5883f7842..bec3ef455 100644
--- a/inc/Cache/CacheImageMod.php
+++ b/inc/Cache/CacheImageMod.php
@@ -7,7 +7,6 @@ namespace dokuwiki\Cache;
*/
class CacheImageMod extends Cache
{
-
/** @var string source file */
protected $file;
@@ -52,5 +51,4 @@ class CacheImageMod extends Cache
getConfigFiles('main')
);
}
-
}
diff --git a/inc/Cache/CacheInstructions.php b/inc/Cache/CacheInstructions.php
index acd02abae..8bc72d976 100644
--- a/inc/Cache/CacheInstructions.php
+++ b/inc/Cache/CacheInstructions.php
@@ -5,9 +5,8 @@ namespace dokuwiki\Cache;
/**
* Caching of parser instructions
*/
-class CacheInstructions extends \dokuwiki\Cache\CacheParser
+class CacheInstructions extends CacheParser
{
-
/**
* @param string $id page id
* @param string $file source file for cache
@@ -26,7 +25,7 @@ class CacheInstructions extends \dokuwiki\Cache\CacheParser
public function retrieveCache($clean = true)
{
$contents = io_readFile($this->cache, false);
- return !empty($contents) ? unserialize($contents) : array();
+ return empty($contents) ? [] : unserialize($contents);
}
/**
diff --git a/inc/Cache/CacheParser.php b/inc/Cache/CacheParser.php
index 4d8550dbe..d885d256b 100644
--- a/inc/Cache/CacheParser.php
+++ b/inc/Cache/CacheParser.php
@@ -7,7 +7,6 @@ namespace dokuwiki\Cache;
*/
class CacheParser extends Cache
{
-
public $file = ''; // source file for cache
public $mode = ''; // input mode (represents the processing the input file will undergo)
public $page = '';
@@ -35,32 +34,30 @@ class CacheParser extends Cache
/**
* method contains cache use decision logic
*
- * @return bool see useCache()
+ * @return bool see useCache()
*/
public function makeDefaultCacheDecision()
{
-
if (!file_exists($this->file)) {
+ // source doesn't exist
return false;
- } // source exists?
+ }
return parent::makeDefaultCacheDecision();
}
protected function addDependencies()
{
-
// parser cache file dependencies ...
- $files = array(
- $this->file, // ... source
- DOKU_INC . 'inc/Parsing/Parser.php', // ... parser
- DOKU_INC . 'inc/parser/handler.php', // ... handler
- );
- $files = array_merge($files, getConfigFiles('main')); // ... wiki settings
-
- $this->depends['files'] = !empty($this->depends['files']) ?
- array_merge($files, $this->depends['files']) :
- $files;
+ $files = [
+ $this->file, // source
+ DOKU_INC . 'inc/Parsing/Parser.php', // parser
+ DOKU_INC . 'inc/parser/handler.php', // handler
+ ];
+ $files = array_merge($files, getConfigFiles('main')); // wiki settings
+
+ $this->depends['files'] = empty($this->depends['files']) ?
+ $files :
+ array_merge($files, $this->depends['files']);
parent::addDependencies();
}
-
}
diff --git a/inc/Cache/CacheRenderer.php b/inc/Cache/CacheRenderer.php
index e8a28c309..95b330d5a 100644
--- a/inc/Cache/CacheRenderer.php
+++ b/inc/Cache/CacheRenderer.php
@@ -7,7 +7,6 @@ namespace dokuwiki\Cache;
*/
class CacheRenderer extends CacheParser
{
-
/**
* method contains cache use decision logic
*
@@ -40,8 +39,10 @@ class CacheRenderer extends CacheParser
// for wiki pages, check metadata dependencies
$metadata = p_get_metadata($this->page);
- if (!isset($metadata['relation']['references']) ||
- empty($metadata['relation']['references'])) {
+ if (
+ !isset($metadata['relation']['references']) ||
+ empty($metadata['relation']['references'])
+ ) {
return true;
}
@@ -70,13 +71,10 @@ class CacheRenderer extends CacheParser
}
// renderer cache file dependencies ...
- $files = array(
- DOKU_INC . 'inc/parser/' . $this->mode . '.php', // ... the renderer
- );
+ $files = [DOKU_INC . 'inc/parser/' . $this->mode . '.php'];
// page implies metadata and possibly some other dependencies
if (isset($this->page)) {
-
// for xhtml this will render the metadata if needed
$valid = p_get_metadata($this->page, 'date valid');
if (!empty($valid['age'])) {
@@ -85,9 +83,9 @@ class CacheRenderer extends CacheParser
}
}
- $this->depends['files'] = !empty($this->depends['files']) ?
- array_merge($files, $this->depends['files']) :
- $files;
+ $this->depends['files'] = empty($this->depends['files']) ?
+ $files :
+ array_merge($files, $this->depends['files']);
parent::addDependencies();
}