From 57c2036c4edde35f8b376a54e5c088209accd9e8 Mon Sep 17 00:00:00 2001
From: Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com>
Date: Wed, 9 May 2018 21:27:40 +0000
Subject: [PATCH] Whitespace-fixes

---
 lib/SimpleSAML/Auth/LDAP.php                 | 92 ++++++++++----------
 modules/ldap/lib/Auth/Process/BaseFilter.php | 48 +++++-----
 modules/ldap/lib/ConfigHelper.php            |  6 +-
 3 files changed, 73 insertions(+), 73 deletions(-)

diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php
index 2c5f699eb..6f36104d8 100644
--- a/lib/SimpleSAML/Auth/LDAP.php
+++ b/lib/SimpleSAML/Auth/LDAP.php
@@ -56,12 +56,12 @@ class SimpleSAML_Auth_LDAP
     public function __construct($hostname, $enable_tls = true, $debug = false, $timeout = 0, $port = 389, $referrals = true)
     {
         // Debug
-        SimpleSAML\Logger::debug('Library - LDAP __construct(): Setup LDAP with ' .
-                        'host=\'' . $hostname .
-                        '\', tls=' . var_export($enable_tls, true) .
-                        ', debug=' . var_export($debug, true) .
-                        ', timeout=' . var_export($timeout, true) .
-                        ', referrals=' . var_export($referrals, true));
+        SimpleSAML\Logger::debug('Library - LDAP __construct(): Setup LDAP with '.
+                        'host=\''.$hostname.
+                        '\', tls='.var_export($enable_tls, true).
+                        ', debug='.var_export($debug, true).
+                        ', timeout='.var_export($timeout, true).
+                        ', referrals='.var_export($referrals, true));
 
         /*
          * Set debug level before calling connect. Note that this passes
@@ -79,7 +79,7 @@ class SimpleSAML_Auth_LDAP
          */
         $this->ldap = @ldap_connect($hostname, $port);
         if ($this->ldap === false) {
-            throw $this->makeException('Library - LDAP __construct(): Unable to connect to \'' . $hostname . '\'', ERR_INTERNAL);
+            throw $this->makeException('Library - LDAP __construct(): Unable to connect to \''.$hostname.'\'', ERR_INTERNAL);
         }
 
         // Enable LDAP protocol version 3
@@ -97,10 +97,10 @@ class SimpleSAML_Auth_LDAP
         $this->timeout = $timeout;
         if ($timeout > 0) {
             if (!@ldap_set_option($this->ldap, LDAP_OPT_NETWORK_TIMEOUT, $timeout)) {
-                SimpleSAML\Logger::warning('Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_NETWORK_TIMEOUT) to ' . $timeout);
+                SimpleSAML\Logger::warning('Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_NETWORK_TIMEOUT) to '.$timeout);
             }
             if (!@ldap_set_option($this->ldap, LDAP_OPT_TIMELIMIT, $timeout)) {
-                SimpleSAML\Logger::warning('Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_TIMELIMIT) to ' . $timeout);
+                SimpleSAML\Logger::warning('Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_TIMELIMIT) to '.$timeout);
             }
         }
 
@@ -136,7 +136,7 @@ class SimpleSAML_Auth_LDAP
         if ($type) {
             if ($errNo !== 0) {
                 // Only log real LDAP errors; not success
-                SimpleSAML\Logger::error($description . '; cause: \'' . ldap_error($this->ldap) . '\' (0x' . dechex($errNo) . ')');
+                SimpleSAML\Logger::error($description.'; cause: \''.ldap_error($this->ldap).'\' (0x'.dechex($errNo).')');
             } else {
                 SimpleSAML\Logger::error($description);
             }
@@ -155,9 +155,9 @@ class SimpleSAML_Auth_LDAP
             }
         } else {
             if ($errNo !== 0) {
-                $description .= '; cause: \'' . ldap_error($this->ldap) . '\' (0x' . dechex($errNo) . ')';
+                $description .= '; cause: \''.ldap_error($this->ldap).'\' (0x'.dechex($errNo).')';
                 if (@ldap_get_option($this->ldap, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extendedError) && !empty($extendedError)) {
-                    $description .= '; additional: \'' . $extendedError . '\'';
+                    $description .= '; additional: \''.$extendedError.'\'';
                 }
             }
             switch ($errNo) {
@@ -212,9 +212,9 @@ class SimpleSAML_Auth_LDAP
         $value = self::escape_filter_value($value, true);
         $filter = '';
         foreach ($attribute as $attr) {
-            $filter .= '(' . $attr . '=' . $value. ')';
+            $filter .= '('.$attr.'='.$value.')';
         }
-        $filter = '(|' . $filter . ')';
+        $filter = '(|'.$filter.')';
 
         // Append LDAP filters if defined
         if ($searchFilter != null) {
@@ -222,7 +222,7 @@ class SimpleSAML_Auth_LDAP
         }
 
         // Search using generated filter
-        SimpleSAML\Logger::debug('Library - LDAP search(): Searching base ('. $scope .') \'' . $base . '\' for \'' . $filter . '\'');
+        SimpleSAML\Logger::debug('Library - LDAP search(): Searching base ('.$scope.') \''.$base.'\' for \''.$filter.'\'');
         if ($scope === 'base') {
             $result = @ldap_read($this->ldap, $base, $filter, array(), 0, 0, $this->timeout, LDAP_DEREF_NEVER);
         } else if ($scope === 'onelevel') {
@@ -232,7 +232,7 @@ class SimpleSAML_Auth_LDAP
         }
 
         if ($result === false) {
-            throw $this->makeException('Library - LDAP search(): Failed search on base \'' . $base . '\' for \'' . $filter . '\'');
+            throw $this->makeException('Library - LDAP search(): Failed search on base \''.$base.'\' for \''.$filter.'\'');
         }
 
         // Sanity checks on search results
@@ -241,21 +241,21 @@ class SimpleSAML_Auth_LDAP
             throw $this->makeException('Library - LDAP search(): Failed to get number of entries returned');
         } elseif ($count > 1) {
             // More than one entry is found. External error
-            throw $this->makeException('Library - LDAP search(): Found ' . $count . ' entries searching base \'' . $base . '\' for \'' . $filter . '\'', ERR_AS_DATA_INCONSIST);
+            throw $this->makeException('Library - LDAP search(): Found '.$count.' entries searching base \''.$base.'\' for \''.$filter.'\'', ERR_AS_DATA_INCONSIST);
         } elseif ($count === 0) {
             // No entry is fond => wrong username is given (or not registered in the catalogue). User error
-            throw $this->makeException('Library - LDAP search(): Found no entries searching base \'' . $base . '\' for \'' . $filter . '\'', ERR_NO_USER);
+            throw $this->makeException('Library - LDAP search(): Found no entries searching base \''.$base.'\' for \''.$filter.'\'', ERR_NO_USER);
         }
 
 
         // Resolve the DN from the search result
         $entry = @ldap_first_entry($this->ldap, $result);
         if ($entry === false) {
-            throw $this->makeException('Library - LDAP search(): Unable to retrieve result after searching base \'' . $base . '\' for \'' . $filter . '\'');
+            throw $this->makeException('Library - LDAP search(): Unable to retrieve result after searching base \''.$base.'\' for \''.$filter.'\'');
         }
         $dn = @ldap_get_dn($this->ldap, $entry);
         if ($dn === false) {
-            throw $this->makeException('Library - LDAP search(): Unable to get DN after searching base \'' . $base . '\' for \'' . $filter . '\'');
+            throw $this->makeException('Library - LDAP search(): Unable to get DN after searching base \''.$base.'\' for \''.$filter.'\'');
         }
         return $dn;
     }
@@ -313,8 +313,8 @@ class SimpleSAML_Auth_LDAP
             return null;
         } else {
             // Zero hits not allowed
-            throw $this->makeException('Library - LDAP searchfordn(): LDAP search returned zero entries for filter \'(' .
-                join(' | ', $attribute) . ' = ' . $value . ')\' on base(s) \'(' . join(' & ', $bases) . ')\'', 2);
+            throw $this->makeException('Library - LDAP searchfordn(): LDAP search returned zero entries for filter \'('.
+                join(' | ', $attribute).' = '.$value.')\' on base(s) \'('.join(' & ', $bases).')\'', 2);
         }
     }
 
@@ -346,7 +346,7 @@ class SimpleSAML_Auth_LDAP
                 $filter .= "($attribute=$value)";
             }
             if (count($filters) > 1) {
-                $filter = ($and ? '(&' : '(|') . $filter . ')';
+                $filter = ($and ? '(&' : '(|').$filter.')';
             }
         } elseif (is_string($filters)) {
             $filter = $filters;
@@ -382,14 +382,14 @@ class SimpleSAML_Auth_LDAP
         // Verify that a result was found in one of the bases
         if ($result === false) {
             throw $this->makeException(
-                'ldap:LdapConnection->search_manual : Failed to search LDAP using base(s) [' .
-                implode('; ', $bases) . '] with filter [' . $filter . ']. LDAP error [' .
-                ldap_error($this->ldap) . ']'
+                'ldap:LdapConnection->search_manual : Failed to search LDAP using base(s) ['.
+                implode('; ', $bases).'] with filter ['.$filter.']. LDAP error ['.
+                ldap_error($this->ldap).']'
             );
         } elseif (@ldap_count_entries($this->ldap, $result) < 1) {
             throw $this->makeException(
-                'ldap:LdapConnection->search_manual : No entries found in LDAP using base(s) [' .
-                implode('; ', $bases) . '] with filter [' . $filter . ']',
+                'ldap:LdapConnection->search_manual : No entries found in LDAP using base(s) ['.
+                implode('; ', $bases).'] with filter ['.$filter.']',
                 ERR_NO_USER
             );
         }
@@ -472,7 +472,7 @@ class SimpleSAML_Auth_LDAP
         if ($error === true) {
             // Good
             $this->authz_id = $authz_id;
-            SimpleSAML\Logger::debug('Library - LDAP bind(): Bind successful with DN \'' . $dn . '\'');
+            SimpleSAML\Logger::debug('Library - LDAP bind(): Bind successful with DN \''.$dn.'\'');
             return true;
         }
 
@@ -495,7 +495,7 @@ class SimpleSAML_Auth_LDAP
         }
 
         // Bad
-        throw $this->makeException('Library - LDAP bind(): Bind failed with DN \'' . $dn . '\'');
+        throw $this->makeException('Library - LDAP bind(): Bind failed with DN \''.$dn.'\'');
     }
 
 
@@ -512,16 +512,16 @@ class SimpleSAML_Auth_LDAP
         // Attempt to set the LDAP option
         if (!@ldap_set_option($this->ldap, $option, $value)) {
             throw $this->makeException(
-                'ldap:LdapConnection->setOption : Failed to set LDAP option [' .
-                $option . '] with the value [' . $value . '] error: ' . ldap_error($this->ldap),
+                'ldap:LdapConnection->setOption : Failed to set LDAP option ['.
+                $option.'] with the value ['.$value.'] error: '.ldap_error($this->ldap),
                 ERR_INTERNAL
             );
         }
 
         // Log debug message
         SimpleSAML\Logger::debug(
-            'ldap:LdapConnection->setOption : Set the LDAP option [' .
-            $option . '] with the value [' . $value . ']'
+            'ldap:LdapConnection->setOption : Set the LDAP option ['.
+            $option.'] with the value ['.$value.']'
         );
     }
 
@@ -547,31 +547,31 @@ class SimpleSAML_Auth_LDAP
         // Preparations, including a pretty debug message...
         $description = 'all attributes';
         if (is_array($attributes)) {
-            $description = '\'' . join(',', $attributes) . '\'';
+            $description = '\''.join(',', $attributes).'\'';
         } else {
             // Get all attributes...
             // TODO: Verify that this originally was the intended behaviour. Could $attributes be a string?
             $attributes = array();
         }
-        SimpleSAML\Logger::debug('Library - LDAP getAttributes(): Getting ' . $description . ' from DN \'' . $dn . '\'');
+        SimpleSAML\Logger::debug('Library - LDAP getAttributes(): Getting '.$description.' from DN \''.$dn.'\'');
 
         // Attempt to get attributes
         // TODO: Should aliases be dereferenced?
         $result = @ldap_read($this->ldap, $dn, 'objectClass=*', $attributes, 0, 0, $this->timeout);
         if ($result === false) {
-            throw $this->makeException('Library - LDAP getAttributes(): Failed to get attributes from DN \'' . $dn . '\'');
+            throw $this->makeException('Library - LDAP getAttributes(): Failed to get attributes from DN \''.$dn.'\'');
         }
         $entry = @ldap_first_entry($this->ldap, $result);
         if ($entry === false) {
-            throw $this->makeException('Library - LDAP getAttributes(): Could not get first entry from DN \'' . $dn . '\'');
+            throw $this->makeException('Library - LDAP getAttributes(): Could not get first entry from DN \''.$dn.'\'');
         }
-        $attributes = @ldap_get_attributes($this->ldap, $entry);  // Recycling $attributes... Possibly bad practice.
+        $attributes = @ldap_get_attributes($this->ldap, $entry); // Recycling $attributes... Possibly bad practice.
         if ($attributes === false) {
-            throw $this->makeException('Library - LDAP getAttributes(): Could not get attributes of first entry from DN \'' . $dn . '\'');
+            throw $this->makeException('Library - LDAP getAttributes(): Could not get attributes of first entry from DN \''.$dn.'\'');
         }
 
         // Parsing each found attribute into our result set
-        $result = array();  // Recycling $result... Possibly bad practice.
+        $result = array(); // Recycling $result... Possibly bad practice.
         for ($i = 0; $i < $attributes['count']; $i++) {
             // Ignore attributes that exceed the maximum allowed size
             $name = $attributes[$i];
@@ -584,8 +584,8 @@ class SimpleSAML_Auth_LDAP
 
                 if (!empty($maxsize) && strlen($value) >= $maxsize) {
                     // Ignoring and warning
-                    SimpleSAML\Logger::warning('Library - LDAP getAttributes(): Attribute \'' .
-                        $name . '\' exceeded maximum allowed size by ' + ($maxsize - strlen($value)));
+                    SimpleSAML\Logger::warning('Library - LDAP getAttributes(): Attribute \''.
+                        $name.'\' exceeded maximum allowed size by ' +($maxsize - strlen($value)));
                     continue;
                 }
 
@@ -602,7 +602,7 @@ class SimpleSAML_Auth_LDAP
         }
 
         // We're done
-        SimpleSAML\Logger::debug('Library - LDAP getAttributes(): Found attributes \'(' . join(',', array_keys($result)) . ')\'');
+        SimpleSAML\Logger::debug('Library - LDAP getAttributes(): Found attributes \'('.join(',', array_keys($result)).')\'');
         return $result;
     }
 
@@ -637,7 +637,7 @@ class SimpleSAML_Auth_LDAP
             // escape characters with a special meaning, also in the password
             $password = addcslashes($password, ',+"\\<>;*');
             if (!$this->bind($dn, $password)) {
-                SimpleSAML\Logger::info('Library - LDAP validate(): Failed to authenticate \''. $username . '\' using DN \'' . $dn . '\'');
+                SimpleSAML\Logger::info('Library - LDAP validate(): Failed to authenticate \''.$username.'\' using DN \''.$dn.'\'');
                 return false;
             }
         }
@@ -679,7 +679,7 @@ class SimpleSAML_Auth_LDAP
             $val = self::asc2hex32($val);
 
             if (null === $val) {
-                $val = '\0';  // apply escaped "null" if string is empty
+                $val = '\0'; // apply escaped "null" if string is empty
             }
 
             $values[$key] = $val;
diff --git a/modules/ldap/lib/Auth/Process/BaseFilter.php b/modules/ldap/lib/Auth/Process/BaseFilter.php
index b8339017a..d7116a2d8 100644
--- a/modules/ldap/lib/Auth/Process/BaseFilter.php
+++ b/modules/ldap/lib/Auth/Process/BaseFilter.php
@@ -99,11 +99,11 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
         // This way if the class is extended the proper name is used
         $classname = get_class($this);
         $classname = explode('_', $classname);
-        $this->title = 'ldap:' . end($classname) . ' : ';
+        $this->title = 'ldap:'.end($classname).' : ';
 
         // Log the construction
         SimpleSAML\Logger::debug(
-            $this->title . 'Creating and configuring the filter.'
+            $this->title.'Creating and configuring the filter.'
         );
 
         // If an authsource was defined (an not empty string)...
@@ -111,8 +111,8 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
 
             // Log the authsource request
             SimpleSAML\Logger::debug(
-                $this->title . 'Attempting to get configuration values from authsource [' .
-                $config['authsource'] . ']'
+                $this->title.'Attempting to get configuration values from authsource ['.
+                $config['authsource'].']'
             );
 
             // Get the authsources file, which should contain the config
@@ -121,7 +121,7 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
             // Verify that the authsource config exists
             if (!$authsource->hasValue($config['authsource'])) {
                 throw new SimpleSAML_Error_Exception(
-                    $this->title . 'Authsource [' . $config['authsource'] .
+                    $this->title.'Authsource ['.$config['authsource'].
                     '] defined in filter parameters not found in authsources.php'
                 );
             }
@@ -134,7 +134,7 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
             // TODO: Support ldap:LDAPMulti, if possible
             if (@$authsource[0] != 'ldap:LDAP') {
                 throw new SimpleSAML_Error_Exception(
-                    $this->title . 'Authsource [' . $config['authsource'] .
+                    $this->title.'Authsource ['.$config['authsource'].
                     '] specified in filter parameters is not an ldap:LDAP type'
                 );
             }
@@ -162,10 +162,10 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
             // only set when search.enabled = true
             if (isset($authsource['search.enable']) && $authsource['search.enable']) {
                 if (isset($authsource['search.base'])) {
-                    $authconfig['ldap.basedn']     = $authsource['search.base'];
+                    $authconfig['ldap.basedn'] = $authsource['search.base'];
                 }
                 if (isset($authsource['search.scope'])) {
-                    $authconfig['ldap.scope']     = $authsource['search.scope'];
+                    $authconfig['ldap.scope'] = $authsource['search.scope'];
                 }
                 if (isset($authsource['search.username'])) {
                     $authconfig['ldap.username']   = $authsource['search.username'];
@@ -195,8 +195,8 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
 
             // Authsource complete
             SimpleSAML\Logger::debug(
-                $this->title . 'Retrieved authsource [' . $config['authsource'] .
-                '] configuration values: ' . $this->var_export($authconfig)
+                $this->title.'Retrieved authsource ['.$config['authsource'].
+                '] configuration values: '.$this->var_export($authconfig)
             );
         }
 
@@ -216,9 +216,9 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
 
         // Log the member values retrieved above
         SimpleSAML\Logger::debug(
-            $this->title . 'Configuration values retrieved;' .
-            ' BaseDN: ' . $this->var_export($this->base_dn) .
-            ' Product: ' . $this->var_export($this->product)
+            $this->title.'Configuration values retrieved;'.
+            ' BaseDN: '.$this->var_export($this->base_dn).
+            ' Product: '.$this->var_export($this->product)
         );
 
         // Setup the attribute map which will be used to search LDAP
@@ -234,7 +234,7 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
 
         // Log the attribute map
         SimpleSAML\Logger::debug(
-            $this->title . 'Attribute map created: ' . $this->var_export($this->attribute_map)
+            $this->title.'Attribute map created: '.$this->var_export($this->attribute_map)
         );
 
         // Setup the object type map which is used to determine a DNs' type
@@ -245,7 +245,7 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
 
         // Log the type map
         SimpleSAML\Logger::debug(
-            $this->title . 'Type map created: ' . $this->var_export($this->type_map)
+            $this->title.'Type map created: '.$this->var_export($this->type_map)
         );
     }
 
@@ -275,15 +275,15 @@ abstract class sspmod_ldap_Auth_Process_BaseFilter extends SimpleSAML_Auth_Proce
 
         // Log the LDAP connection
         SimpleSAML\Logger::debug(
-            $this->title . 'Connecting to LDAP server;' .
-            ' Hostname: ' . $hostname .
-            ' Port: ' . $port .
-            ' Enable TLS: ' . ($enable_tls ? 'Yes' : 'No') .
-            ' Debug: ' . ($debug ? 'Yes' : 'No') .
-            ' Referrals: ' . ($referrals ? 'Yes' : 'No') .
-            ' Timeout: ' . $timeout .
-            ' Username: ' . $username .
-            ' Password: ' . (empty($password) ? '' : '********')
+            $this->title.'Connecting to LDAP server;'.
+            ' Hostname: '.$hostname.
+            ' Port: '.$port.
+            ' Enable TLS: '.($enable_tls ? 'Yes' : 'No').
+            ' Debug: '.($debug ? 'Yes' : 'No').
+            ' Referrals: '.($referrals ? 'Yes' : 'No').
+            ' Timeout: '.$timeout.
+            ' Username: '.$username.
+            ' Password: '.(empty($password) ? '' : '********')
         );
 
         // Connect to the LDAP server to be queried during processing
diff --git a/modules/ldap/lib/ConfigHelper.php b/modules/ldap/lib/ConfigHelper.php
index 0abfc1f42..c02adf8b0 100644
--- a/modules/ldap/lib/ConfigHelper.php
+++ b/modules/ldap/lib/ConfigHelper.php
@@ -184,7 +184,7 @@ class sspmod_ldap_ConfigHelper
         assert(is_string($password));
 
         if (empty($password)) {
-            SimpleSAML\Logger::info($this->location . ': Login with empty password disallowed.');
+            SimpleSAML\Logger::info($this->location.': Login with empty password disallowed.');
             throw new SimpleSAML_Error_Error('WRONGUSERPASS');
         }
 
@@ -203,13 +203,13 @@ class sspmod_ldap_ConfigHelper
             $dn = $ldap->searchfordn($this->searchBase, $this->searchAttributes, $username, true, $this->searchFilter, $this->searchScope);
             if ($dn === null) {
                 /* User not found with search. */
-                SimpleSAML\Logger::info($this->location . ': Unable to find users DN. username=\'' . $username . '\'');
+                SimpleSAML\Logger::info($this->location.': Unable to find users DN. username=\''.$username.'\'');
                 throw new SimpleSAML_Error_Error('WRONGUSERPASS');
             }
         }
 
         if (!$ldap->bind($dn, $password, $sasl_args)) {
-            SimpleSAML\Logger::info($this->location . ': '. $username . ' failed to authenticate. DN=' . $dn);
+            SimpleSAML\Logger::info($this->location.': '.$username.' failed to authenticate. DN='.$dn);
             throw new SimpleSAML_Error_Error('WRONGUSERPASS');
         }
 
-- 
GitLab