Skip to content

Commit 5497ea2

Browse files
authored
Merge pull request #16 from cosmocode/bot/autofix
🤖 Automatic code style fixes
2 parents 9cc4b3d + 9ab8cba commit 5497ea2

16 files changed

+106
-77
lines changed

action/banner.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<?php
22

3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
6+
use dokuwiki\Form\Form;
37
use dokuwiki\plugin\structpublish\meta\Constants;
48
use dokuwiki\plugin\structpublish\meta\Revision;
59

610
/**
711
* Action component responsible for the publish banner
812
* attached to struct data of a page
913
*/
10-
class action_plugin_structpublish_banner extends DokuWiki_Action_Plugin
14+
class action_plugin_structpublish_banner extends ActionPlugin
1115
{
1216
/** @var \helper_plugin_structpublish_db */
1317
protected $dbHelper;
@@ -16,15 +20,15 @@ class action_plugin_structpublish_banner extends DokuWiki_Action_Plugin
1620
protected $compactView;
1721

1822
/** @inheritDoc */
19-
public function register(Doku_Event_Handler $controller)
23+
public function register(EventHandler $controller)
2024
{
2125
$controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'renderBanner');
2226
}
2327

2428
/**
2529
* Add banner to pages under structpublish control
2630
*/
27-
public function renderBanner(Doku_Event $event)
31+
public function renderBanner(Event $event)
2832
{
2933
global $ID;
3034
global $INFO;
@@ -153,7 +157,7 @@ protected function actionButtons($status, $newVersion)
153157
return '';
154158
}
155159

156-
$form = new dokuwiki\Form\Form();
160+
$form = new Form();
157161

158162
if (
159163
$status !== Constants::STATUS_APPROVED &&
@@ -192,6 +196,6 @@ protected function increaseVersion($version)
192196
}
193197
$parts[] = $last;
194198

195-
return join('.', $parts);
199+
return implode('.', $parts);
196200
}
197201
}

action/cache.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
<?php
22

3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
6+
use dokuwiki\Cache\CacheParser;
7+
38
/**
49
* Double caching of pages containing struct aggregations:
510
* one for regular users, one for publishers/approvers
611
*
712
* @see action_plugin_struct_cache
813
*/
9-
class action_plugin_structpublish_cache extends DokuWiki_Action_Plugin
14+
class action_plugin_structpublish_cache extends ActionPlugin
1015
{
1116
/**
1217
* Registers a callback function for a given event
1318
*
14-
* @param Doku_Event_Handler $controller DokuWiki's event controller object
19+
* @param EventHandler $controller DokuWiki's event controller object
1520
* @return void
1621
*/
17-
public function register(Doku_Event_Handler $controller)
22+
public function register(EventHandler $controller)
1823
{
1924
$controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'handleCacheAggregation');
2025
}
@@ -23,12 +28,12 @@ public function register(Doku_Event_Handler $controller)
2328
* For pages containing an aggregation, add structpublish flag to cache key
2429
* to differentiate between caches for regular and privileged users
2530
*
26-
* @param Doku_Event $event event object by reference
31+
* @param Event $event event object by reference
2732
* @return bool
2833
*/
29-
public function handleCacheAggregation(Doku_Event $event)
34+
public function handleCacheAggregation(Event $event)
3035
{
31-
/** @var \dokuwiki\Cache\CacheParser $cache */
36+
/** @var CacheParser $cache */
3237
$cache = $event->data;
3338
if ($cache->mode != 'xhtml') return true;
3439
if (!$cache->page) return true; // not a page cache

action/migration.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<?php
22

3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
6+
use dokuwiki\plugin\struct\meta\SchemaImporter;
7+
use dokuwiki\plugin\sqlite\SQLiteDB;
38
use dokuwiki\plugin\sqlite\Tools;
49

5-
class action_plugin_structpublish_migration extends DokuWiki_Action_Plugin
10+
class action_plugin_structpublish_migration extends ActionPlugin
611
{
712
public const MIN_DB_STRUCT = 19;
813

@@ -12,7 +17,7 @@ class action_plugin_structpublish_migration extends DokuWiki_Action_Plugin
1217
/**
1318
* @inheritDoc
1419
*/
15-
public function register(Doku_Event_Handler $controller)
20+
public function register(EventHandler $controller)
1621
{
1722
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handleMigrations');
1823
}
@@ -22,11 +27,11 @@ public function register(Doku_Event_Handler $controller)
2227
* so we cannot use the mechanism in sqlite init()
2328
* which processes updateXXXX.sql files
2429
*
25-
* @param Doku_Event $event
30+
* @param Event $event
2631
* @return bool
2732
* @throws Exception
2833
*/
29-
public function handleMigrations(Doku_Event $event)
34+
public function handleMigrations(Event $event)
3035
{
3136
/** @var \helper_plugin_struct_db $helper */
3237
$helper = plugin_load('helper', 'struct_db');
@@ -38,7 +43,7 @@ public function handleMigrations(Doku_Event $event)
3843

3944
$sqlite = $helper->getDB();
4045

41-
list($dbVersionStruct, $dbVersionStructpublish) = $this->getDbVersions($sqlite);
46+
[$dbVersionStruct, $dbVersionStructpublish] = $this->getDbVersions($sqlite);
4247

4348
// check if struct has required version
4449
if ($dbVersionStruct < self::MIN_DB_STRUCT) {
@@ -55,7 +60,7 @@ public function handleMigrations(Doku_Event $event)
5560

5661
// check whether we have any pending migrations
5762
$pending = range(($dbVersionStructpublish ?: 0) + 1, $latestVersion);
58-
if (empty($pending)) {
63+
if ($pending === []) {
5964
return true;
6065
}
6166

@@ -79,7 +84,7 @@ public function handleMigrations(Doku_Event $event)
7984
/**
8085
* Read the current versions for struct and struct publish from the database
8186
*
82-
* @param \dokuwiki\plugin\sqlite\SQLiteDB $sqlite
87+
* @param SQLiteDB $sqlite
8388
* @return array [structversion, structpublishversion]
8489
*/
8590
protected function getDbVersions($sqlite)
@@ -112,14 +117,14 @@ protected function getLatestVersion()
112117
/**
113118
* Database setup
114119
*
115-
* @param \dokuwiki\plugin\sqlite\SQLiteDB $sqlite
120+
* @param SQLiteDB $sqlite
116121
* @return bool
117122
*/
118123
protected function migration1($sqlite)
119124
{
120125
$file = DOKU_PLUGIN . 'structpublish/db/json/structpublish0001.struct.json';
121126
$schemaJson = file_get_contents($file);
122-
$importer = new \dokuwiki\plugin\struct\meta\SchemaImporter('structpublish', $schemaJson);
127+
$importer = new SchemaImporter('structpublish', $schemaJson);
123128
$ok = (bool) $importer->build();
124129

125130
if ($ok) {
@@ -137,7 +142,7 @@ protected function migration1($sqlite)
137142
* Reset 'latest' flag to 0 for all rows except actually latest ones
138143
* for each pid / status combination.
139144
*
140-
* @param \dokuwiki\plugin\sqlite\SQLiteDB $sqlite
145+
* @param SQLiteDB $sqlite
141146
* @return bool
142147
*/
143148
protected function migration2($sqlite)
@@ -155,7 +160,7 @@ protected function migration2($sqlite)
155160
* Set 'latest' flag to 0 for all rows except actually latest ones
156161
* for each page,
157162
*
158-
* @param \dokuwiki\plugin\sqlite\SQLiteDB $sqlite
163+
* @param SQLiteDB $sqlite
159164
* @return bool
160165
*/
161166
protected function migration3($sqlite)

action/publish.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
<?php
22

3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
36
use dokuwiki\plugin\structpublish\meta\Constants;
47

5-
class action_plugin_structpublish_publish extends DokuWiki_Action_Plugin
8+
class action_plugin_structpublish_publish extends ActionPlugin
69
{
710
/** @inheritDoc */
8-
public function register(Doku_Event_Handler $controller)
11+
public function register(EventHandler $controller)
912
{
1013
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'changeStatus');
1114
}
1215

1316
/**
1417
* Handle the publish button and version field
1518
*
16-
* @param Doku_Event $event
19+
* @param Event $event
1720
* @return void
1821
* @throws Exception
1922
*/
20-
public function changeStatus(Doku_Event $event)
23+
public function changeStatus(Event $event)
2124
{
2225
if ($event->data != 'show') {
2326
return;

action/revisions.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
<?php
22

3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
6+
use dokuwiki\Form\CheckableElement;
7+
use dokuwiki\Form\HTMLElement;
38
use dokuwiki\plugin\structpublish\meta\Revision;
49
use dokuwiki\plugin\structpublish\meta\Constants;
510

6-
class action_plugin_structpublish_revisions extends DokuWiki_Action_Plugin
11+
class action_plugin_structpublish_revisions extends ActionPlugin
712
{
8-
public function register(Doku_Event_Handler $controller)
13+
public function register(EventHandler $controller)
914
{
1015
$controller->register_hook('FORM_REVISIONS_OUTPUT', 'BEFORE', $this, 'handleRevisions');
1116
}
1217

1318
/**
1419
* Adds publish info to page revisions
1520
*
16-
* @param Doku_Event $event
21+
* @param Event $event
1722
* @return void
1823
*/
19-
public function handleRevisions(Doku_Event $event)
24+
public function handleRevisions(Event $event)
2025
{
2126
global $INFO;
2227

@@ -36,12 +41,12 @@ public function handleRevisions(Doku_Event $event)
3641
for ($i = 0; $i < $elCount; $i++) {
3742
$el = $form->getElementAt($i);
3843

39-
if (!is_a($el, \dokuwiki\Form\CheckableElement::class) && !is_a($el, \dokuwiki\Form\HTMLElement::class)) {
44+
if (!$el instanceof CheckableElement && !$el instanceof HTMLElement) {
4045
continue;
4146
}
4247

4348
// extract rev from checkbox info
44-
if (is_a($el, \dokuwiki\Form\CheckableElement::class)) {
49+
if (is_a($el, CheckableElement::class)) {
4550
if ($el->attr('name') === $checkName) {
4651
$rev = $el->attr('value');
4752
}
@@ -54,7 +59,7 @@ public function handleRevisions(Doku_Event $event)
5459

5560
// insert status for published revisions
5661
if (
57-
is_a($el, \dokuwiki\Form\HTMLElement::class) &&
62+
is_a($el, HTMLElement::class) &&
5863
!empty(trim($el->val())) &&
5964
$status === Constants::STATUS_PUBLISHED
6065
) {

action/save.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
36
use dokuwiki\plugin\struct\meta\StructException;
47
use dokuwiki\plugin\structpublish\meta\Assignments;
58
use dokuwiki\plugin\structpublish\meta\Constants;
@@ -8,21 +11,21 @@
811
/**
912
* Action component to handle page save
1013
*/
11-
class action_plugin_structpublish_save extends DokuWiki_Action_Plugin
14+
class action_plugin_structpublish_save extends ActionPlugin
1215
{
1316
/** @inheritDoc */
14-
public function register(Doku_Event_Handler $controller)
17+
public function register(EventHandler $controller)
1518
{
1619
$controller->register_hook('COMMON_WIKIPAGE_SAVE', 'AFTER', $this, 'handleSave');
1720
}
1821

1922
/**
2023
* Handle the page save event to store revision meta data
2124
*
22-
* @param Doku_Event $event
25+
* @param Event $event
2326
* @return void
2427
*/
25-
public function handleSave(Doku_Event $event)
28+
public function handleSave(Event $event)
2629
{
2730
/** @var helper_plugin_structpublish_db $dbHelper */
2831
$dbHelper = plugin_load('helper', 'structpublish_db');

action/show.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<?php
22

3+
use dokuwiki\Extension\ActionPlugin;
4+
use dokuwiki\Extension\EventHandler;
5+
use dokuwiki\Extension\Event;
36
use dokuwiki\plugin\structpublish\meta\Constants;
47
use dokuwiki\plugin\structpublish\meta\Revision;
58

6-
class action_plugin_structpublish_show extends DokuWiki_Action_Plugin
9+
class action_plugin_structpublish_show extends ActionPlugin
710
{
811
/** @var int */
912
protected static $latestPublishedRev;
1013

1114
/** @inheritDoc */
12-
public function register(Doku_Event_Handler $controller)
15+
public function register(EventHandler $controller)
1316
{
1417
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handleShow');
1518
$controller->register_hook('HTML_SHOWREV_OUTPUT', 'BEFORE', $this, 'handleShowrev');
@@ -18,10 +21,10 @@ public function register(Doku_Event_Handler $controller)
1821
/**
1922
* Decide which revision to show based on role assignments
2023
*
21-
* @param Doku_Event $event
24+
* @param Event $event
2225
* @return void
2326
*/
24-
public function handleShow(Doku_Event $event)
27+
public function handleShow(Event $event)
2528
{
2629
if ($event->data != 'show') {
2730
return;
@@ -67,10 +70,10 @@ public function handleShow(Doku_Event $event)
6770
* Suppress message about viewing an old revision if it is the latest one
6871
* that the current user is allowed to see.
6972
*
70-
* @param Doku_Event $event
73+
* @param Event $event
7174
* @return void
7275
*/
73-
public function handleShowrev(Doku_Event $event)
76+
public function handleShowrev(Event $event)
7477
{
7578
/** @var helper_plugin_structpublish_db $dbHelper */
7679
$dbHelper = plugin_load('helper', 'structpublish_db');

0 commit comments

Comments
 (0)