From 6ff5c09554389786c9f179e73369f131d1edc12b Mon Sep 17 00:00:00 2001
From: splitbrain <86426+splitbrain@users.noreply.github.com>
Date: Thu, 19 Sep 2024 21:52:42 +0000
Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Automatic=20code=20style=20fixes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 action.php | 19 ++++++++++++-------
 helper.php |  8 +++++---
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/action.php b/action.php
index 6c4dd87..325b50d 100644
--- a/action.php
+++ b/action.php
@@ -1,5 +1,10 @@
 <?php
 
+use dokuwiki\Extension\ActionPlugin;
+use dokuwiki\Extension\EventHandler;
+use dokuwiki\Extension\Event;
+use dokuwiki\plugin\struct\meta\Schema;
+use dokuwiki\plugin\struct\types\User;
 use dokuwiki\plugin\struct\meta\AccessTable;
 use dokuwiki\plugin\struct\meta\Assignments;
 use dokuwiki\plugin\struct\meta\StructException;
@@ -10,10 +15,10 @@
  * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
  * @author  Anna Dabrowska <dokuwiki@cosmocode.de>
  */
-class action_plugin_structacl extends \dokuwiki\Extension\ActionPlugin
+class action_plugin_structacl extends ActionPlugin
 {
     /** @inheritDoc */
-    public function register(Doku_Event_Handler $controller)
+    public function register(EventHandler $controller)
     {
         $mode = $this->getConf('run');
         $controller->register_hook('AUTH_ACL_CHECK', $mode, $this, 'handleAclCheck', $mode);
@@ -25,11 +30,11 @@ public function register(Doku_Event_Handler $controller)
      * If current user is found in a configured struct field of the current page,
      * upload permissions are granted.
      *
-     * @param Doku_Event $event event object by reference
+     * @param Event $event event object by reference
      * @param string $mode BEFORE|AFTER
      * @return void
      */
-    public function handleAclCheck(Doku_Event $event, $mode)
+    public function handleAclCheck(Event $event, $mode)
     {
         global $ID;
         global $REV;
@@ -52,12 +57,12 @@ public function handleAclCheck(Doku_Event $event, $mode)
                 continue;
             }
             try {
-                $schema = new \dokuwiki\plugin\struct\meta\Schema($schemaName);
+                $schema = new Schema($schemaName);
                 $schemaData = AccessTable::getPageAccess($schemaName, $ID, (int)$REV);
                 $data = $schemaData->getData();
                 foreach ($fields as $field) {
                     $col = $schema->findColumn($field);
-                    if ($col && is_a($col->getType(), \dokuwiki\plugin\struct\types\User::class)) {
+                    if ($col && is_a($col->getType(), User::class)) {
                         $value = $data[$field]->getValue();
                         if (empty($value)) continue;
                         // multivalue field?
@@ -74,7 +79,7 @@ public function handleAclCheck(Doku_Event $event, $mode)
         }
 
         // grant upload permissions if current user is found in struct field
-        if (!empty($users) && in_array($event->data['user'], $users)) {
+        if ($users !== [] && in_array($event->data['user'], $users)) {
             $event->result = AUTH_UPLOAD;
         }
 
diff --git a/helper.php b/helper.php
index 125ad5a..a5c9913 100644
--- a/helper.php
+++ b/helper.php
@@ -1,6 +1,8 @@
 <?php
 
-class helper_plugin_structacl extends DokuWiki_Plugin
+use dokuwiki\Extension\Plugin;
+
+class helper_plugin_structacl extends Plugin
 {
     public const STRUCTACL_SEPCHAR = '.';
     /**
@@ -20,8 +22,8 @@ public function getConfiguration($confValue)
             $line = trim($line);
             if ($line === '' || strpos($line, self::STRUCTACL_SEPCHAR) === false) continue;
 
-            list($schema, $field) = explode(self::STRUCTACL_SEPCHAR, $line, 2);
-            $config[$schema] = $config[$schema] ?? [];
+            [$schema, $field] = explode(self::STRUCTACL_SEPCHAR, $line, 2);
+            $config[$schema] ??= [];
             $config[$schema][] = $field;
         }