From ca00beccc7f146555812304077b130ffb7c6bd9f Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Sat, 28 Jul 2018 16:59:47 +0200
Subject: [PATCH] Fix indentation / PSR-2

---
 modules/consent/lib/Consent/Store/Cookie.php | 21 +++----
 modules/consent/templates/consentform.php    | 64 ++++++++++----------
 modules/consent/templates/noconsent.php      | 10 +--
 modules/consent/www/getconsent.php           | 48 +++++++--------
 4 files changed, 68 insertions(+), 75 deletions(-)

diff --git a/modules/consent/lib/Consent/Store/Cookie.php b/modules/consent/lib/Consent/Store/Cookie.php
index ad448c799..52ea5f952 100644
--- a/modules/consent/lib/Consent/Store/Cookie.php
+++ b/modules/consent/lib/Consent/Store/Cookie.php
@@ -44,20 +44,19 @@ class Cookie extends \SimpleSAML\Module\consent\Store
 
         $cookieName = self::_getCookieName($userId, $destinationId);
 
-        $data = $userId . ':' . $attributeSet . ':' . $destinationId;
+        $data = $userId.':'.$attributeSet.':'.$destinationId;
 
-        \SimpleSAML\Logger::debug('Consent cookie - Get [' . $data . ']');
+        \SimpleSAML\Logger::debug('Consent cookie - Get ['.$data.']');
 
         if (!array_key_exists($cookieName, $_COOKIE)) {
             \SimpleSAML\Logger::debug(
-                'Consent cookie - no cookie with name \'' .
-                $cookieName . '\'.'
+                'Consent cookie - no cookie with name \''.$cookieName.'\'.'
             );
             return false;
         }
         if (!is_string($_COOKIE[$cookieName])) {
             \SimpleSAML\Logger::warning(
-                'Value of consent cookie wasn\'t a string. Was: ' .
+                'Value of consent cookie wasn\'t a string. Was: '.
                 var_export($_COOKIE[$cookieName], true)
             );
             return false;
@@ -99,9 +98,9 @@ class Cookie extends \SimpleSAML\Module\consent\Store
         assert(is_string($attributeSet));
 
         $name = self::_getCookieName($userId, $destinationId);
-        $value = $userId . ':' . $attributeSet . ':' . $destinationId;
+        $value = $userId.':'.$attributeSet.':'.$destinationId;
 
-        \SimpleSAML\Logger::debug('Consent cookie - Set [' . $value . ']');
+        \SimpleSAML\Logger::debug('Consent cookie - Set ['.$value.']');
 
         $value = self::_sign($value);
         $this->_setConsentCookie($name, $value);
@@ -178,7 +177,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store
             $tmp = explode(':', $value, 3);
             if (count($tmp) !== 3) {
                 \SimpleSAML\Logger::warning(
-                    'Consent cookie with invalid value: ' . $value
+                    'Consent cookie with invalid value: '.$value
                 );
                 continue;
             }
@@ -211,7 +210,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store
 
         $secretSalt = \SimpleSAML\Utils\Config::getSecretSalt();
 
-        return sha1($secretSalt . $data . $secretSalt) . ':' . $data;
+        return sha1($secretSalt.$data.$secretSalt).':'.$data;
     }
 
 
@@ -260,7 +259,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store
         assert(is_string($userId));
         assert(is_string($destinationId));
 
-        return '\SimpleSAML\Module\consent:' . sha1($userId . ':' . $destinationId);
+        return '\SimpleSAML\Module\consent:'.sha1($userId.':'.$destinationId);
     }
 
 
@@ -279,7 +278,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store
 
         $globalConfig = \SimpleSAML\Configuration::getInstance();
         $params = array(
-            'lifetime' => 7776000,    // (90*24*60*60)
+            'lifetime' => 7776000, // (90*24*60*60)
             'path' => ($globalConfig->getBasePath()),
             'httponly' => true,
             'secure' => \SimpleSAML\Utils\HTTP::isHTTPS(),
diff --git a/modules/consent/templates/consentform.php b/modules/consent/templates/consentform.php
index 2f5edf7b9..694c316bf 100644
--- a/modules/consent/templates/consentform.php
+++ b/modules/consent/templates/consentform.php
@@ -18,16 +18,16 @@ $dstName = $this->data['dstName'];
 $srcName = $this->data['srcName'];
 
 $this->data['header'] = $this->t('{consent:consent:consent_header}');
-$this->data['head'] = '<link rel="stylesheet" type="text/css" href="' .
-    SimpleSAML\Module::getModuleURL("consent/style.css") . '" />' . "\n";
+$this->data['head'] = '<link rel="stylesheet" type="text/css" href="'.
+    SimpleSAML\Module::getModuleURL("consent/style.css").'" />'."\n";
 
 $this->includeAtTemplateBase('includes/header.php');
 ?>
 <p><?php echo $this->data['consent_accept']; ?></p>
 
 <?php
-if (isSet($this->data['consent_purpose'])) {
-    echo '<p>' . $this->data['consent_purpose'] . '</p>';
+if (isset($this->data['consent_purpose'])) {
+    echo '<p>'.$this->data['consent_purpose'].'</p>';
 }
 ?>
 
@@ -35,8 +35,8 @@ if (isSet($this->data['consent_purpose'])) {
 <?php
 if ($this->data['usestorage']) {
     $checked = ($this->data['checked'] ? 'checked="checked"' : '');
-    echo '<input type="checkbox" name="saveconsent" ' . $checked .
-        ' value="1" /> ' . $this->t('{consent:consent:remember}');
+    echo '<input type="checkbox" name="saveconsent" '.$checked.
+        ' value="1" /> '.$this->t('{consent:consent:remember}');
 } // Embed hidden fields...
 ?>
     <input type="hidden" name="StateId" value="<?php echo htmlspecialchars($this->data['stateId']); ?>" />
@@ -54,8 +54,8 @@ if ($this->data['usestorage']) {
 
 <?php
 if ($this->data['sppp'] !== false) {
-    echo "<p>" . htmlspecialchars($this->t('{consent:consent:consent_privacypolicy}')) . " ";
-    echo '<a target="_blank" href="' . htmlspecialchars($this->data['sppp']) . '">' . $dstName . "</a>";
+    echo "<p>".htmlspecialchars($this->t('{consent:consent:consent_privacypolicy}'))." ";
+    echo '<a target="_blank" href="'.htmlspecialchars($this->data['sppp']).'">'.$dstName."</a>";
     echo "</p>";
 }
 
@@ -74,40 +74,39 @@ function present_attributes($t, $attributes, $nameParent)
 
     $alternate = array('odd', 'even');
     $i = 0;
-    $summary = 'summary="' . $t->t('{consent:consent:table_summary}') . '"';
+    $summary = 'summary="'.$t->t('{consent:consent:table_summary}').'"';
 
     if (strlen($nameParent) > 0) {
-        $parentStr = strtolower($nameParent) . '_';
-        $str = '<table class="attributes" ' . $summary . '>';
+        $parentStr = strtolower($nameParent).'_';
+        $str = '<table class="attributes" '.$summary.'>';
     } else {
         $parentStr = '';
-        $str = '<table id="table_with_attributes"  class="attributes" '. $summary .'>';
-        $str .= "\n" . '<caption>' . $t->t('{consent:consent:table_caption}') .
-            '</caption>';
+        $str = '<table id="table_with_attributes"  class="attributes" '.$summary.'>';
+        $str .= "\n".'<caption>'.$t->t('{consent:consent:table_caption}').'</caption>';
     }
 
     foreach ($attributes as $name => $value) {
         $nameraw = $name;
-        $name = $translator->getAttributeTranslation($parentStr . $nameraw);
+        $name = $translator->getAttributeTranslation($parentStr.$nameraw);
 
         if (preg_match('/^child_/', $nameraw)) {
             // insert child table
             $parentName = preg_replace('/^child_/', '', $nameraw);
             foreach ($value as $child) {
-                $str .= "\n" . '<tr class="odd"><td style="padding: 2em">' .
-                    present_attributes($t, $child, $parentName) . '</td></tr>';
+                $str .= "\n".'<tr class="odd"><td style="padding: 2em">'.
+                    present_attributes($t, $child, $parentName).'</td></tr>';
             }
         } else {
             // insert values directly
 
-            $str .= "\n" . '<tr class="' . $alternate[($i++ % 2)] .
-                '"><td><span class="attrname">' . htmlspecialchars($name) . '</span>';
+            $str .= "\n".'<tr class="'.$alternate[($i++ % 2)].
+                '"><td><span class="attrname">'.htmlspecialchars($name).'</span>';
 
             $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true);
             if ($isHidden) {
                 $hiddenId = SimpleSAML\Utils\Random::generateID();
 
-                $str .= '<div class="attrvalue" style="display: none;" id="hidden_' . $hiddenId . '">';
+                $str .= '<div class="attrvalue" style="display: none;" id="hidden_'.$hiddenId.'">';
             } else {
                 $str .= '<div class="attrvalue">';
             }
@@ -117,19 +116,19 @@ function present_attributes($t, $attributes, $nameParent)
                 $str .= '<ul>';
                 foreach ($value as $listitem) {
                     if ($nameraw === 'jpegPhoto') {
-                        $str .= '<li><img src="data:image/jpeg;base64,' .
-                            htmlspecialchars($listitem) .
+                        $str .= '<li><img src="data:image/jpeg;base64,'.
+                            htmlspecialchars($listitem).
                             '" alt="User photo" /></li>';
                     } else {
-                        $str .= '<li>' . htmlspecialchars($listitem) . '</li>';
+                        $str .= '<li>'.htmlspecialchars($listitem).'</li>';
                     }
                 }
                 $str .= '</ul>';
             } elseif (isset($value[0])) {
                 // we hawe only one value
                 if ($nameraw === 'jpegPhoto') {
-                    $str .= '<img src="data:image/jpeg;base64,' .
-                        htmlspecialchars($value[0]) .
+                    $str .= '<img src="data:image/jpeg;base64,'.
+                        htmlspecialchars($value[0]).
                         '" alt="User photo" />';
                 } else {
                     $str .= htmlspecialchars($value[0]);
@@ -138,10 +137,10 @@ function present_attributes($t, $attributes, $nameParent)
             $str .= '</div>';
 
             if ($isHidden) {
-                $str .= '<div class="attrvalue consent_showattribute" id="visible_' . $hiddenId . '">';
+                $str .= '<div class="attrvalue consent_showattribute" id="visible_'.$hiddenId.'">';
                 $str .= '... ';
-                $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_' . $hiddenId;
-                $str .= '\'); SimpleSAML_hide(\'visible_' . $hiddenId . '\');">';
+                $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_'.$hiddenId;
+                $str .= '\'); SimpleSAML_hide(\'visible_'.$hiddenId.'\');">';
                 $str .= $t->t('{consent:consent:show_attribute}');
                 $str .= '</a>';
                 $str .= '</div>';
@@ -150,16 +149,15 @@ function present_attributes($t, $attributes, $nameParent)
             $str .= '</td></tr>';
         }	// end else: not child table
     }	// end foreach
-    $str .= isset($attributes)? '</table>':'';
+    $str .= isset($attributes) ? '</table>' : '';
     return $str;
 }
 
-echo '<h3 id="attributeheader">' .
+echo '<h3 id="attributeheader">'.
     $this->t(
         '{consent:consent:consent_attributes_header}',
-        array( 'SPNAME' => $dstName, 'IDPNAME' => $srcName)
-    ) .
-    '</h3>';
+        array('SPNAME' => $dstName, 'IDPNAME' => $srcName)
+    ).'</h3>';
 
 echo $this->data['attributes_html'];
 
diff --git a/modules/consent/templates/noconsent.php b/modules/consent/templates/noconsent.php
index 313ace97f..4ed911533 100644
--- a/modules/consent/templates/noconsent.php
+++ b/modules/consent/templates/noconsent.php
@@ -4,21 +4,21 @@ $this->data['header'] = $this->t('{consent:consent:noconsent_title}');
 
 $this->includeAtTemplateBase('includes/header.php');
 
-echo '<h2>' . $this->data['header'] . '</h2>';
-echo '<p>' . $this->data['noconsent_text'] . '</p>';
+echo '<h2>'.$this->data['header'].'</h2>';
+echo '<p>'.$this->data['noconsent_text'].'</p>';
 
 if ($this->data['resumeFrom']) {
-    echo('<p><a href="' . htmlspecialchars($this->data['resumeFrom']) . '">');
+    echo('<p><a href="'.htmlspecialchars($this->data['resumeFrom']).'">');
     echo($this->t('{consent:consent:noconsent_return}'));
     echo('</a></p>');
 }
 
 if ($this->data['aboutService']) {
-    echo('<p><a href="' . htmlspecialchars($this->data['aboutService']) . '">');
+    echo('<p><a href="'.htmlspecialchars($this->data['aboutService']).'">');
     echo($this->t('{consent:consent:noconsent_goto_about}'));
     echo('</a></p>');
 }
 
-echo('<p><a href="' . htmlspecialchars($this->data['logoutLink']) . '">' . $this->data['noconsent_abort'] . '</a></p>');
+echo('<p><a href="'.htmlspecialchars($this->data['logoutLink']).'">'.$this->data['noconsent_abort'].'</a></p>');
 
 $this->includeAtTemplateBase('includes/footer.php');
diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php
index 3f2faa0c1..8c722126f 100644
--- a/modules/consent/www/getconsent.php
+++ b/modules/consent/www/getconsent.php
@@ -57,7 +57,7 @@ if (array_key_exists('yes', $_REQUEST)) {
     }
     \SimpleSAML\Stats::log('consent:accept', $statsInfo);
 
-    if (   array_key_exists('consent:store', $state) 
+    if (array_key_exists('consent:store', $state) 
         && array_key_exists('saveconsent', $_REQUEST)
         && $_REQUEST['saveconsent'] === '1'
     ) {
@@ -68,13 +68,12 @@ if (array_key_exists('yes', $_REQUEST)) {
         $attributeSet = $state['consent:store.attributeSet'];
 
         \SimpleSAML\Logger::debug(
-            'Consent - saveConsent() : [' . $userId . '|' .
-            $targetedId . '|' .  $attributeSet . ']'
+            'Consent - saveConsent() : ['.$userId.'|'.$targetedId.'|'.$attributeSet.']'
         );	
         try {
             $store->saveConsent($userId, $targetedId, $attributeSet);
         } catch (\Exception $e) {
-            \SimpleSAML\Logger::error('Consent: Error writing to storage: ' . $e->getMessage());
+            \SimpleSAML\Logger::error('Consent: Error writing to storage: '.$e->getMessage());
         }
     }
 
@@ -217,40 +216,39 @@ function present_attributes($t, $attributes, $nameParent)
 
     $alternate = array('odd', 'even');
     $i = 0;
-    $summary = 'summary="' . $translator->t('{consent:consent:table_summary}') . '"';
+    $summary = 'summary="'.$translator->t('{consent:consent:table_summary}').'"';
 
     if (strlen($nameParent) > 0) {
-        $parentStr = strtolower($nameParent) . '_';
-        $str = '<table class="attributes" ' . $summary . '>';
+        $parentStr = strtolower($nameParent).'_';
+        $str = '<table class="attributes" '.$summary.'>';
     } else {
         $parentStr = '';
-        $str = '<table id="table_with_attributes"  class="attributes" '. $summary .'>';
-        $str .= "\n" . '<caption>' . $translator->t('{consent:consent:table_caption}') .
-            '</caption>';
+        $str = '<table id="table_with_attributes"  class="attributes" '.$summary.'>';
+        $str .= "\n".'<caption>'.$translator->t('{consent:consent:table_caption}').'</caption>';
     }
 
     foreach ($attributes as $name => $value) {
         $nameraw = $name;
-        $name = $translator->getAttributeTranslation($parentStr . $nameraw);
+        $name = $translator->getAttributeTranslation($parentStr.$nameraw);
 
         if (preg_match('/^child_/', $nameraw)) {
             // insert child table
             $parentName = preg_replace('/^child_/', '', $nameraw);
             foreach ($value as $child) {
-                $str .= "\n" . '<tr class="odd"><td class="td_odd">' .
-                    present_attributes($t, $child, $parentName) . '</td></tr>';
+                $str .= "\n".'<tr class="odd"><td class="td_odd">'.
+                    present_attributes($t, $child, $parentName).'</td></tr>';
             }
         } else {
             // insert values directly
 
-            $str .= "\n" . '<tr class="' . $alternate[($i++ % 2)] .
-                '"><td><span class="attrname">' . htmlspecialchars($name) . '</span>';
+            $str .= "\n".'<tr class="'.$alternate[($i++ % 2)].
+                '"><td><span class="attrname">'.htmlspecialchars($name).'</span>';
 
             $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true);
             if ($isHidden) {
                 $hiddenId = \SimpleSAML\Utils\Random::generateID();
 
-                $str .= '<div class="attrvalue hidden" id="hidden_' . $hiddenId . '">';
+                $str .= '<div class="attrvalue hidden" id="hidden_'.$hiddenId.'">';
             } else {
                 $str .= '<div class="attrvalue">';
             }
@@ -260,20 +258,18 @@ function present_attributes($t, $attributes, $nameParent)
                 $str .= '<ul>';
                 foreach ($value as $listitem) {
                     if ($nameraw === 'jpegPhoto') {
-                        $str .= '<li><img src="data:image/jpeg;base64,' .
-                            htmlspecialchars($listitem) .
-                            '" alt="User photo" /></li>';
+                        $str .= '<li><img src="data:image/jpeg;base64,'.
+                            htmlspecialchars($listitem).'" alt="User photo" /></li>';
                     } else {
-                        $str .= '<li>' . htmlspecialchars($listitem) . '</li>';
+                        $str .= '<li>'.htmlspecialchars($listitem).'</li>';
                     }
                 }
                 $str .= '</ul>';
             } elseif (isset($value[0])) {
                 // we hawe only one value
                 if ($nameraw === 'jpegPhoto') {
-                    $str .= '<img src="data:image/jpeg;base64,' .
-                        htmlspecialchars($value[0]) .
-                        '" alt="User photo" />';
+                    $str .= '<img src="data:image/jpeg;base64,'.
+                        htmlspecialchars($value[0]).'" alt="User photo" />';
                 } else {
                     $str .= htmlspecialchars($value[0]);
                 }
@@ -281,10 +277,10 @@ function present_attributes($t, $attributes, $nameParent)
             $str .= '</div>';
 
             if ($isHidden) {
-                $str .= '<div class="attrvalue consent_showattribute" id="visible_' . $hiddenId . '">';
+                $str .= '<div class="attrvalue consent_showattribute" id="visible_'.$hiddenId.'">';
                 $str .= '... ';
-                $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_' . $hiddenId;
-                $str .= '\'); SimpleSAML_hide(\'visible_' . $hiddenId . '\');">';
+                $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_'.$hiddenId;
+                $str .= '\'); SimpleSAML_hide(\'visible_'.$hiddenId.'\');">';
                 $str .= $translator->t('{consent:consent:show_attribute}');
                 $str .= '</a>';
                 $str .= '</div>';
-- 
GitLab