diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-26 09:30:18 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-26 16:34:56 +0100 |
commit | b80ebc96748b45fd2e0ba9323308657c4b00b7ec (patch) | |
tree | ec20e0ffa2f86b9b54939a83a785407319f94559 /apps/user_ldap | |
parent | 62403d0932be7d620c7bdadc6b4e13eb496fcd6f (diff) | |
download | nextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.tar.gz nextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.zip |
Use the short array syntax, everywhere
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/user_ldap')
41 files changed, 377 insertions, 377 deletions
diff --git a/apps/user_ldap/ajax/clearMappings.php b/apps/user_ldap/ajax/clearMappings.php index 3e98162904c..f847b818db0 100644 --- a/apps/user_ldap/ajax/clearMappings.php +++ b/apps/user_ldap/ajax/clearMappings.php @@ -56,5 +56,5 @@ try { } \OC_JSON::success(); } catch (\Exception $e) { - \OC_JSON::error(array('message' => $e->getMessage())); + \OC_JSON::error(['message' => $e->getMessage()]); } diff --git a/apps/user_ldap/ajax/deleteConfiguration.php b/apps/user_ldap/ajax/deleteConfiguration.php index d6bce7439f7..c2bf4f265d0 100644 --- a/apps/user_ldap/ajax/deleteConfiguration.php +++ b/apps/user_ldap/ajax/deleteConfiguration.php @@ -36,5 +36,5 @@ if($helper->deleteServerConfiguration($prefix)) { \OC_JSON::success(); } else { $l = \OC::$server->getL10N('user_ldap'); - \OC_JSON::error(array('message' => $l->t('Failed to delete the server configuration'))); + \OC_JSON::error(['message' => $l->t('Failed to delete the server configuration')]); } diff --git a/apps/user_ldap/ajax/getConfiguration.php b/apps/user_ldap/ajax/getConfiguration.php index b8ed917de6e..8c9a3a6c3f6 100644 --- a/apps/user_ldap/ajax/getConfiguration.php +++ b/apps/user_ldap/ajax/getConfiguration.php @@ -38,4 +38,4 @@ if (isset($configuration['ldap_agent_password']) && $configuration['ldap_agent_p // hide password $configuration['ldap_agent_password'] = '**PASSWORD SET**'; } -\OC_JSON::success(array('configuration' => $configuration)); +\OC_JSON::success(['configuration' => $configuration]); diff --git a/apps/user_ldap/ajax/getNewServerConfigPrefix.php b/apps/user_ldap/ajax/getNewServerConfigPrefix.php index 9c6f63fc3de..9d93b2b8971 100644 --- a/apps/user_ldap/ajax/getNewServerConfigPrefix.php +++ b/apps/user_ldap/ajax/getNewServerConfigPrefix.php @@ -35,7 +35,7 @@ $lk = array_pop($serverConnections); $ln = (int)str_replace('s', '', $lk); $nk = 's'.str_pad($ln+1, 2, '0', STR_PAD_LEFT); -$resultData = array('configPrefix' => $nk); +$resultData = ['configPrefix' => $nk]; $newConfig = new \OCA\User_LDAP\Configuration($nk, false); if(isset($_POST['copyConfig'])) { diff --git a/apps/user_ldap/ajax/setConfiguration.php b/apps/user_ldap/ajax/setConfiguration.php index 31aa80d0945..fd8a2b0c1b5 100644 --- a/apps/user_ldap/ajax/setConfiguration.php +++ b/apps/user_ldap/ajax/setConfiguration.php @@ -35,8 +35,8 @@ $prefix = (string)$_POST['ldap_serverconfig_chooser']; // Checkboxes are not submitted, when they are unchecked. Set them manually. // only legacy checkboxes (Advanced and Expert tab) need to be handled here, // the Wizard-like tabs handle it on their own -$chkboxes = array('ldap_configuration_active', 'ldap_override_main_server', - 'ldap_turn_off_cert_check'); +$chkboxes = ['ldap_configuration_active', 'ldap_override_main_server', + 'ldap_turn_off_cert_check']; foreach($chkboxes as $boxid) { if(!isset($_POST[$boxid])) { $_POST[$boxid] = 0; diff --git a/apps/user_ldap/ajax/testConfiguration.php b/apps/user_ldap/ajax/testConfiguration.php index 00393ff66e3..a21cb407558 100644 --- a/apps/user_ldap/ajax/testConfiguration.php +++ b/apps/user_ldap/ajax/testConfiguration.php @@ -66,23 +66,23 @@ try { * pass (like e.g. expected syntax error). */ try { - $ldapWrapper->read($connection->getConnectionResource(), '', 'objectClass=*', array('dn')); + $ldapWrapper->read($connection->getConnectionResource(), '', 'objectClass=*', ['dn']); } catch (\Exception $e) { if($e->getCode() === 1) { - \OC_JSON::error(array('message' => $l->t('Invalid configuration: Anonymous binding is not allowed.'))); + \OC_JSON::error(['message' => $l->t('Invalid configuration: Anonymous binding is not allowed.')]); exit; } } - \OC_JSON::success(array('message' - => $l->t('Valid configuration, connection established!'))); + \OC_JSON::success(['message' + => $l->t('Valid configuration, connection established!')]); } else { - \OC_JSON::error(array('message' - => $l->t('Valid configuration, but binding failed. Please check the server settings and credentials.'))); + \OC_JSON::error(['message' + => $l->t('Valid configuration, but binding failed. Please check the server settings and credentials.')]); } } else { - \OC_JSON::error(array('message' - => $l->t('Invalid configuration. Please have a look at the logs for further details.'))); + \OC_JSON::error(['message' + => $l->t('Invalid configuration. Please have a look at the logs for further details.')]); } } catch (\Exception $e) { - \OC_JSON::error(array('message' => $e->getMessage())); + \OC_JSON::error(['message' => $e->getMessage()]); } diff --git a/apps/user_ldap/ajax/wizard.php b/apps/user_ldap/ajax/wizard.php index 3cce732f070..1756e978de2 100644 --- a/apps/user_ldap/ajax/wizard.php +++ b/apps/user_ldap/ajax/wizard.php @@ -36,13 +36,13 @@ $l = \OC::$server->getL10N('user_ldap'); if(!isset($_POST['action'])) { - \OC_JSON::error(array('message' => $l->t('No action specified'))); + \OC_JSON::error(['message' => $l->t('No action specified')]); } $action = (string)$_POST['action']; if(!isset($_POST['ldap_serverconfig_chooser'])) { - \OC_JSON::error(array('message' => $l->t('No configuration specified'))); + \OC_JSON::error(['message' => $l->t('No configuration specified')]); } $prefix = (string)$_POST['ldap_serverconfig_chooser']; @@ -99,7 +99,7 @@ switch($action) { exit; } } catch (\Exception $e) { - \OC_JSON::error(array('message' => $e->getMessage(), 'code' => $e->getCode())); + \OC_JSON::error(['message' => $e->getMessage(), 'code' => $e->getCode()]); exit; } \OC_JSON::error(); @@ -115,7 +115,7 @@ switch($action) { exit; } } catch (\Exception $e) { - \OC_JSON::error(array('message' => $e->getMessage())); + \OC_JSON::error(['message' => $e->getMessage()]); exit; } \OC_JSON::error(); @@ -127,15 +127,15 @@ switch($action) { $key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false; $val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null; if($key === false || is_null($val)) { - \OC_JSON::error(array('message' => $l->t('No data specified'))); + \OC_JSON::error(['message' => $l->t('No data specified')]); exit; } - $cfg = array($key => $val); - $setParameters = array(); + $cfg = [$key => $val]; + $setParameters = []; $configuration->setConfiguration($cfg, $setParameters); if(!in_array($key, $setParameters)) { - \OC_JSON::error(array('message' => $l->t($key. - ' Could not set configuration %s', $setParameters[0]))); + \OC_JSON::error(['message' => $l->t($key. + ' Could not set configuration %s', $setParameters[0])]); exit; } $configuration->saveConfiguration(); @@ -145,6 +145,6 @@ switch($action) { \OC_JSON::success(); break; default: - \OC_JSON::error(array('message' => $l->t('Action does not exist'))); + \OC_JSON::error(['message' => $l->t('Action does not exist')]); break; } diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index a16e8f04cb2..6f6e3648e30 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -75,7 +75,7 @@ class Access extends LDAPUtility { /** * @var string[] $cookies an array of returned Paged Result cookies */ - protected $cookies = array(); + protected $cookies = []; /** * @var string $lastCookie the last cookie returned from a Paged Results @@ -268,9 +268,9 @@ class Access extends LDAPUtility { * @throws ServerNotAvailableException */ public function executeRead($cr, $dn, $attribute, $filter, $maxResults) { - $this->initPagedSearch($filter, array($dn), array($attribute), $maxResults, 0); + $this->initPagedSearch($filter, [$dn], [$attribute], $maxResults, 0); $dn = $this->helper->DNasBaseParameter($dn); - $rr = @$this->invokeLDAPMethod('read', $cr, $dn, $filter, array($attribute)); + $rr = @$this->invokeLDAPMethod('read', $cr, $dn, $filter, [$attribute]); if (!$this->ldap->isResource($rr)) { if ($attribute !== '') { //do not throw this message on userExists check, irritates @@ -384,13 +384,13 @@ class Access extends LDAPUtility { * @return boolean if so true, otherwise false */ private function resemblesDN($attr) { - $resemblingAttributes = array( + $resemblingAttributes = [ 'dn', 'uniquemember', 'member', // memberOf is an "operational" attribute, without a definition in any RFC 'memberof' - ); + ]; return in_array($attr, $resemblingAttributes); } @@ -419,7 +419,7 @@ class Access extends LDAPUtility { //not a valid DN return ''; } - $domainParts = array(); + $domainParts = []; $dcFound = false; foreach($allParts as $part) { if(!$dcFound && strpos($part, 'dc=') === 0) { @@ -865,13 +865,13 @@ class Access extends LDAPUtility { */ private function createAltInternalOwnCloudName($name, $isUser) { $originalTTL = $this->connection->ldapCacheTTL; - $this->connection->setConfiguration(array('ldapCacheTTL' => 0)); + $this->connection->setConfiguration(['ldapCacheTTL' => 0]); if($isUser) { $altName = $this->_createAltInternalOwnCloudNameForUsers($name); } else { $altName = $this->_createAltInternalOwnCloudNameForGroups($name); } - $this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL)); + $this->connection->setConfiguration(['ldapCacheTTL' => $originalTTL]); return $altName; } @@ -884,7 +884,7 @@ class Access extends LDAPUtility { * @param array $attributes optional, list of attributes to read * @return array */ - public function fetchUsersByLoginName($loginName, $attributes = array('dn')) { + public function fetchUsersByLoginName($loginName, $attributes = ['dn']) { $loginName = $this->escapeFilterPart($loginName); $filter = str_replace('%uid', $loginName, $this->connection->ldapLoginFilter); return $this->fetchListOfUsers($filter, $attributes); @@ -996,13 +996,13 @@ class Access extends LDAPUtility { $attribute = array_keys($item)[0]; $carry[] = $item[$attribute][0]; return $carry; - }, array()); + }, []); return array_unique($list, SORT_LOCALE_STRING); } } //error cause actually, maybe throw an exception in future. - return array(); + return []; } /** @@ -1033,7 +1033,7 @@ class Access extends LDAPUtility { * @return false|int * @throws ServerNotAvailableException */ - public function countUsers($filter, $attr = array('dn'), $limit = null, $offset = null) { + public function countUsers($filter, $attr = ['dn'], $limit = null, $offset = null) { $result = false; foreach($this->connection->ldapBaseUsers as $base) { $count = $this->count($filter, [$base], $attr, $limit, $offset); @@ -1072,7 +1072,7 @@ class Access extends LDAPUtility { * @return int|bool * @throws ServerNotAvailableException */ - public function countGroups($filter, $attr = array('dn'), $limit = null, $offset = null) { + public function countGroups($filter, $attr = ['dn'], $limit = null, $offset = null) { $result = false; foreach($this->connection->ldapBaseGroups as $base) { $count = $this->count($filter, [$base], $attr, $limit, $offset); @@ -1122,7 +1122,7 @@ class Access extends LDAPUtility { if ($command == 'controlPagedResultResponse') { throw new \InvalidArgumentException('Invoker does not support controlPagedResultResponse, call LDAP Wrapper directly instead.'); } else { - return call_user_func_array(array($this->ldap, $command), $arguments); + return call_user_func_array([$this->ldap, $command], $arguments); } }; try { @@ -1162,7 +1162,7 @@ class Access extends LDAPUtility { */ private function executeSearch($filter, $base, &$attr = null, $limit = null, $offset = null) { if(!is_null($attr) && !is_array($attr)) { - $attr = array(mb_strtolower($attr, 'UTF-8')); + $attr = [mb_strtolower($attr, 'UTF-8')]; } // See if we have a resource, in case not cancel with message @@ -1177,7 +1177,7 @@ class Access extends LDAPUtility { //check whether paged search should be attempted $pagedSearchOK = $this->initPagedSearch($filter, $base, $attr, (int)$limit, $offset); - $linkResources = array_pad(array(), count($base), $cr); + $linkResources = array_pad([], count($base), $cr); $sr = $this->invokeLDAPMethod('search', $linkResources, $base, $filter, $attr); // cannot use $cr anymore, might have changed in the previous call! $error = $this->ldap->errno($this->connection->getConnectionResource()); @@ -1186,7 +1186,7 @@ class Access extends LDAPUtility { return false; } - return array($sr, $pagedSearchOK); + return [$sr, $pagedSearchOK]; } /** @@ -1349,7 +1349,7 @@ class Access extends LDAPUtility { $this->processPagedSearchStatus($sr, $filter, $base, 1, $limitPerPage, $offset, $pagedSearchOK, $skipHandling); - return array(); + return []; } $iFoundItems = 0; @@ -1370,7 +1370,7 @@ class Access extends LDAPUtility { // if we're here, probably no connection resource is returned. // to make Nextcloud behave nicely, we simply give back an empty array. if(is_null($findings)) { - return array(); + return []; } if(!is_null($attr)) { @@ -1463,8 +1463,8 @@ class Access extends LDAPUtility { $asterisk = '*'; $input = mb_substr($input, 1, null, 'UTF-8'); } - $search = array('*', '\\', '(', ')'); - $replace = array('\\*', '\\\\', '\\(', '\\)'); + $search = ['*', '\\', '(', ')']; + $replace = ['\\*', '\\\\', '\\(', '\\)']; return $asterisk . str_replace($search, $replace, $input); } @@ -1541,11 +1541,11 @@ class Access extends LDAPUtility { throw new \Exception('searchAttributes must be an array with at least two string'); } $searchWords = explode(' ', trim($search)); - $wordFilters = array(); + $wordFilters = []; foreach($searchWords as $word) { $word = $this->prepareSearchTerm($word); //every word needs to appear at least once - $wordMatchOneAttrFilters = array(); + $wordMatchOneAttrFilters = []; foreach($searchAttributes as $attr) { $wordMatchOneAttrFilters[] = $attr . '=' . $word; } @@ -1563,7 +1563,7 @@ class Access extends LDAPUtility { * @return string the final filter part to use in LDAP searches */ private function getFilterPartForSearch($search, $searchAttributes, $fallbackAttribute) { - $filter = array(); + $filter = []; $haveMultiSearchAttributes = (is_array($searchAttributes) && count($searchAttributes) > 0); if($haveMultiSearchAttributes && strpos(trim($search), ' ') !== false) { try { @@ -1619,10 +1619,10 @@ class Access extends LDAPUtility { * @return string */ public function getFilterForUserCount() { - $filter = $this->combineFilterWithAnd(array( + $filter = $this->combineFilterWithAnd([ $this->connection->ldapUserFilter, $this->connection->ldapUserDisplayName . '=*' - )); + ]); return $filter; } @@ -1635,10 +1635,10 @@ class Access extends LDAPUtility { public function areCredentialsValid($name, $password) { $name = $this->helper->DNasBaseParameter($name); $testConnection = clone $this->connection; - $credentials = array( + $credentials = [ 'ldapAgentName' => $name, 'ldapAgentPassword' => $password - ); + ]; if(!$testConnection->setConfiguration($credentials)) { return false; } @@ -1919,7 +1919,7 @@ class Access extends LDAPUtility { // precision (see https://gist.github.com/bantu/886ac680b0aef5812f71) $iav = number_format(hexdec(bin2hex(substr($sid, 2, 6))), 0, '', ''); - $subIDs = array(); + $subIDs = []; for ($i = 0; $i < $numberSubID; $i++) { $subID = unpack('V', substr($sid, $subIdStart + $subIdLength * $i, $subIdLength)); $subIDs[] = sprintf('%u', $subID[1]); @@ -2065,7 +2065,7 @@ class Access extends LDAPUtility { // to start from 0 to come to the desired page. cookie value // of '0' is valid, because 389ds $reOffset = ($offset - $limit) < 0 ? 0 : $offset - $limit; - $this->search($filter, array($base), $attr, $limit, $reOffset, true); + $this->search($filter, [$base], $attr, $limit, $reOffset, true); $cookie = $this->getPagedResultCookie($base, $filter, $limit, $offset); //still no cookie? obviously, the server does not like us. Let's skip paging efforts. // '0' is valid, because 389ds diff --git a/apps/user_ldap/lib/Command/ShowConfig.php b/apps/user_ldap/lib/Command/ShowConfig.php index fd33a0bc0df..46d08986617 100644 --- a/apps/user_ldap/lib/Command/ShowConfig.php +++ b/apps/user_ldap/lib/Command/ShowConfig.php @@ -94,8 +94,8 @@ class ShowConfig extends Command { ksort($configuration); $table = new Table($output); - $table->setHeaders(array('Configuration', $id)); - $rows = array(); + $table->setHeaders(['Configuration', $id]); + $rows = []; foreach($configuration as $key => $value) { if($key === 'ldapAgentPassword' && !$withPassword) { $value = '***'; @@ -103,7 +103,7 @@ class ShowConfig extends Command { if(is_array($value)) { $value = implode(';', $value); } - $rows[] = array($key, $value); + $rows[] = [$key, $value]; } $table->setRows($rows); $table->render($output); diff --git a/apps/user_ldap/lib/Command/TestConfig.php b/apps/user_ldap/lib/Command/TestConfig.php index 67ff73d4e91..b38d2e972a2 100644 --- a/apps/user_ldap/lib/Command/TestConfig.php +++ b/apps/user_ldap/lib/Command/TestConfig.php @@ -80,9 +80,9 @@ class TestConfig extends Command { //ensure validation is run before we attempt the bind $connection->getConfiguration(); - if(!$connection->setConfiguration(array( + if(!$connection->setConfiguration([ 'ldap_configuration_active' => 1, - ))) { + ])) { return 1; } if($connection->bind()) { diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php index 724f240847a..9fa386a8215 100644 --- a/apps/user_ldap/lib/Configuration.php +++ b/apps/user_ldap/lib/Configuration.php @@ -53,7 +53,7 @@ class Configuration { protected $unsavedChanges = ['ldapConfigurationActive' => 'ldapConfigurationActive']; //settings - protected $config = array( + protected $config = [ 'ldapHost' => null, 'ldapPort' => null, 'ldapBackupHost' => null, @@ -109,7 +109,7 @@ class Configuration { 'ldapDynamicGroupMemberURL' => null, 'ldapDefaultPPolicyDN' => null, 'ldapExtStorageHomeAttribute' => null, - ); + ]; /** * @param string $configPrefix @@ -138,7 +138,7 @@ class Configuration { * @param mixed $value */ public function __set($name, $value) { - $this->setConfiguration(array($name => $value)); + $this->setConfiguration([$name => $value]); } /** @@ -426,7 +426,7 @@ class Configuration { * to config-value entries in the database table */ public function getDefaults() { - return array( + return [ 'ldap_host' => '', 'ldap_port' => '', 'ldap_backup_host' => '', @@ -481,7 +481,7 @@ class Configuration { 'ldap_default_ppolicy_dn' => '', 'ldap_user_avatar_rule' => 'default', 'ldap_ext_storage_home_attribute' => '', - ); + ]; } /** @@ -489,7 +489,7 @@ class Configuration { */ public function getConfigTranslationArray() { //TODO: merge them into one representation - static $array = array( + static $array = [ 'ldap_host' => 'ldapHost', 'ldap_port' => 'ldapPort', 'ldap_backup_host' => 'ldapBackupHost', @@ -543,7 +543,7 @@ class Configuration { 'ldap_default_ppolicy_dn' => 'ldapDefaultPPolicyDN', 'ldap_ext_storage_home_attribute' => 'ldapExtStorageHomeAttribute', 'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig - ); + ]; return $array; } diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 8d499a4ee1c..5e2d7fb8583 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -298,7 +298,7 @@ class Connection extends LDAPUtility { */ public function setConfiguration($config, &$setParameters = null) { if(is_null($setParameters)) { - $setParameters = array(); + $setParameters = []; } $this->doNotValidate = false; $this->configuration->setConfiguration($config, $setParameters); @@ -328,7 +328,7 @@ class Connection extends LDAPUtility { $this->readConfiguration(); $config = $this->configuration->getConfiguration(); $cta = $this->configuration->getConfigTranslationArray(); - $result = array(); + $result = []; foreach($cta as $dbkey => $configkey) { switch($configkey) { case 'homeFolderNamingRule': @@ -356,15 +356,15 @@ class Connection extends LDAPUtility { private function doSoftValidation() { //if User or Group Base are not set, take over Base DN setting - foreach(array('ldapBaseUsers', 'ldapBaseGroups') as $keyBase) { + foreach(['ldapBaseUsers', 'ldapBaseGroups'] as $keyBase) { $val = $this->configuration->$keyBase; if(empty($val)) { $this->configuration->$keyBase = $this->configuration->ldapBase; } } - foreach(array('ldapExpertUUIDUserAttr' => 'ldapUuidUserAttribute', - 'ldapExpertUUIDGroupAttr' => 'ldapUuidGroupAttribute') + foreach(['ldapExpertUUIDUserAttr' => 'ldapUuidUserAttribute', + 'ldapExpertUUIDGroupAttr' => 'ldapUuidGroupAttribute'] as $expertSetting => $effectiveSetting) { $uuidOverride = $this->configuration->$expertSetting; if(!empty($uuidOverride)) { @@ -392,12 +392,12 @@ class Connection extends LDAPUtility { } //make sure empty search attributes are saved as simple, empty array - $saKeys = array('ldapAttributesForUserSearch', - 'ldapAttributesForGroupSearch'); + $saKeys = ['ldapAttributesForUserSearch', + 'ldapAttributesForGroupSearch']; foreach($saKeys as $key) { $val = $this->configuration->$key; if(is_array($val) && count($val) === 1 && empty($val[0])) { - $this->configuration->$key = array(); + $this->configuration->$key = []; } } @@ -421,8 +421,8 @@ class Connection extends LDAPUtility { (string)$this->configPrefix .'): '; //options that shall not be empty - $options = array('ldapHost', 'ldapPort', 'ldapUserDisplayName', - 'ldapGroupDisplayName', 'ldapLoginFilter'); + $options = ['ldapHost', 'ldapPort', 'ldapUserDisplayName', + 'ldapGroupDisplayName', 'ldapLoginFilter']; foreach($options as $key) { $val = $this->configuration->$key; if(empty($val)) { diff --git a/apps/user_ldap/lib/GroupPluginManager.php b/apps/user_ldap/lib/GroupPluginManager.php index 115cc8d3fdb..f1b36923ada 100644 --- a/apps/user_ldap/lib/GroupPluginManager.php +++ b/apps/user_ldap/lib/GroupPluginManager.php @@ -29,14 +29,14 @@ class GroupPluginManager { private $respondToActions = 0; - private $which = array( + private $which = [ GroupInterface::CREATE_GROUP => null, GroupInterface::DELETE_GROUP => null, GroupInterface::ADD_TO_GROUP => null, GroupInterface::REMOVE_FROM_GROUP => null, GroupInterface::COUNT_USERS => null, GroupInterface::GROUP_DETAILS => null - ); + ]; /** * @return int All implemented actions diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index 40b8bcf16c9..c19f6ac4ed6 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -138,8 +138,8 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD //extra work if we don't get back user DNs if(strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid') { - $dns = array(); - $filterParts = array(); + $dns = []; + $filterParts = []; $bytes = 0; foreach($members as $mid) { $filter = str_replace('%uid', $mid, $this->access->connection->ldapLoginFilter); @@ -150,7 +150,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD // to take even the chance to exceed it $filter = $this->access->combineFilterWithOr($filterParts); $bytes = 0; - $filterParts = array(); + $filterParts = []; $users = $this->access->fetchListOfUsers($filter, 'dn', count($filterParts)); $dns = array_merge($dns, $users); } @@ -182,10 +182,10 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD $dynamicGroupMemberURL = strtolower($this->access->connection->ldapDynamicGroupMemberURL); if (empty($dynamicGroupMemberURL)) { - return array(); + return []; } - $dynamicMembers = array(); + $dynamicMembers = []; $memberURLs = $this->access->readAttribute( $dnGroup, $dynamicGroupMemberURL, @@ -199,7 +199,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD if ($pos !== false) { $memberUrlFilter = substr($memberURLs[0], $pos); $foundMembers = $this->access->searchUsers($memberUrlFilter,'dn'); - $dynamicMembers = array(); + $dynamicMembers = []; foreach($foundMembers as $value) { $dynamicMembers[$value['dn'][0]] = 1; } @@ -335,7 +335,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD 'objectClass=posixGroup', $this->access->connection->ldapGidNumber . '=' . $gid ]); - $result = $this->access->searchGroups($filter, array('dn'), 1); + $result = $this->access->searchGroups($filter, ['dn'], 1); if(empty($result)) { return false; } @@ -493,11 +493,11 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD } //we need to get the DN from LDAP - $filter = $this->access->combineFilterWithAnd(array( + $filter = $this->access->combineFilterWithAnd([ $this->access->connection->ldapGroupFilter, 'objectsid=' . $domainObjectSid . '-' . $gid - )); - $result = $this->access->searchGroups($filter, array('dn'), 1); + ]); + $result = $this->access->searchGroups($filter, ['dn'], 1); if(empty($result)) { return false; } @@ -590,13 +590,13 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD $filter = $this->prepareFilterForUsersInPrimaryGroup($groupDN, $search); $users = $this->access->fetchListOfUsers( $filter, - array($this->access->connection->ldapUserDisplayName, 'dn'), + [$this->access->connection->ldapUserDisplayName, 'dn'], $limit, $offset ); return $this->access->nextcloudUserNames($users); } catch (\Exception $e) { - return array(); + return []; } } @@ -612,7 +612,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD public function countUsersInPrimaryGroup($groupDN, $search = '', $limit = -1, $offset = 0) { try { $filter = $this->prepareFilterForUsersInPrimaryGroup($groupDN, $search); - $users = $this->access->countUsers($filter, array('dn'), $limit, $offset); + $users = $this->access->countUsers($filter, ['dn'], $limit, $offset); return (int)$users; } catch (\Exception $e) { return 0; @@ -648,7 +648,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD */ public function getUserGroups($uid) { if(!$this->enabled) { - return array(); + return []; } $cacheKey = 'getUserGroups'.$uid; $userGroups = $this->access->connection->getFromCache($cacheKey); @@ -657,8 +657,8 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD } $userDN = $this->access->username2dn($uid); if(!$userDN) { - $this->access->connection->writeToCache($cacheKey, array()); - return array(); + $this->access->connection->writeToCache($cacheKey, []); + return []; } $groups = []; @@ -670,7 +670,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD if (!empty($dynamicGroupMemberURL)) { // look through dynamic groups to add them to the result array if needed $groupsToMatch = $this->access->fetchListOfGroups( - $this->access->connection->ldapGroupFilter,array('dn',$dynamicGroupMemberURL)); + $this->access->connection->ldapGroupFilter,['dn',$dynamicGroupMemberURL]); foreach($groupsToMatch as $dynamicGroup) { if (!array_key_exists($dynamicGroupMemberURL, $dynamicGroup)) { continue; @@ -816,10 +816,10 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD */ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { if(!$this->enabled) { - return array(); + return []; } if(!$this->groupExists($gid)) { - return array(); + return []; } $search = $this->access->escapeFilterPart($search, true); $cacheKey = 'usersInGroup-'.$gid.'-'.$search.'-'.$limit.'-'.$offset; @@ -843,8 +843,8 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD $groupDN = $this->access->groupname2dn($gid); if(!$groupDN) { // group couldn't be found, return empty resultset - $this->access->connection->writeToCache($cacheKey, array()); - return array(); + $this->access->connection->writeToCache($cacheKey, []); + return []; } $primaryUsers = $this->getUsersInPrimaryGroup($groupDN, $search, $limit, $offset); @@ -856,19 +856,19 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD return []; } - $groupUsers = array(); + $groupUsers = []; $isMemberUid = (strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid'); $attrs = $this->access->userManager->getAttributes(true); foreach($members as $member) { if($isMemberUid) { //we got uids, need to get their DNs to 'translate' them to user names - $filter = $this->access->combineFilterWithAnd(array( + $filter = $this->access->combineFilterWithAnd([ str_replace('%uid', trim($member), $this->access->connection->ldapLoginFilter), $this->access->combineFilterWithAnd([ $this->access->getFilterPartForUserSearch($search), $this->access->connection->ldapUserFilter ]) - )); + ]); $ldap_users = $this->access->fetchListOfUsers($filter, $attrs, 1); if(count($ldap_users) < 1) { continue; @@ -968,14 +968,14 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD // and let it count. //For now this is not important, because the only use of this method //does not supply a search string - $groupUsers = array(); + $groupUsers = []; foreach($members as $member) { if($isMemberUid) { //we got uids, need to get their DNs to 'translate' them to user names - $filter = $this->access->combineFilterWithAnd(array( + $filter = $this->access->combineFilterWithAnd([ str_replace('%uid', $member, $this->access->connection->ldapLoginFilter), $this->access->getFilterPartForUserSearch($search) - )); + ]); $ldap_users = $this->access->fetchListOfUsers($filter, 'dn', 1); if(count($ldap_users) < 1) { continue; @@ -1013,7 +1013,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD */ protected function getGroupsChunk($search = '', $limit = -1, $offset = 0) { if(!$this->enabled) { - return array(); + return []; } $cacheKey = 'getGroups-'.$search.'-'.$limit.'-'.$offset; @@ -1029,13 +1029,13 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD if($limit <= 0) { $limit = null; } - $filter = $this->access->combineFilterWithAnd(array( + $filter = $this->access->combineFilterWithAnd([ $this->access->connection->ldapGroupFilter, $this->access->getFilterPartForGroupSearch($search) - )); + ]); \OCP\Util::writeLog('user_ldap', 'getGroups Filter '.$filter, ILogger::DEBUG); $ldap_groups = $this->access->fetchListOfGroups($filter, - array($this->access->connection->ldapGroupDisplayName, 'dn'), + [$this->access->connection->ldapGroupDisplayName, 'dn'], $limit, $offset); $ldap_groups = $this->access->nextcloudGroupNames($ldap_groups); @@ -1059,7 +1059,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD */ public function getGroups($search = '', $limit = -1, $offset = 0) { if(!$this->enabled) { - return array(); + return []; } $search = $this->access->escapeFilterPart($search, true); $pagingSize = (int)$this->access->connection->ldapPagingSize; @@ -1073,7 +1073,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD $overallLimit = $maxGroups; } $chunkOffset = $offset; - $allGroups = array(); + $allGroups = []; while ($chunkOffset < $overallLimit) { $chunkLimit = min($pagingSize, $overallLimit - $chunkOffset); $ldapGroups = $this->getGroupsChunk($search, $chunkLimit, $chunkOffset); diff --git a/apps/user_ldap/lib/Group_Proxy.php b/apps/user_ldap/lib/Group_Proxy.php index 3b39d4398c7..441bf141a38 100644 --- a/apps/user_ldap/lib/Group_Proxy.php +++ b/apps/user_ldap/lib/Group_Proxy.php @@ -30,7 +30,7 @@ namespace OCA\User_LDAP; use OCP\Group\Backend\IGetDisplayNameBackend; class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGetDisplayNameBackend { - private $backends = array(); + private $backends = []; private $refBackend = null; /** @@ -58,7 +58,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet protected function walkBackends($gid, $method, $parameters) { $cacheKey = $this->getGroupCacheKey($gid); foreach($this->backends as $configPrefix => $backend) { - if($result = call_user_func_array(array($backend, $method), $parameters)) { + if($result = call_user_func_array([$backend, $method], $parameters)) { $this->writeToCache($cacheKey, $configPrefix); return $result; } @@ -80,13 +80,13 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet //in case the uid has been found in the past, try this stored connection first if(!is_null($prefix)) { if(isset($this->backends[$prefix])) { - $result = call_user_func_array(array($this->backends[$prefix], $method), $parameters); + $result = call_user_func_array([$this->backends[$prefix], $method], $parameters); if($result === $passOnWhen) { //not found here, reset cache to null if group vanished //because sometimes methods return false with a reason $groupExists = call_user_func_array( - array($this->backends[$prefix], 'groupExists'), - array($gid) + [$this->backends[$prefix], 'groupExists'], + [$gid] ); if(!$groupExists) { $this->writeToCache($cacheKey, null); @@ -107,7 +107,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet * Checks whether the user is member of a group or not. */ public function inGroup($uid, $gid) { - return $this->handleRequest($gid, 'inGroup', array($uid, $gid)); + return $this->handleRequest($gid, 'inGroup', [$uid, $gid]); } /** @@ -119,7 +119,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet * if the user exists at all. */ public function getUserGroups($uid) { - $groups = array(); + $groups = []; foreach($this->backends as $backend) { $backendGroups = $backend->getUserGroups($uid); @@ -136,7 +136,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet * @return string[] with user ids */ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { - $users = array(); + $users = []; foreach($this->backends as $backend) { $backendUsers = $backend->usersInGroup($gid, $search, $limit, $offset); @@ -154,7 +154,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet */ public function createGroup($gid) { return $this->handleRequest( - $gid, 'createGroup', array($gid)); + $gid, 'createGroup', [$gid]); } /** @@ -164,7 +164,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet */ public function deleteGroup($gid) { return $this->handleRequest( - $gid, 'deleteGroup', array($gid)); + $gid, 'deleteGroup', [$gid]); } /** @@ -177,7 +177,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet */ public function addToGroup($uid, $gid) { return $this->handleRequest( - $gid, 'addToGroup', array($uid, $gid)); + $gid, 'addToGroup', [$uid, $gid]); } /** @@ -190,7 +190,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet */ public function removeFromGroup($uid, $gid) { return $this->handleRequest( - $gid, 'removeFromGroup', array($uid, $gid)); + $gid, 'removeFromGroup', [$uid, $gid]); } /** @@ -201,7 +201,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet */ public function countUsersInGroup($gid, $search = '') { return $this->handleRequest( - $gid, 'countUsersInGroup', array($gid, $search)); + $gid, 'countUsersInGroup', [$gid, $search]); } /** @@ -211,7 +211,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet */ public function getGroupDetails($gid) { return $this->handleRequest( - $gid, 'getGroupDetails', array($gid)); + $gid, 'getGroupDetails', [$gid]); } /** @@ -221,7 +221,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet * Returns a list with all groups */ public function getGroups($search = '', $limit = -1, $offset = 0) { - $groups = array(); + $groups = []; foreach($this->backends as $backend) { $backendGroups = $backend->getGroups($search, $limit, $offset); @@ -239,7 +239,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet * @return bool */ public function groupExists($gid) { - return $this->handleRequest($gid, 'groupExists', array($gid)); + return $this->handleRequest($gid, 'groupExists', [$gid]); } /** @@ -271,7 +271,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet * @return resource of the LDAP connection */ public function getNewLDAPConnection($gid) { - return $this->handleRequest($gid, 'getNewLDAPConnection', array($gid)); + return $this->handleRequest($gid, 'getNewLDAPConnection', [$gid]); } public function getDisplayName(string $gid): string { diff --git a/apps/user_ldap/lib/Helper.php b/apps/user_ldap/lib/Helper.php index 4279ea72c71..6962a3cb978 100644 --- a/apps/user_ldap/lib/Helper.php +++ b/apps/user_ldap/lib/Helper.php @@ -99,7 +99,7 @@ class Helper { $keys = $this->getServersConfig($referenceConfigkey); - $result = array(); + $result = []; foreach($keys as $key) { $len = strlen($key) - strlen($referenceConfigkey); $prefix = substr($key, 0, $len); @@ -164,7 +164,7 @@ class Helper { AND `appid` = \'user_ldap\' AND `configkey` NOT IN (\'enabled\', \'installed_version\', \'types\', \'bgjUpdateGroupsLastRun\') '); - $delRows = $query->execute(array($prefix.'%')); + $delRows = $query->execute([$prefix.'%']); if($delRows === null) { return false; @@ -234,7 +234,7 @@ class Helper { public function sanitizeDN($dn) { //treating multiple base DNs if(is_array($dn)) { - $result = array(); + $result = []; foreach($dn as $singleDN) { $result[] = $this->sanitizeDN($singleDN); } @@ -251,7 +251,7 @@ class Helper { //escape DN values according to RFC 2253 – this is already done by ldap_explode_dn //to use the DN in search filters, \ needs to be escaped to \5c additionally //to use them in bases, we convert them back to simple backslashes in readAttribute() - $replacements = array( + $replacements = [ '\,' => '\5c2C', '\=' => '\5c3D', '\+' => '\5c2B', @@ -263,7 +263,7 @@ class Helper { '(' => '\28', ')' => '\29', '*' => '\2A', - ); + ]; $dn = str_replace(array_keys($replacements), array_values($replacements), $dn); return $dn; diff --git a/apps/user_ldap/lib/Jobs/Sync.php b/apps/user_ldap/lib/Jobs/Sync.php index 174897d8639..7b95950bda5 100644 --- a/apps/user_ldap/lib/Jobs/Sync.php +++ b/apps/user_ldap/lib/Jobs/Sync.php @@ -161,11 +161,11 @@ class Sync extends TimedJob { $access = $this->accessFactory->get($connection); $access->setUserMapper($this->mapper); - $filter = $access->combineFilterWithAnd(array( + $filter = $access->combineFilterWithAnd([ $access->connection->ldapUserFilter, $access->connection->ldapUserDisplayName . '=*', $access->getFilterPartForUserSearch('') - )); + ]); $results = $access->fetchListOfUsers( $filter, $access->userManager->getAttributes(), diff --git a/apps/user_ldap/lib/Jobs/UpdateGroups.php b/apps/user_ldap/lib/Jobs/UpdateGroups.php index ef42f36f54f..bf5d730c3b8 100644 --- a/apps/user_ldap/lib/Jobs/UpdateGroups.php +++ b/apps/user_ldap/lib/Jobs/UpdateGroups.php @@ -104,21 +104,21 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { $actualUsers = self::getGroupBE()->usersInGroup($group); $hasChanged = false; foreach(array_diff($knownUsers, $actualUsers) as $removedUser) { - \OCP\Util::emitHook('OC_User', 'post_removeFromGroup', array('uid' => $removedUser, 'gid' => $group)); + \OCP\Util::emitHook('OC_User', 'post_removeFromGroup', ['uid' => $removedUser, 'gid' => $group]); \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".', ILogger::INFO); $hasChanged = true; } foreach(array_diff($actualUsers, $knownUsers) as $addedUser) { - \OCP\Util::emitHook('OC_User', 'post_addToGroup', array('uid' => $addedUser, 'gid' => $group)); + \OCP\Util::emitHook('OC_User', 'post_addToGroup', ['uid' => $addedUser, 'gid' => $group]); \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".', ILogger::INFO); $hasChanged = true; } if($hasChanged) { - $query->execute(array(serialize($actualUsers), $group)); + $query->execute([serialize($actualUsers), $group]); } } \OCP\Util::writeLog('user_ldap', @@ -141,7 +141,7 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { 'bgJ "updateGroups" – new group "'.$createdGroup.'" found.', ILogger::INFO); $users = serialize(self::getGroupBE()->usersInGroup($createdGroup)); - $query->execute(array($createdGroup, $users)); + $query->execute([$createdGroup, $users]); } \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – FINISHED dealing with created Groups.', @@ -162,7 +162,7 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – group "'.$removedGroup.'" was removed.', ILogger::INFO); - $query->execute(array($removedGroup)); + $query->execute([$removedGroup]); } \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – FINISHED dealing with removed groups.', @@ -217,7 +217,7 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { FROM `*PREFIX*ldap_group_members` '); $result = $query->execute()->fetchAll(); - self::$groupsFromDB = array(); + self::$groupsFromDB = []; foreach($result as $dataset) { self::$groupsFromDB[$dataset['owncloudname']] = $dataset; } diff --git a/apps/user_ldap/lib/LDAP.php b/apps/user_ldap/lib/LDAP.php index e68c3149696..8c8a6bfbf1e 100644 --- a/apps/user_ldap/lib/LDAP.php +++ b/apps/user_ldap/lib/LDAP.php @@ -35,7 +35,7 @@ use OCA\User_LDAP\Exceptions\ConstraintViolationException; class LDAP implements ILDAPWrapper { protected $curFunc = ''; - protected $curArgs = array(); + protected $curArgs = []; /** * @param resource $link @@ -71,7 +71,7 @@ class LDAP implements ILDAPWrapper { */ public function controlPagedResultResponse($link, $result, &$cookie) { $this->preFunctionCall('ldap_control_paged_result_response', - array($link, $result, $cookie)); + [$link, $result, $cookie]); $result = ldap_control_paged_result_response($link, $result, $cookie); $this->postFunctionCall(); @@ -217,7 +217,7 @@ class LDAP implements ILDAPWrapper { * @return bool */ public function modReplace($link, $userDN, $password) { - return $this->invokeLDAPMethod('mod_replace', $link, $userDN, array('userPassword' => $password)); + return $this->invokeLDAPMethod('mod_replace', $link, $userDN, ['userPassword' => $password]); } /** diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php index 472cd8d2779..fecc25da92e 100644 --- a/apps/user_ldap/lib/Mapping/AbstractMapping.php +++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php @@ -84,7 +84,7 @@ abstract class AbstractMapping { WHERE `' . $compareCol . '` = ? '); - $res = $query->execute(array($search)); + $res = $query->execute([$search]); if($res !== false) { return $query->fetchColumn(); } @@ -126,7 +126,7 @@ abstract class AbstractMapping { WHERE `directory_uuid` = ? '); - return $this->modify($query, array($fdn, $uuid)); + return $this->modify($query, [$fdn, $uuid]); } /** @@ -171,8 +171,8 @@ abstract class AbstractMapping { WHERE `owncloud_name` LIKE ? '); - $res = $query->execute(array($prefixMatch.$this->dbc->escapeLikeParameter($search).$postfixMatch)); - $names = array(); + $res = $query->execute([$prefixMatch.$this->dbc->escapeLikeParameter($search).$postfixMatch]); + $names = []; if($res !== false) { while($row = $query->fetch()) { $names[] = $row['owncloud_name']; @@ -240,11 +240,11 @@ abstract class AbstractMapping { return false; } - $row = array( + $row = [ 'ldap_dn' => $fdn, 'owncloud_name' => $name, 'directory_uuid' => $uuid - ); + ]; try { $result = $this->dbc->insertIfNotExist($this->getTableName(), $row); @@ -265,7 +265,7 @@ abstract class AbstractMapping { DELETE FROM `'. $this->getTableName() .'` WHERE `owncloud_name` = ?'); - return $this->modify($query, array($name)); + return $this->modify($query, [$name]); } /** diff --git a/apps/user_ldap/lib/Proxy.php b/apps/user_ldap/lib/Proxy.php index 24313fc7bfb..4515e53c6c4 100644 --- a/apps/user_ldap/lib/Proxy.php +++ b/apps/user_ldap/lib/Proxy.php @@ -37,7 +37,7 @@ use OCA\User_LDAP\Mapping\UserMapping; use OCA\User_LDAP\User\Manager; abstract class Proxy { - static private $accesses = array(); + static private $accesses = []; private $ldap = null; /** @var \OCP\ICache|null */ diff --git a/apps/user_ldap/lib/User/OfflineUser.php b/apps/user_ldap/lib/User/OfflineUser.php index 1511f3bcd61..c75a144e909 100644 --- a/apps/user_ldap/lib/User/OfflineUser.php +++ b/apps/user_ldap/lib/User/OfflineUser.php @@ -105,7 +105,7 @@ class OfflineUser { * @return array */ public function export() { - $data = array(); + $data = []; $data['ocName'] = $this->getOCName(); $data['dn'] = $this->getDN(); $data['uid'] = $this->getUID(); @@ -223,7 +223,7 @@ class OfflineUser { FROM `*PREFIX*share` WHERE `uid_owner` = ? ', 1); - $query->execute(array($this->ocName)); + $query->execute([$this->ocName]); $sResult = $query->fetchColumn(0); if((int)$sResult === 1) { $this->hasActiveShares = true; @@ -235,7 +235,7 @@ class OfflineUser { FROM `*PREFIX*share_external` WHERE `owner` = ? ', 1); - $query->execute(array($this->ocName)); + $query->execute([$this->ocName]); $sResult = $query->fetchColumn(0); if((int)$sResult === 1) { $this->hasActiveShares = true; diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 467d5ca025b..eb126b94bfe 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -96,7 +96,7 @@ class User { /** * @var string[] */ - protected $refreshedFeatures = array(); + protected $refreshedFeatures = []; /** * @var string */ @@ -711,7 +711,7 @@ class User { $uid = $params['uid']; if (isset($uid) && $uid === $this->getUsername()) { //retrieve relevant user attributes - $result = $this->access->search('objectclass=*', array($this->dn), ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']); + $result = $this->access->search('objectclass=*', [$this->dn], ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']); if (array_key_exists('pwdpolicysubentry', $result[0])) { $pwdPolicySubentry = $result[0]['pwdpolicysubentry']; @@ -728,7 +728,7 @@ class User { $cacheKey = 'ppolicyAttributes' . $ppolicyDN; $result = $this->connection->getFromCache($cacheKey); if(is_null($result)) { - $result = $this->access->search('objectclass=*', array($ppolicyDN), ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']); + $result = $this->access->search('objectclass=*', [$ppolicyDN], ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']); $this->connection->writeToCache($cacheKey, $result); } @@ -742,10 +742,10 @@ class User { && count($pwdGraceUseTime) < (int)$pwdGraceAuthNLimit[0]) { //at least one more grace login available? $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( - 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid))); + 'user_ldap.renewPassword.showRenewPasswordForm', ['user' => $uid])); } else { //no more grace login available header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( - 'user_ldap.renewPassword.showLoginFormInvalidPassword', array('user' => $uid))); + 'user_ldap.renewPassword.showLoginFormInvalidPassword', ['user' => $uid])); } exit(); } @@ -753,7 +753,7 @@ class User { if (!empty($pwdReset) && $pwdReset[0] === 'TRUE') { //user must change his password $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( - 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid))); + 'user_ldap.renewPassword.showRenewPasswordForm', ['user' => $uid])); exit(); } //handle password expiry warning diff --git a/apps/user_ldap/lib/UserPluginManager.php b/apps/user_ldap/lib/UserPluginManager.php index 1407bec011d..6301257b1af 100644 --- a/apps/user_ldap/lib/UserPluginManager.php +++ b/apps/user_ldap/lib/UserPluginManager.php @@ -32,7 +32,7 @@ class UserPluginManager { private $respondToActions = 0; - private $which = array( + private $which = [ Backend::CREATE_USER => null, Backend::SET_PASSWORD => null, Backend::GET_HOME => null, @@ -41,7 +41,7 @@ class UserPluginManager { Backend::PROVIDE_AVATAR => null, Backend::COUNT_USERS => null, 'deleteUser' => null - ); + ]; /** * @return int All implemented actions, except for 'deleteUser' diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index 323e59860f3..fec3b25a78e 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -260,11 +260,11 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn if($limit <= 0) { $limit = null; } - $filter = $this->access->combineFilterWithAnd(array( + $filter = $this->access->combineFilterWithAnd([ $this->access->connection->ldapUserFilter, $this->access->connection->ldapUserDisplayName . '=*', $this->access->getFilterPartForUserSearch($search) - )); + ]); Util::writeLog('user_ldap', 'getUsers: Options: search '.$search.' limit '.$limit.' offset '.$offset.' Filter: '.$filter, @@ -511,7 +511,7 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn return $displayNames; } - $displayNames = array(); + $displayNames = []; $users = $this->getUsers($search, $limit, $offset); foreach ($users as $user) { $displayNames[$user] = $this->getDisplayName($user); diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php index 96be4a7529f..2edc0d2d64a 100644 --- a/apps/user_ldap/lib/User_Proxy.php +++ b/apps/user_ldap/lib/User_Proxy.php @@ -84,7 +84,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, && method_exists($this->getAccess($configPrefix), $method)) { $instance = $this->getAccess($configPrefix); } - if($result = call_user_func_array(array($instance, $method), $parameters)) { + if($result = call_user_func_array([$instance, $method], $parameters)) { $this->writeToCache($cacheKey, $configPrefix); return $result; } @@ -160,7 +160,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, */ public function getUsers($search = '', $limit = 10, $offset = 0) { //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends - $users = array(); + $users = []; foreach($this->backends as $backend) { $backendUsers = $backend->getUsers($search, $limit, $offset); if (is_array($backendUsers)) { @@ -177,7 +177,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, */ public function userExists($uid) { $existsOnLDAP = false; - $existsLocally = $this->handleRequest($uid, 'userExists', array($uid)); + $existsLocally = $this->handleRequest($uid, 'userExists', [$uid]); if($existsLocally) { $existsOnLDAP = $this->userExistsOnLDAP($uid); } @@ -202,7 +202,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, */ public function userExistsOnLDAP($user) { $id = ($user instanceof User) ? $user->getUsername() : $user; - return $this->handleRequest($id, 'userExistsOnLDAP', array($user)); + return $this->handleRequest($id, 'userExistsOnLDAP', [$user]); } /** @@ -214,7 +214,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * Check if the password is correct without logging in the user */ public function checkPassword($uid, $password) { - return $this->handleRequest($uid, 'checkPassword', array($uid, $password)); + return $this->handleRequest($uid, 'checkPassword', [$uid, $password]); } /** @@ -225,7 +225,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, */ public function loginName2UserName($loginName) { $id = 'LOGINNAME,' . $loginName; - return $this->handleRequest($id, 'loginName2UserName', array($loginName)); + return $this->handleRequest($id, 'loginName2UserName', [$loginName]); } /** @@ -236,7 +236,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, */ public function dn2UserName($dn) { $id = 'DN,' . $dn; - return $this->handleRequest($id, 'dn2UserName', array($dn)); + return $this->handleRequest($id, 'dn2UserName', [$dn]); } /** @@ -245,7 +245,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * @return boolean */ public function getHome($uid) { - return $this->handleRequest($uid, 'getHome', array($uid)); + return $this->handleRequest($uid, 'getHome', [$uid]); } /** @@ -254,7 +254,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * @return string display name */ public function getDisplayName($uid) { - return $this->handleRequest($uid, 'getDisplayName', array($uid)); + return $this->handleRequest($uid, 'getDisplayName', [$uid]); } /** @@ -265,7 +265,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * @return string display name */ public function setDisplayName($uid, $displayName) { - return $this->handleRequest($uid, 'setDisplayName', array($uid, $displayName)); + return $this->handleRequest($uid, 'setDisplayName', [$uid, $displayName]); } /** @@ -286,7 +286,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, */ public function getDisplayNames($search = '', $limit = null, $offset = null) { //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends - $users = array(); + $users = []; foreach($this->backends as $backend) { $backendUsers = $backend->getDisplayNames($search, $limit, $offset); if (is_array($backendUsers)) { @@ -304,7 +304,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * Deletes a user */ public function deleteUser($uid) { - return $this->handleRequest($uid, 'deleteUser', array($uid)); + return $this->handleRequest($uid, 'deleteUser', [$uid]); } /** @@ -315,7 +315,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * */ public function setPassword($uid, $password) { - return $this->handleRequest($uid, 'setPassword', array($uid, $password)); + return $this->handleRequest($uid, 'setPassword', [$uid, $password]); } /** @@ -346,7 +346,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * @return Access instance of Access for LDAP interaction */ public function getLDAPAccess($uid) { - return $this->handleRequest($uid, 'getLDAPAccess', array($uid)); + return $this->handleRequest($uid, 'getLDAPAccess', [$uid]); } /** @@ -356,7 +356,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * @return resource of the LDAP connection */ public function getNewLDAPConnection($uid) { - return $this->handleRequest($uid, 'getNewLDAPConnection', array($uid)); + return $this->handleRequest($uid, 'getNewLDAPConnection', [$uid]); } /** @@ -366,6 +366,6 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * @return bool */ public function createUser($username, $password) { - return $this->handleRequest($username, 'createUser', array($username,$password)); + return $this->handleRequest($username, 'createUser', [$username,$password]); } } diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php index 82f06010bcf..4e3f41d6fc9 100644 --- a/apps/user_ldap/lib/Wizard.php +++ b/apps/user_ldap/lib/Wizard.php @@ -48,7 +48,7 @@ class Wizard extends LDAPUtility { protected $cr; protected $configuration; protected $result; - protected $resultCache = array(); + protected $resultCache = []; const LRESULT_PROCESSED_OK = 2; const LRESULT_PROCESSED_INVALID = 3; @@ -135,7 +135,7 @@ class Wizard extends LDAPUtility { $filter = $this->configuration->ldapGroupFilter; if(empty($filter)) { - $output = self::$l->n('%s group found', '%s groups found', 0, array(0)); + $output = self::$l->n('%s group found', '%s groups found', 0, [0]); $this->result->addChange('ldap_group_count', $output); return $this->result; } @@ -200,22 +200,22 @@ class Wizard extends LDAPUtility { * @return int|bool */ public function countUsersWithAttribute($attr, $existsCheck = false) { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', 'ldapUserFilter', - ))) { + ])) { return false; } - $filter = $this->access->combineFilterWithAnd(array( + $filter = $this->access->combineFilterWithAnd([ $this->configuration->ldapUserFilter, $attr . '=*' - )); + ]); $limit = ($existsCheck === false) ? null : 1; - return $this->access->countUsers($filter, array('dn'), $limit); + return $this->access->countUsers($filter, ['dn'], $limit); } /** @@ -225,11 +225,11 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function detectUserDisplayNameAttribute() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', 'ldapUserFilter', - ))) { + ])) { return false; } @@ -247,7 +247,7 @@ class Wizard extends LDAPUtility { } // first attribute that has at least one result wins - $displayNameAttrs = array('displayname', 'cn'); + $displayNameAttrs = ['displayname', 'cn']; foreach ($displayNameAttrs as $attr) { $count = (int)$this->countUsersWithAttribute($attr, true); @@ -267,11 +267,11 @@ class Wizard extends LDAPUtility { * @return WizardResult|bool */ public function detectEmailAttribute() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', 'ldapUserFilter', - ))) { + ])) { return false; } @@ -286,7 +286,7 @@ class Wizard extends LDAPUtility { $writeLog = false; } - $emailAttributes = array('mail', 'mailPrimaryAddress'); + $emailAttributes = ['mail', 'mailPrimaryAddress']; $winner = ''; $maxUsers = 0; foreach($emailAttributes as $attr) { @@ -314,11 +314,11 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function determineAttributes() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', 'ldapUserFilter', - ))) { + ])) { return false; } @@ -343,11 +343,11 @@ class Wizard extends LDAPUtility { * @throws \Exception */ private function getUserAttributes() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', 'ldapUserFilter', - ))) { + ])) { return false; } $cr = $this->getConnection(); @@ -357,13 +357,13 @@ class Wizard extends LDAPUtility { $base = $this->configuration->ldapBase[0]; $filter = $this->configuration->ldapUserFilter; - $rr = $this->ldap->search($cr, $base, $filter, array(), 1, 1); + $rr = $this->ldap->search($cr, $base, $filter, [], 1, 1); if(!$this->ldap->isResource($rr)) { return false; } $er = $this->ldap->firstEntry($cr, $rr); $attributes = $this->ldap->getAttributes($cr, $er); - $pureAttributes = array(); + $pureAttributes = []; for($i = 0; $i < $attributes['count']; $i++) { $pureAttributes[] = $attributes[$i]; } @@ -399,10 +399,10 @@ class Wizard extends LDAPUtility { * @throws \Exception */ private function determineGroups($dbKey, $confKey, $testMemberOf = true) { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', - ))) { + ])) { return false; } $cr = $this->getConnection(); @@ -432,9 +432,9 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function fetchGroups($dbKey, $confKey) { - $obclasses = array('posixGroup', 'group', 'zimbraDistributionList', 'groupOfNames', 'groupOfUniqueNames'); + $obclasses = ['posixGroup', 'group', 'zimbraDistributionList', 'groupOfNames', 'groupOfUniqueNames']; - $filterParts = array(); + $filterParts = []; foreach($obclasses as $obclass) { $filterParts[] = 'objectclass='.$obclass; } @@ -442,16 +442,16 @@ class Wizard extends LDAPUtility { //- that looks like a group and //- has the group display name set $filter = $this->access->combineFilterWithOr($filterParts); - $filter = $this->access->combineFilterWithAnd(array($filter, 'cn=*')); + $filter = $this->access->combineFilterWithAnd([$filter, 'cn=*']); - $groupNames = array(); - $groupEntries = array(); + $groupNames = []; + $groupEntries = []; $limit = 400; $offset = 0; do { // we need to request dn additionally here, otherwise memberOf // detection will fail later - $result = $this->access->searchGroups($filter, array('cn', 'dn'), $limit, $offset); + $result = $this->access->searchGroups($filter, ['cn', 'dn'], $limit, $offset); foreach($result as $item) { if(!isset($item['cn']) && !is_array($item['cn']) && !isset($item['cn'][0])) { // just in case - no issue known @@ -479,17 +479,17 @@ class Wizard extends LDAPUtility { } public function determineGroupMemberAssoc() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapGroupFilter', - ))) { + ])) { return false; } $attribute = $this->detectGroupMemberAssoc(); if($attribute === false) { return false; } - $this->configuration->setConfiguration(array('ldapGroupMemberAssocAttr' => $attribute)); + $this->configuration->setConfiguration(['ldapGroupMemberAssocAttr' => $attribute]); $this->result->addChange('ldap_group_member_assoc_attribute', $attribute); return $this->result; @@ -501,10 +501,10 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function determineGroupObjectClasses() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', - ))) { + ])) { return false; } $cr = $this->getConnection(); @@ -512,7 +512,7 @@ class Wizard extends LDAPUtility { throw new \Exception('Could not connect to LDAP'); } - $obclasses = array('groupOfNames', 'groupOfUniqueNames', 'group', 'posixGroup', '*'); + $obclasses = ['groupOfNames', 'groupOfUniqueNames', 'group', 'posixGroup', '*']; $this->determineFeature($obclasses, 'objectclass', 'ldap_groupfilter_objectclass', @@ -528,10 +528,10 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function determineUserObjectClasses() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', - ))) { + ])) { return false; } $cr = $this->getConnection(); @@ -539,8 +539,8 @@ class Wizard extends LDAPUtility { throw new \Exception('Could not connect to LDAP'); } - $obclasses = array('inetOrgPerson', 'person', 'organizationalPerson', - 'user', 'posixAccount', '*'); + $obclasses = ['inetOrgPerson', 'person', 'organizationalPerson', + 'user', 'posixAccount', '*']; $filter = $this->configuration->ldapUserFilter; //if filter is empty, it is probably the first time the wizard is called //then, apply suggestions. @@ -558,10 +558,10 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function getGroupFilter() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', - ))) { + ])) { return false; } //make sure the use display name is set @@ -582,10 +582,10 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function getUserListFilter() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', - ))) { + ])) { return false; } //make sure the use display name is set @@ -608,11 +608,11 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function getUserLoginFilter() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', 'ldapUserFilter', - ))) { + ])) { return false; } @@ -631,11 +631,11 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function testLoginName($loginName) { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', 'ldapBase', 'ldapLoginFilter', - ))) { + ])) { return false; } @@ -665,8 +665,8 @@ class Wizard extends LDAPUtility { * @throws \Exception */ public function guessPortAndTLS() { - if(!$this->checkRequirements(array('ldapHost', - ))) { + if(!$this->checkRequirements(['ldapHost', + ])) { return false; } $this->checkHost(); @@ -698,10 +698,10 @@ class Wizard extends LDAPUtility { } if ($settingsFound === true) { - $config = array( + $config = [ 'ldapPort' => $p, 'ldapTLS' => (int)$t - ); + ]; $this->configuration->setConfiguration($config); \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, ILogger::DEBUG); $this->result->addChange('ldap_port', $p); @@ -718,9 +718,9 @@ class Wizard extends LDAPUtility { * @return WizardResult|false WizardResult on success, false otherwise */ public function guessBaseDN() { - if(!$this->checkRequirements(array('ldapHost', + if(!$this->checkRequirements(['ldapHost', 'ldapPort', - ))) { + ])) { return false; } @@ -766,7 +766,7 @@ class Wizard extends LDAPUtility { */ private function applyFind($key, $value) { $this->result->addChange($key, $value); - $this->configuration->setConfiguration(array($key => $value)); + $this->configuration->setConfiguration([$key => $value]); } /** @@ -844,7 +844,7 @@ class Wizard extends LDAPUtility { //base is there, let's validate it. If we search for anything, we should //get a result set > 0 on a proper base - $rr = $this->ldap->search($cr, $base, 'objectClass=*', array('dn'), 0, 1); + $rr = $this->ldap->search($cr, $base, 'objectClass=*', ['dn'], 0, 1); if(!$this->ldap->isResource($rr)) { $errorNo = $this->ldap->errno($cr); $errorMsg = $this->ldap->error($cr); @@ -870,7 +870,7 @@ class Wizard extends LDAPUtility { if(!$cr) { throw new \Exception('Could not connect to LDAP'); } - $result = $this->access->countUsers('memberOf=*', array('memberOf'), 1); + $result = $this->access->countUsers('memberOf=*', ['memberOf'], 1); if(is_int($result) && $result > 0) { return true; } @@ -911,7 +911,7 @@ class Wizard extends LDAPUtility { } $base = $this->configuration->ldapBase[0]; foreach($cns as $cn) { - $rr = $this->ldap->search($cr, $base, 'cn=' . $cn, array('dn', 'primaryGroupToken')); + $rr = $this->ldap->search($cr, $base, 'cn=' . $cn, ['dn', 'primaryGroupToken']); if(!$this->ldap->isResource($rr)) { continue; } @@ -1132,8 +1132,8 @@ class Wizard extends LDAPUtility { * @return array|false an array with the values on success, false otherwise */ public function cumulativeSearchOnAttribute($filters, $attr, $dnReadLimit = 3, &$maxF = null) { - $dnRead = array(); - $foundItems = array(); + $dnRead = []; + $foundItems = []; $maxEntries = 0; if(!is_array($this->configuration->ldapBase) || !isset($this->configuration->ldapBase[0])) { @@ -1154,7 +1154,7 @@ class Wizard extends LDAPUtility { continue; } // 20k limit for performance and reason - $rr = $this->ldap->search($cr, $base, $filter, array($attr), 0, 20000); + $rr = $this->ldap->search($cr, $base, $filter, [$attr], 0, 20000); if(!$this->ldap->isResource($rr)) { continue; } @@ -1178,7 +1178,7 @@ class Wizard extends LDAPUtility { if($dn === false || in_array($dn, $dnRead)) { continue; } - $newItems = array(); + $newItems = []; $state = $this->getAttributeValuesFromEntry($attributes, $attr, $newItems); @@ -1317,14 +1317,14 @@ class Wizard extends LDAPUtility { * @return array */ private function getDefaultLdapPortSettings() { - static $settings = array( - array('port' => 7636, 'tls' => false), - array('port' => 636, 'tls' => false), - array('port' => 7389, 'tls' => true), - array('port' => 389, 'tls' => true), - array('port' => 7389, 'tls' => false), - array('port' => 389, 'tls' => false), - ); + static $settings = [ + ['port' => 7636, 'tls' => false], + ['port' => 636, 'tls' => false], + ['port' => 7389, 'tls' => true], + ['port' => 389, 'tls' => true], + ['port' => 7389, 'tls' => false], + ['port' => 389, 'tls' => false], + ]; return $settings; } @@ -1337,7 +1337,7 @@ class Wizard extends LDAPUtility { //7xxx ← UCS. need to be checked first, because both ports may be open $host = $this->configuration->ldapHost; $port = (int)$this->configuration->ldapPort; - $portSettings = array(); + $portSettings = []; //In case the port is already provided, we will check this first if($port > 0) { @@ -1345,9 +1345,9 @@ class Wizard extends LDAPUtility { if(!(is_array($hostInfo) && isset($hostInfo['scheme']) && stripos($hostInfo['scheme'], 'ldaps') !== false)) { - $portSettings[] = array('port' => $port, 'tls' => true); + $portSettings[] = ['port' => $port, 'tls' => true]; } - $portSettings[] =array('port' => $port, 'tls' => false); + $portSettings[] =['port' => $port, 'tls' => false]; } //default ports diff --git a/apps/user_ldap/lib/WizardResult.php b/apps/user_ldap/lib/WizardResult.php index 74bb1171d48..ae90cfe437a 100644 --- a/apps/user_ldap/lib/WizardResult.php +++ b/apps/user_ldap/lib/WizardResult.php @@ -29,8 +29,8 @@ namespace OCA\User_LDAP; class WizardResult { - protected $changes = array(); - protected $options = array(); + protected $changes = []; + protected $options = []; protected $markedChange = false; /** @@ -52,7 +52,7 @@ class WizardResult { */ public function addOptions($key, $values) { if(!is_array($values)) { - $values = array($values); + $values = [$values]; } $this->options[$key] = $values; } @@ -68,7 +68,7 @@ class WizardResult { * @return array */ public function getResultArray() { - $result = array(); + $result = []; $result['changes'] = $this->changes; if(count($this->options) > 0) { $result['options'] = $this->options; diff --git a/apps/user_ldap/templates/part.wizard-server.php b/apps/user_ldap/templates/part.wizard-server.php index 5b607f7be86..56194bafecd 100644 --- a/apps/user_ldap/templates/part.wizard-server.php +++ b/apps/user_ldap/templates/part.wizard-server.php @@ -6,7 +6,7 @@ $sel = ' selected'; foreach($_['serverConfigurationPrefixes'] as $prefix) { ?> - <option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($l->t('%s. Server:', array($i++)));?> <?php p(' '.$_['serverConfigurationHosts'][$prefix]); ?></option> + <option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($l->t('%s. Server:', [$i++]));?> <?php p(' '.$_['serverConfigurationHosts'][$prefix]); ?></option> <?php } ?> diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php index e8fa47c6ab9..0397a851557 100644 --- a/apps/user_ldap/tests/AccessTest.php +++ b/apps/user_ldap/tests/AccessTest.php @@ -116,7 +116,7 @@ class AccessTest extends TestCase { ->getMock(); $helper = new Helper(\OC::$server->getConfig()); - return array($lw, $connector, $um, $helper); + return [$lw, $connector, $um, $helper]; } public function testEscapeFilterPartValidChars() { @@ -147,9 +147,9 @@ class AccessTest extends TestCase { } public function convertSID2StrSuccessData() { - return array( - array( - array( + return [ + [ + [ "\x01", "\x04", "\x00\x00\x00\x00\x00\x05", @@ -157,20 +157,20 @@ class AccessTest extends TestCase { "\xa6\x81\xe5\x0e", "\x4d\x6c\x6c\x2b", "\xca\x32\x05\x5f", - ), + ], 'S-1-5-21-249921958-728525901-1594176202', - ), - array( - array( + ], + [ + [ "\x01", "\x02", "\xFF\xFF\xFF\xFF\xFF\xFF", "\xFF\xFF\xFF\xFF", "\xFF\xFF\xFF\xFF", - ), + ], 'S-1-281474976710655-4294967295-4294967295', - ), - ); + ], + ]; } public function testConvertSID2StrInputError() { @@ -208,12 +208,12 @@ class AccessTest extends TestCase { return [[ [ 'input' => 'foo=bar,bar=foo,dc=foobar', - 'interResult' => array( + 'interResult' => [ 'count' => 3, 0 => 'foo=bar', 1 => 'bar=foo', 2 => 'dc=foobar' - ), + ], 'expectedResult' => true ], [ @@ -408,12 +408,12 @@ class AccessTest extends TestCase { public function dNAttributeProvider() { // corresponds to Access::resemblesDN() - return array( - 'dn' => array('dn'), - 'uniqueMember' => array('uniquemember'), - 'member' => array('member'), - 'memberOf' => array('memberof') - ); + return [ + 'dn' => ['dn'], + 'uniqueMember' => ['uniquemember'], + 'member' => ['member'], + 'memberOf' => ['memberof'] + ]; } /** @@ -432,9 +432,9 @@ class AccessTest extends TestCase { ->willReturn(true); $lw->expects($this->any()) ->method('getAttributes') - ->willReturn(array( - $attribute => array('count' => 1, $dnFromServer) - )); + ->willReturn([ + $attribute => ['count' => 1, $dnFromServer] + ]); $access = new Access($con, $lw, $um, $helper, $config, $this->ncUserManager); $values = $access->readAttribute('uid=whoever,dc=example,dc=org', $attribute); diff --git a/apps/user_ldap/tests/ConfigurationTest.php b/apps/user_ldap/tests/ConfigurationTest.php index 1c757aa5a47..c44f8a0177a 100644 --- a/apps/user_ldap/tests/ConfigurationTest.php +++ b/apps/user_ldap/tests/ConfigurationTest.php @@ -36,71 +36,71 @@ class ConfigurationTest extends \Test\TestCase { } public function configurationDataProvider() { - $inputWithDN = array( + $inputWithDN = [ 'cn=someUsers,dc=example,dc=org', ' ', ' cn=moreUsers,dc=example,dc=org ' - ); - $expectWithDN = array( + ]; + $expectWithDN = [ 'cn=someUsers,dc=example,dc=org', 'cn=moreUsers,dc=example,dc=org' - ); + ]; - $inputNames = array( + $inputNames = [ ' uid ', 'cn ', ' ', '', ' whats my name', ' ' - ); - $expectedNames = array('uid', 'cn', 'whats my name'); + ]; + $expectedNames = ['uid', 'cn', 'whats my name']; $inputString = ' alea iacta est '; $expectedString = 'alea iacta est'; - $inputHomeFolder = array( + $inputHomeFolder = [ ' homeDirectory ', ' attr:homeDirectory ', ' ' - ); + ]; - $expectedHomeFolder = array( + $expectedHomeFolder = [ 'attr:homeDirectory', 'attr:homeDirectory', '' - ); + ]; $password = ' such a passw0rd '; - return array( - 'set general base' => array('ldapBase', $inputWithDN, $expectWithDN), - 'set user base' => array('ldapBaseUsers', $inputWithDN, $expectWithDN), - 'set group base' => array('ldapBaseGroups', $inputWithDN, $expectWithDN), + return [ + 'set general base' => ['ldapBase', $inputWithDN, $expectWithDN], + 'set user base' => ['ldapBaseUsers', $inputWithDN, $expectWithDN], + 'set group base' => ['ldapBaseGroups', $inputWithDN, $expectWithDN], - 'set search attributes users' => array('ldapAttributesForUserSearch', $inputNames, $expectedNames), - 'set search attributes groups' => array('ldapAttributesForGroupSearch', $inputNames, $expectedNames), + 'set search attributes users' => ['ldapAttributesForUserSearch', $inputNames, $expectedNames], + 'set search attributes groups' => ['ldapAttributesForGroupSearch', $inputNames, $expectedNames], - 'set user filter objectclasses' => array('ldapUserFilterObjectclass', $inputNames, $expectedNames), - 'set user filter groups' => array('ldapUserFilterGroups', $inputNames, $expectedNames), - 'set group filter objectclasses' => array('ldapGroupFilterObjectclass', $inputNames, $expectedNames), - 'set group filter groups' => array('ldapGroupFilterGroups', $inputNames, $expectedNames), - 'set login filter attributes' => array('ldapLoginFilterAttributes', $inputNames, $expectedNames), + 'set user filter objectclasses' => ['ldapUserFilterObjectclass', $inputNames, $expectedNames], + 'set user filter groups' => ['ldapUserFilterGroups', $inputNames, $expectedNames], + 'set group filter objectclasses' => ['ldapGroupFilterObjectclass', $inputNames, $expectedNames], + 'set group filter groups' => ['ldapGroupFilterGroups', $inputNames, $expectedNames], + 'set login filter attributes' => ['ldapLoginFilterAttributes', $inputNames, $expectedNames], - 'set agent password' => array('ldapAgentPassword', $password, $password), + 'set agent password' => ['ldapAgentPassword', $password, $password], - 'set home folder, variant 1' => array('homeFolderNamingRule', $inputHomeFolder[0], $expectedHomeFolder[0]), - 'set home folder, variant 2' => array('homeFolderNamingRule', $inputHomeFolder[1], $expectedHomeFolder[1]), - 'set home folder, empty' => array('homeFolderNamingRule', $inputHomeFolder[2], $expectedHomeFolder[2]), + 'set home folder, variant 1' => ['homeFolderNamingRule', $inputHomeFolder[0], $expectedHomeFolder[0]], + 'set home folder, variant 2' => ['homeFolderNamingRule', $inputHomeFolder[1], $expectedHomeFolder[1]], + 'set home folder, empty' => ['homeFolderNamingRule', $inputHomeFolder[2], $expectedHomeFolder[2]], // default behaviour, one case is enough, special needs must be tested // individually - 'set string value' => array('ldapHost', $inputString, $expectedString), + 'set string value' => ['ldapHost', $inputString, $expectedString], 'set avatar rule, default' => ['ldapUserAvatarRule', 'default', 'default'], 'set avatar rule, none' => ['ldapUserAvatarRule', 'none', 'none'], 'set avatar rule, data attribute' => ['ldapUserAvatarRule', 'data:jpegPhoto', 'data:jpegPhoto'], 'set external storage home attribute' => ['ldapExtStorageHomeAttribute', 'homePath', 'homePath'], - ); + ]; } /** diff --git a/apps/user_ldap/tests/ConnectionTest.php b/apps/user_ldap/tests/ConnectionTest.php index 82e6f85952d..778a666317b 100644 --- a/apps/user_ldap/tests/ConnectionTest.php +++ b/apps/user_ldap/tests/ConnectionTest.php @@ -67,17 +67,17 @@ class ConnectionTest extends \Test\TestCase { $lw = $this->createMock(ILDAPWrapper::class); $connection = new Connection($lw, '', null); - $agent = array( + $agent = [ 'ldapAgentName' => 'agent', 'ldapAgentPassword' => '123456', - ); + ]; $connection->setConfiguration($agent); $testConnection = clone $connection; - $user = array( + $user = [ 'ldapAgentName' => 'user', 'ldapAgentPassword' => 'password', - ); + ]; $testConnection->setConfiguration($user); $agentName = $connection->ldapAgentName; diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php index 5fdc3c5862c..d5a6f3b712c 100644 --- a/apps/user_ldap/tests/Group_LDAPTest.php +++ b/apps/user_ldap/tests/Group_LDAPTest.php @@ -229,7 +229,7 @@ class Group_LDAPTest extends TestCase { $access->expects($this->once()) ->method('searchGroups') - ->willReturn(array()); + ->willReturn([]); $access->expects($this->never()) ->method('dn2groupname'); @@ -276,7 +276,7 @@ class Group_LDAPTest extends TestCase { $access->expects($this->once()) ->method('readAttribute') ->with($dn, $attr) - ->willReturn(array('3117')); + ->willReturn(['3117']); $groupBackend = new GroupLDAP($access, $pluginManager); @@ -376,7 +376,7 @@ class Group_LDAPTest extends TestCase { $access->expects($this->once()) ->method('searchGroups') - ->willReturn(array()); + ->willReturn([]); $access->expects($this->never()) ->method('dn2groupname'); @@ -430,7 +430,7 @@ class Group_LDAPTest extends TestCase { $access->expects($this->once()) ->method('readAttribute') ->with($dn, $attr) - ->willReturn(array('3117')); + ->willReturn(['3117']); $groupBackend = new GroupLDAP($access, $pluginManager); @@ -496,7 +496,7 @@ class Group_LDAPTest extends TestCase { $access->expects($this->once()) ->method('nextcloudGroupNames') - ->willReturn(array('group1', 'group2')); + ->willReturn(['group1', 'group2']); $groupBackend = new GroupLDAP($access, $pluginManager); $groups = $groupBackend->getGroups('', 2, 2); @@ -521,11 +521,11 @@ class Group_LDAPTest extends TestCase { ->method('readAttribute') ->willReturnCallback(function($dn, $attr) { if($attr === 'primaryGroupToken') { - return array(1337); + return [1337]; } else if($attr === 'gidNumber') { return [4211]; } - return array(); + return []; }); $access->expects($this->any()) ->method('groupname2dn') @@ -558,16 +558,16 @@ class Group_LDAPTest extends TestCase { ->method('readAttribute') ->willReturnCallback(function($dn, $attr) { if($attr === 'primaryGroupToken') { - return array(1337); + return [1337]; } - return array(); + return []; }); $access->expects($this->any()) ->method('groupname2dn') ->willReturn('cn=foobar,dc=foo,dc=bar'); $access->expects($this->once()) ->method('nextcloudUserNames') - ->willReturn(array('lisa', 'bart', 'kira', 'brad')); + ->willReturn(['lisa', 'bart', 'kira', 'brad']); $access->userManager = $this->createMock(Manager::class); $groupBackend = new GroupLDAP($access, $pluginManager); @@ -594,9 +594,9 @@ class Group_LDAPTest extends TestCase { ->method('readAttribute') ->willReturnCallback(function($dn, $attr) { if($attr === 'primaryGroupToken') { - return array(1337); + return [1337]; } - return array(); + return []; }); $access->expects($this->any()) diff --git a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php index e652b7a644c..6912fc2d9a7 100644 --- a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php +++ b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php @@ -129,12 +129,12 @@ class ExceptionOnLostConnection { //host contains port, 2nd parameter will be ignored $cr = $this->ldap->connect($this->ldapHost, 0); $this->ldap->bind($cr, $this->ldapBindDN, $this->ldapBindPwd); - $this->ldap->search($cr, $this->ldapBase, 'objectClass=*', array('dn'), true, 5); + $this->ldap->search($cr, $this->ldapBase, 'objectClass=*', ['dn'], true, 5); // disable LDAP, will cause lost connection $this->setProxyState(false); try { - $this->ldap->search($cr, $this->ldapBase, 'objectClass=*', array('dn'), true, 5); + $this->ldap->search($cr, $this->ldapBase, 'objectClass=*', ['dn'], true, 5); } catch (ServerNotAvailableException $e) { print("Test PASSED" . PHP_EOL); exit(0); @@ -173,9 +173,9 @@ class ExceptionOnLostConnection { $ch = $this->getCurl(); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( + curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', - 'Content-Length: ' . strlen($postData)) + 'Content-Length: ' . strlen($postData)] ); $recvd = curl_exec($ch); $this->checkCurlResult($ch, $recvd); diff --git a/apps/user_ldap/tests/Jobs/CleanUpTest.php b/apps/user_ldap/tests/Jobs/CleanUpTest.php index 22065d14b2c..f08a5440c4f 100644 --- a/apps/user_ldap/tests/Jobs/CleanUpTest.php +++ b/apps/user_ldap/tests/Jobs/CleanUpTest.php @@ -31,7 +31,7 @@ use OCP\IDBConnection; class CleanUpTest extends \Test\TestCase { public function getMocks() { - $mocks = array(); + $mocks = []; $mocks['userBackend'] = $this->getMockBuilder('\OCA\User_LDAP\User_Proxy') ->disableOriginalConstructor() diff --git a/apps/user_ldap/tests/LDAPProviderTest.php b/apps/user_ldap/tests/LDAPProviderTest.php index b6e63f4a7ae..71e08654893 100644 --- a/apps/user_ldap/tests/LDAPProviderTest.php +++ b/apps/user_ldap/tests/LDAPProviderTest.php @@ -601,7 +601,7 @@ class LDAPProviderTest extends \Test\TestCase { ->willReturn(true); $userBackend->expects($this->at(3)) ->method('getConfiguration') - ->willReturn(array('ldap_display_name'=>'displayName')); + ->willReturn(['ldap_display_name'=>'displayName']); $userBackend->expects($this->any()) ->method($this->anything()) ->willReturnSelf(); @@ -639,7 +639,7 @@ class LDAPProviderTest extends \Test\TestCase { ->willReturn(true); $userBackend->expects($this->at(3)) ->method('getConfiguration') - ->willReturn(array('ldap_email_attr'=>'mail')); + ->willReturn(['ldap_email_attr'=>'mail']); $userBackend->expects($this->any()) ->method($this->anything()) ->willReturnSelf(); @@ -687,7 +687,7 @@ class LDAPProviderTest extends \Test\TestCase { ->willReturn(true); $groupBackend->expects($this->any()) ->method('getConfiguration') - ->willReturn(array('ldap_group_member_assoc_attribute'=>'assoc_type')); + ->willReturn(['ldap_group_member_assoc_attribute'=>'assoc_type']); $groupBackend->expects($this->any()) ->method($this->anything()) ->willReturnSelf(); diff --git a/apps/user_ldap/tests/LDAPTest.php b/apps/user_ldap/tests/LDAPTest.php index 9821336df75..c06017f4be4 100644 --- a/apps/user_ldap/tests/LDAPTest.php +++ b/apps/user_ldap/tests/LDAPTest.php @@ -86,7 +86,7 @@ class LDAPTest extends TestCase { $this->ldap ->expects($this->once()) ->method('invokeLDAPMethod') - ->with('mod_replace', $link, $userDN, array('userPassword' => $password)) + ->with('mod_replace', $link, $userDN, ['userPassword' => $password]) ->willReturn(true); $this->assertTrue($this->ldap->modReplace($link, $userDN, $password)); diff --git a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php index 57177819c2d..e4aadb3ea97 100644 --- a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php +++ b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php @@ -49,23 +49,23 @@ abstract class AbstractMappingTest extends \Test\TestCase { * @return array */ protected function getTestData() { - $data = array( - array( + $data = [ + [ 'dn' => 'uid=foobar,dc=example,dc=org', 'name' => 'Foobar', 'uuid' => '1111-AAAA-1234-CDEF', - ), - array( + ], + [ 'dn' => 'uid=barfoo,dc=example,dc=org', 'name' => 'Barfoo', 'uuid' => '2222-BBBB-1234-CDEF', - ), - array( + ], + [ 'dn' => 'uid=barabara,dc=example,dc=org', 'name' => 'BaraBara', 'uuid' => '3333-CCCC-1234-CDEF', - ) - ); + ] + ]; return $data; } @@ -97,7 +97,7 @@ abstract class AbstractMappingTest extends \Test\TestCase { $mapper->clear(); $this->mapEntries($mapper, $data); - return array($mapper, $data); + return [$mapper, $data]; } /** @@ -109,7 +109,7 @@ abstract class AbstractMappingTest extends \Test\TestCase { // test that mapping will not happen when it shall not $tooLongDN = 'uid=joann,ou=Secret Small Specialized Department,ou=Some Tremendously Important Department,ou=Another Very Important Department,ou=Pretty Meaningful Derpartment,ou=Quite Broad And General Department,ou=The Topmost Department,dc=hugelysuccessfulcompany,dc=com'; - $paramKeys = array('', 'dn', 'name', 'uuid', $tooLongDN); + $paramKeys = ['', 'dn', 'name', 'uuid', $tooLongDN]; foreach($paramKeys as $key) { $failEntry = $data[0]; if(!empty($key)) { diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php index cb9df7037b9..54a35f032b4 100644 --- a/apps/user_ldap/tests/User/UserTest.php +++ b/apps/user_ldap/tests/User/UserTest.php @@ -1032,9 +1032,9 @@ class UserTest extends \Test\TestCase { ->setMethods($requiredMethods) ->getMock(); - $this->connection->setConfiguration(array( + $this->connection->setConfiguration([ 'homeFolderNamingRule' => 'homeDirectory' - )); + ]); $this->connection->expects($this->any()) ->method('__get') ->willReturnCallback(function($name) { @@ -1070,10 +1070,10 @@ class UserTest extends \Test\TestCase { } public function emptyHomeFolderAttributeValueProvider() { - return array( + return [ 'empty' => [''], 'prefixOnly' => ['attr:'], - ); + ]; } /** diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index f3052b19327..baa307b2e6b 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -149,17 +149,17 @@ class User_LDAPTest extends TestCase { ->method('fetchListOfUsers') ->willReturnCallback(function($filter) { if($filter === 'roland') { - return array(array('dn' => ['dnOfRoland,dc=test'])); + return [['dn' => ['dnOfRoland,dc=test']]]; } - return array(); + return []; }); $this->access->expects($this->any()) ->method('fetchUsersByLoginName') ->willReturnCallback(function($uid) { if($uid === 'roland') { - return array(array('dn' => ['dnOfRoland,dc=test'])); + return [['dn' => ['dnOfRoland,dc=test']]]; } - return array(); + return []; }); $retVal = 'gunslinger'; @@ -378,11 +378,11 @@ class User_LDAPTest extends TestCase { $this->access->expects($this->any()) ->method('fetchListOfUsers') ->willReturnCallback(function($search, $a, $l, $o) { - $users = array('gunslinger', 'newyorker', 'ladyofshadows'); + $users = ['gunslinger', 'newyorker', 'ladyofshadows']; if(empty($search)) { $result = $users; } else { - $result = array(); + $result = []; foreach($users as $user) { if(stripos($user, $search) !== false) { $result[] = $user; @@ -545,7 +545,7 @@ class User_LDAPTest extends TestCase { ->method('readAttribute') ->willReturnCallback(function($dn) { if($dn === 'dnOfRoland,dc=test') { - return array(); + return []; } return false; }); @@ -570,7 +570,7 @@ class User_LDAPTest extends TestCase { ->method('readAttribute') ->willReturnCallback(function($dn) { if($dn === 'dnOfRoland,dc=test') { - return array(); + return []; } return false; }); @@ -613,9 +613,9 @@ class User_LDAPTest extends TestCase { switch ($dn) { case 'dnOfRoland,dc=test': if($attr === 'testAttribute') { - return array('/tmp/rolandshome/'); + return ['/tmp/rolandshome/']; } - return array(); + return []; break; default: return false; @@ -665,9 +665,9 @@ class User_LDAPTest extends TestCase { switch ($dn) { case 'dnOfLadyOfShadows,dc=test': if($attr === 'testAttribute') { - return array('susannah/'); + return ['susannah/']; } - return array(); + return []; break; default: return false; @@ -821,9 +821,9 @@ class User_LDAPTest extends TestCase { switch ($dn) { case 'dnOfRoland,dc=test': if($attr === 'displayname') { - return array('Roland Deschain'); + return ['Roland Deschain']; } - return array(); + return []; break; default: @@ -1156,17 +1156,17 @@ class User_LDAPTest extends TestCase { ->method('fetchListOfUsers') ->willReturnCallback(function($filter) { if($filter === 'roland') { - return array(array('dn' => ['dnOfRoland,dc=test'])); + return [['dn' => ['dnOfRoland,dc=test']]]; } - return array(); + return []; }); $this->access->expects($this->any()) ->method('fetchUsersByLoginName') ->willReturnCallback(function($uid) { if($uid === 'roland') { - return array(array('dn' => ['dnOfRoland,dc=test'])); + return [['dn' => ['dnOfRoland,dc=test']]]; } - return array(); + return []; }); $this->access->expects($this->any()) ->method('dn2username') diff --git a/apps/user_ldap/tests/WizardTest.php b/apps/user_ldap/tests/WizardTest.php index db23fc1ed40..50931c75ff6 100644 --- a/apps/user_ldap/tests/WizardTest.php +++ b/apps/user_ldap/tests/WizardTest.php @@ -47,8 +47,8 @@ class WizardTest extends TestCase { parent::setUp(); //we need to make sure the consts are defined, otherwise tests will fail //on systems without php5_ldap - $ldapConsts = array('LDAP_OPT_PROTOCOL_VERSION', - 'LDAP_OPT_REFERRALS', 'LDAP_OPT_NETWORK_TIMEOUT'); + $ldapConsts = ['LDAP_OPT_PROTOCOL_VERSION', + 'LDAP_OPT_REFERRALS', 'LDAP_OPT_NETWORK_TIMEOUT']; foreach($ldapConsts as $const) { if(!defined($const)) { define($const, 42); @@ -78,7 +78,7 @@ class WizardTest extends TestCase { /** @var Access|\PHPUnit_Framework_MockObject_MockObject $access */ $access = $this->createMock(Access::class); - return array(new Wizard($conf, $lw, $access), $conf, $lw, $access); + return [new Wizard($conf, $lw, $access), $conf, $lw, $access]; } private function prepareLdapWrapperForConnections(MockObject &$ldap) { @@ -104,7 +104,7 @@ class WizardTest extends TestCase { ->method('__get') ->willReturnCallback(function($name) { if($name === 'ldapBase') { - return array('base'); + return ['base']; } return null; }); @@ -139,7 +139,7 @@ class WizardTest extends TestCase { $ldap->expects($this->exactly(10)) ->method('getAttributes') //dummy value, usually invalid - ->willReturn(array('cn' => array('foo'), 'count' => 1)); + ->willReturn(['cn' => ['foo'], 'count' => 1]); global $uidnumber; $uidnumber = 1; @@ -152,7 +152,7 @@ class WizardTest extends TestCase { }); // The following expectations are the real test - $filters = array('f1', 'f2', '*'); + $filters = ['f1', 'f2', '*']; $wizard->cumulativeSearchOnAttribute($filters, 'cn', 5); unset($uidnumber); } @@ -164,7 +164,7 @@ class WizardTest extends TestCase { ->method('__get') ->willReturnCallback(function($name) { if($name === 'ldapBase') { - return array('base'); + return ['base']; } return null; }); @@ -215,7 +215,7 @@ class WizardTest extends TestCase { $ldap->expects($this->exactly(46)) ->method('getAttributes') //dummy value, usually invalid - ->willReturn(array('cn' => array('foo'), 'count' => 1)); + ->willReturn(['cn' => ['foo'], 'count' => 1]); global $uidnumber; $uidnumber = 1; @@ -228,7 +228,7 @@ class WizardTest extends TestCase { }); // The following expectations are the real test - $filters = array('f1', 'f2', '*'); + $filters = ['f1', 'f2', '*']; $wizard->cumulativeSearchOnAttribute($filters, 'cn', 0); unset($uidnumber); } @@ -380,7 +380,7 @@ class WizardTest extends TestCase { ->method('__get') ->willReturnCallback(function($name) { if($name === 'ldapBase') { - return array('base'); + return ['base']; } return null; }); @@ -432,7 +432,7 @@ class WizardTest extends TestCase { ->method('getAttributes') //dummy value, usually invalid ->willReturnCallback(function($a, $entry) { - return array('cn' => array($entry), 'count' => 1); + return ['cn' => [$entry], 'count' => 1]; }); $ldap->expects($this->any()) @@ -443,7 +443,7 @@ class WizardTest extends TestCase { }); // The following expectations are the real test - $filters = array('f1', 'f2', '*'); + $filters = ['f1', 'f2', '*']; $resultArray = $wizard->cumulativeSearchOnAttribute($filters, 'cn', 0); $this->assertSame(6, count($resultArray)); unset($mark); |