Skip to content

Commit

Permalink
automatic code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Dec 14, 2023
1 parent 6bd15c1 commit 3101d80
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
16 changes: 10 additions & 6 deletions action.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

use dokuwiki\Extension\ActionPlugin;
use dokuwiki\Extension\EventHandler;
use dokuwiki\Extension\Event;

/**
* Changes Plugin: List the most recent changes of the wiki
*
Expand All @@ -11,20 +15,20 @@
/**
* Class action_plugin_changes
*/
class action_plugin_changes extends DokuWiki_Action_Plugin
class action_plugin_changes extends ActionPlugin
{
/**
* Register callbacks
* @param Doku_Event_Handler $controller
* @param EventHandler $controller
*/
public function register(Doku_Event_Handler $controller)
public function register(EventHandler $controller)
{
$controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'beforeParserCacheUse');
}

/**
* Handle PARSER_CACHE_USE:BEFORE event
* @param Doku_Event $event
* @param Event $event
*/
public function beforeParserCacheUse($event)
{
Expand All @@ -45,10 +49,10 @@ protected function addDependencies($cache, $depends)
{
// Prevent "Warning: in_array() expects parameter 2 to be array, null given"
if (!is_array($cache->depends)) {
$cache->depends = array();
$cache->depends = [];
}
if (!array_key_exists('files', $cache->depends)) {
$cache->depends['files'] = array();
$cache->depends['files'] = [];
}

foreach ($depends as $file) {
Expand Down
32 changes: 16 additions & 16 deletions syntax.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php

use dokuwiki\Extension\SyntaxPlugin;

/**
* Changes Plugin: List the most recent changes of the wiki
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
* @author Mykola Ostrovskyy <spambox03@mail.ru>
*/

/**
* Class syntax_plugin_changes
*/
class syntax_plugin_changes extends DokuWiki_Syntax_Plugin
class syntax_plugin_changes extends SyntaxPlugin
{
/**
* What kind of syntax are we?
Expand Down Expand Up @@ -75,12 +77,10 @@ public function handle($match, $state, $pos, Doku_Handler $handler)
foreach ($match as $m) {
if (is_numeric($m)) {
$data['count'] = (int) $m;
} elseif (preg_match('/(\w+)\s*=(.+)/', $m, $temp) == 1) {
$this->handleNamedParameter($temp[1], trim($temp[2]), $data);
} else {
if (preg_match('/(\w+)\s*=(.+)/', $m, $temp) == 1) {
$this->handleNamedParameter($temp[1], trim($temp[2]), $data);
} else {
$this->addNamespace($data, trim($m));
}
$this->addNamespace($data, trim($m));
}
}

Expand All @@ -97,13 +97,13 @@ protected function handleNamedParameter($name, $value, &$data)
{
global $ID;

static $types = array('edit' => 'E', 'create' => 'C', 'delete' => 'D', 'minor' => 'e');
static $renderers = array('list', 'pagelist');
static $types = ['edit' => 'E', 'create' => 'C', 'delete' => 'D', 'minor' => 'e'];
static $renderers = ['list', 'pagelist'];

switch ($name) {
case 'count':
case 'maxage':
$data[$name] = intval($value);
$data[$name] = (int) $value;
break;
case 'ns':
foreach (preg_split('/\s*,\s*/', $value) as $value) {
Expand Down Expand Up @@ -223,10 +223,10 @@ public function render($mode, Doku_Renderer $R, $data)
protected function getChanges($num, $ns, $excludedpages, $type, $user, $maxage, $excludedusers, $reverse)
{
global $conf;
$changes = array();
$seen = array();
$changes = [];
$seen = [];
$count = 0;
$lines = array();
$lines = [];

// Get global changelog
if (file_exists($conf['changelog']) && is_readable($conf['changelog'])) {
Expand Down Expand Up @@ -271,7 +271,7 @@ protected function getChanges($num, $ns, $excludedpages, $type, $user, $maxage,

// Date sort merged page and media changes
if ($this->getConf('listmedia') || $reverse) {
$dates = array();
$dates = [];
foreach ($changes as $change) {
$dates[] = $change['date'];
}
Expand Down Expand Up @@ -436,7 +436,7 @@ protected function renderSimpleList($changes, &$R, $flags = null)
foreach ($changes as $change) {
if ($flags['dayheaders']) {
$tdate = date('Ymd', $change['date']);
if ($tdate != $dayheaders_date) {
if ($tdate !== $dayheaders_date) {
$R->listu_close(); // break list to insert new header
$this->dayheader($R, $change['date']);
$R->listu_open();
Expand Down Expand Up @@ -478,7 +478,7 @@ protected function renderSimpleList($changes, &$R, $flags = null)
*/
protected function parseSimpleListFlags($flags)
{
$outFlags = array('summary' => true, 'signature' => false, 'dayheaders' => false);
$outFlags = ['summary' => true, 'signature' => false, 'dayheaders' => false];
if (!empty($flags)) {
foreach ($flags as $flag) {
if (array_key_exists($flag, $outFlags)) {
Expand Down

0 comments on commit 3101d80

Please sign in to comment.