From b2705e32055a57461ad9612635267081bd77631e Mon Sep 17 00:00:00 2001
From: BaranekD <0Baranek.dominik0@gmail.com>
Date: Fri, 10 May 2019 13:03:48 +0200
Subject: [PATCH] Using of short array syntax

---
 CHANGELOG.md                                  |  2 ++
 config-templates/config-warning.php           |  4 +--
 .../module_cesnet_IsCesnetEligible.php        |  4 +--
 .../processFilterConfigurations-example.md    | 10 ++++----
 lib/Auth/Process/ComputeLoA.php               |  6 ++---
 lib/Auth/Process/IsCesnetEligible.php         | 12 ++++-----
 themes/cesnet/default/includes/header.php     | 25 +++++++++----------
 themes/cesnet/perun/disco-tpl.php             |  2 +-
 8 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e0ef4f6..84ad82b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
 All notable changes to this project will be documented in this file.
 
 ## [Unreleased]
+[Changed]
+- Using of short array syntax ([] instead of array())
 
 ## [v2.0.0]
 [Added]
diff --git a/config-templates/config-warning.php b/config-templates/config-warning.php
index 4a3b8eb..924bc06 100644
--- a/config-templates/config-warning.php
+++ b/config-templates/config-warning.php
@@ -3,7 +3,7 @@
 /**
  * This config template is able to show a warning to a user.
  */
-$config = array(
+$config = [
 
     /**
      * When true, the config file is switched on.
@@ -25,4 +25,4 @@ $config = array(
      */
     'text' => '<p> Due to maintenance it won\'t be possible to access our service from' .
                 '<b>1.1.2018 2:00</b> to <b>1.1.2018 4:00</b> </p>',
-);
+];
diff --git a/config-templates/module_cesnet_IsCesnetEligible.php b/config-templates/module_cesnet_IsCesnetEligible.php
index f01de42..5055296 100644
--- a/config-templates/module_cesnet_IsCesnetEligible.php
+++ b/config-templates/module_cesnet_IsCesnetEligible.php
@@ -6,7 +6,7 @@
  * copy command (from SimpleSAML base dir)
  * cp modules/perun/module_cesnet_IsCesnetEligible.php config/
  */
-$config = array(
+$config = [
 
     /**
      * hostname of CESNET ldap with ldap(s):// at the beginning.
@@ -20,4 +20,4 @@ $config = array(
     'ldap.password' => '',
     'ldap.base' => '',
 
-);
+];
diff --git a/config-templates/processFilterConfigurations-example.md b/config-templates/processFilterConfigurations-example.md
index 415d4b5..77424f7 100644
--- a/config-templates/processFilterConfigurations-example.md
+++ b/config-templates/processFilterConfigurations-example.md
@@ -4,9 +4,9 @@ Example how to configure ComputeLoA filter:
 * Put something like this into saml20-idp-hosted.php:
 
     ```php
-    11 => array(
+    11 => [
             'class' => 'cesnet:ComputeLoA',
-    ),
+    ],
     ```
 
 
@@ -16,9 +16,9 @@ Example how to configure IsCesnetEligible filter:
 * Put something like this into saml20-idp-hosted.php:
 
     ```php
-    25 => array(
+    25 => [
             'class' => 'cesnet:IsCesnetEligible',
                     'cesnetEligibleLastSeenAttr' => 'urn:perun:user:attribute-def:def:isCesnetEligibleLastSeen',
-                    'listOfPerunEntityIds' => array ('entityId1', 'entityId2'),
-    ),
+                    'listOfPerunEntityIds' => ['entityId1', 'entityId2'],
+    ],
     ```
\ No newline at end of file
diff --git a/lib/Auth/Process/ComputeLoA.php b/lib/Auth/Process/ComputeLoA.php
index 275d020..ee33e75 100644
--- a/lib/Auth/Process/ComputeLoA.php
+++ b/lib/Auth/Process/ComputeLoA.php
@@ -26,7 +26,7 @@ class ComputeLoA extends \SimpleSAML\Auth\ProcessingFilter
 
     private $metadata;
     private $entityCategory = null;
-    private $eduPersonScopedAffiliation = array();
+    private $eduPersonScopedAffiliation = [];
 
     public function __construct($config, $reserved)
     {
@@ -55,7 +55,7 @@ class ComputeLoA extends \SimpleSAML\Auth\ProcessingFilter
             Logger::error("cesnet:ComputeLoA - There are no element with name 'EntityAttributes' "
                 . "and subelement with name 'http://macedir.org/entity-category' in metadata for IdP with entityId "
                 . $request['saml:sp:IdP'] . "!");
-            $entityCategoryAttributes = array();
+            $entityCategoryAttributes = [];
         }
 
         if (isset($request['Attributes']['eduPersonScopedAffiliation'])) {
@@ -78,7 +78,7 @@ class ComputeLoA extends \SimpleSAML\Auth\ProcessingFilter
 
         $loa = $this->getLoA();
 
-        $request['Attributes'][$this->attrName] = array($loa);
+        $request['Attributes'][$this->attrName] = [$loa];
         Logger::debug("cesnet:ComputeLoA: loa '$loa' was saved to attribute " . $this->attrName);
     }
 
diff --git a/lib/Auth/Process/IsCesnetEligible.php b/lib/Auth/Process/IsCesnetEligible.php
index 4e8f44d..3b7dcf4 100644
--- a/lib/Auth/Process/IsCesnetEligible.php
+++ b/lib/Auth/Process/IsCesnetEligible.php
@@ -33,7 +33,7 @@ class IsCesnetEligible extends \SimpleSAML\Auth\ProcessingFilter
 
     private $spEntityId;
     private $idpEntityId;
-    private $eduPersonScopedAffiliation = array();
+    private $eduPersonScopedAffiliation = [];
 
     /**
      * @var LdapConnector
@@ -107,7 +107,7 @@ class IsCesnetEligible extends \SimpleSAML\Auth\ProcessingFilter
                 $this->cesnetEligibleLastSeen = $this->rpcConnector->get(
                     'attributesManager',
                     'getAttribute',
-                    array('user' => $user->getId(), 'attributeName' => $this->cesnetEligibleLastSeenAttr,)
+                    ['user' => $user->getId(), 'attributeName' => $this->cesnetEligibleLastSeenAttr,]
                 );
             }
 
@@ -120,7 +120,7 @@ class IsCesnetEligible extends \SimpleSAML\Auth\ProcessingFilter
                     $this->rpcConnector->post(
                         'attributesManager',
                         'setAttribute',
-                        array('user' => $user->getId(), 'attribute' => $this->cesnetEligibleLastSeen,)
+                        ['user' => $user->getId(), 'attribute' => $this->cesnetEligibleLastSeen,]
                     );
                 }
             }
@@ -129,7 +129,7 @@ class IsCesnetEligible extends \SimpleSAML\Auth\ProcessingFilter
         }
 
         if ($this->cesnetEligibleLastSeen['value'] != null) {
-            $request['Attributes'][$this->attrName] = array($this->cesnetEligibleLastSeen['value']);
+            $request['Attributes'][$this->attrName] = [$this->cesnetEligibleLastSeen['value']];
         }
     }
 
@@ -160,13 +160,13 @@ class IsCesnetEligible extends \SimpleSAML\Auth\ProcessingFilter
      */
     private function getAllowedAffiliations($idpEntityId)
     {
-        $allowedAffiliations = array();
+        $allowedAffiliations = [];
 
         try {
             $affiliations = $this->cesnetLdapConnector->searchForEntity(
                 self::ORGANIZATION_LDAP_BASE,
                 '(entityIDofIdP=' . $idpEntityId . ')',
-                array('cesnetcustomeraffiliation')
+                ['cesnetcustomeraffiliation']
             )['cesnetcustomeraffiliation'];
 
             if (empty($affiliations)) {
diff --git a/themes/cesnet/default/includes/header.php b/themes/cesnet/default/includes/header.php
index 47817d6..29bacc3 100644
--- a/themes/cesnet/default/includes/header.php
+++ b/themes/cesnet/default/includes/header.php
@@ -6,25 +6,25 @@ use SimpleSAML\Utils\HTTP;
 /**
  * Support the htmlinject hook, which allows modules to change header, pre and post body on all pages.
  */
-$this->data['htmlinject'] = array(
-    'htmlContentPre' => array(),
-    'htmlContentPost' => array(),
-    'htmlContentHead' => array(),
-);
+$this->data['htmlinject'] = [
+    'htmlContentPre' => [],
+    'htmlContentPost' => [],
+    'htmlContentHead' => [],
+];
 
-$jquery = array();
+$jquery = [];
 if (array_key_exists('jquery', $this->data)) {
     $jquery = $this->data['jquery'];
 }
 
 if (array_key_exists('pageid', $this->data)) {
-    $hookinfo = array(
+    $hookinfo = [
         'pre' => &$this->data['htmlinject']['htmlContentPre'],
         'post' => &$this->data['htmlinject']['htmlContentPost'],
         'head' => &$this->data['htmlinject']['htmlContentHead'],
         'jquery' => &$jquery,
         'page' => $this->data['pageid']
-    );
+    ];
 
     Module::callHooks('htmlinject', $hookinfo);
 }
@@ -159,7 +159,7 @@ if ($onLoad !== '') {
             $languages = $this->getLanguageList();
             if (count($languages) > 1) {
                 echo '<div id="languagebar">';
-                $langnames = array(
+                $langnames = [
                     'no' => 'BokmĂĄl', // Norwegian BokmĂĄl
                     'nn' => 'Nynorsk', // Norwegian Nynorsk
                     'se' => 'Sámegiella', // Northern Sami
@@ -196,9 +196,9 @@ if ($onLoad !== '') {
                     'ro' => 'Românește', // Romanian
                     'eu' => 'Euskara', // Basque
                     'af' => 'Afrikaans', // Afrikaans
-                );
+                ];
 
-                $textarray = array();
+                $textarray = [];
                 foreach ($languages as $lang => $current) {
                     $lang = strtolower($lang);
                     if ($current) {
@@ -206,8 +206,7 @@ if ($onLoad !== '') {
                     } else {
                         $textarray[] = '<a href="' . htmlspecialchars(HTTP::addURLParameters(
                             HTTP::getSelfURL(),
-                            array(
-                                    $this->getTranslator()->getLanguage()->getLanguageParameterName() => $lang)
+                            [$this->getTranslator()->getLanguage()->getLanguageParameterName() => $lang]
                         )) . '">' .
                             $langnames[$lang] . '</a>';
                     }
diff --git a/themes/cesnet/perun/disco-tpl.php b/themes/cesnet/perun/disco-tpl.php
index 5a20bff..092e673 100644
--- a/themes/cesnet/perun/disco-tpl.php
+++ b/themes/cesnet/perun/disco-tpl.php
@@ -100,7 +100,7 @@ if (isset($idpmeta['defaultEFilter'])) {
     $defaultEFilter = $idpmeta['defaultEFilter'];
 }
 
-$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true);
+$this->data['jquery'] = ['core' => true, 'ui' => true, 'css' => true];
 $this->includeAtTemplateBase('includes/header.php');
 
 if ($authContextClassRef != null) {
-- 
GitLab