diff options
Diffstat (limited to 'apps')
165 files changed, 1302 insertions, 1302 deletions
diff --git a/apps/accessibility/lib/AccessibilityProvider.php b/apps/accessibility/lib/AccessibilityProvider.php index ce9489df5f2..c922c7e2850 100644 --- a/apps/accessibility/lib/AccessibilityProvider.php +++ b/apps/accessibility/lib/AccessibilityProvider.php @@ -57,7 +57,7 @@ class AccessibilityProvider { } public function getThemes() { - return array( + return [ [ 'id' => 'dark', 'img' => $this->urlGenerator->imagePath($this->appName, 'theme-dark.jpg'), @@ -65,7 +65,7 @@ class AccessibilityProvider { 'enableLabel' => $this->l->t('Enable dark theme'), 'text' => $this->l->t('A dark theme to ease your eyes by reducing the overall luminosity and brightness. It is still under development, so please report any issues you may find.') ] - ); + ]; } public function getHighContrast() { @@ -79,7 +79,7 @@ class AccessibilityProvider { } public function getFonts() { - return array( + return [ [ 'id' => 'fontdyslexic', 'img' => $this->urlGenerator->imagePath($this->appName, 'font-opendyslexic.jpg'), @@ -87,7 +87,7 @@ class AccessibilityProvider { 'enableLabel' => $this->l->t('Enable dyslexia font'), 'text' => $this->l->t('OpenDyslexic is a free typeface/font designed to mitigate some of the common reading errors caused by dyslexia.') ] - ); + ]; } } diff --git a/apps/accessibility/lib/Controller/ConfigController.php b/apps/accessibility/lib/Controller/ConfigController.php index a84281501ca..d089feda300 100644 --- a/apps/accessibility/lib/Controller/ConfigController.php +++ b/apps/accessibility/lib/Controller/ConfigController.php @@ -113,7 +113,7 @@ class ConfigController extends OCSController { } $themes = $this->accessibilityProvider->getThemes(); - $highcontrast = array($this->accessibilityProvider->getHighContrast()); + $highcontrast = [$this->accessibilityProvider->getHighContrast()]; $fonts = $this->accessibilityProvider->getFonts(); $availableOptions = array_map(function($option) { diff --git a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php index c31ff10e1d7..db5f48adf23 100644 --- a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php +++ b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php @@ -290,7 +290,7 @@ class RequestHandlerController extends Controller { \OCP\Util::emitHook( '\OCA\Files_Sharing\API\Server2Server', 'preLoginNameUsedAsUserName', - array('uid' => &$uid) + ['uid' => &$uid] ); $this->logger->debug('shareWith after, ' . $uid, ['app' => $this->appName]); diff --git a/apps/comments/lib/AppInfo/Application.php b/apps/comments/lib/AppInfo/Application.php index bd883071adc..9a9df25edfd 100644 --- a/apps/comments/lib/AppInfo/Application.php +++ b/apps/comments/lib/AppInfo/Application.php @@ -44,7 +44,7 @@ class Application extends App { const APP_ID = 'comments'; - public function __construct (array $urlParams = array()) { + public function __construct (array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); $container = $this->getContainer(); diff --git a/apps/dav/appinfo/v1/caldav.php b/apps/dav/appinfo/v1/caldav.php index 529fa576b4a..82fddd152e6 100644 --- a/apps/dav/appinfo/v1/caldav.php +++ b/apps/dav/appinfo/v1/caldav.php @@ -69,10 +69,10 @@ $principalCollection->disableListing = !$debugging; // Disable listing $addressBookRoot = new CalendarRoot($principalBackend, $calDavBackend); $addressBookRoot->disableListing = !$debugging; // Disable listing -$nodes = array( +$nodes = [ $principalCollection, $addressBookRoot, -); +]; // Fire up server $server = new \Sabre\DAV\Server($nodes); diff --git a/apps/dav/appinfo/v1/carddav.php b/apps/dav/appinfo/v1/carddav.php index b8886c0d152..b2e812c2c18 100644 --- a/apps/dav/appinfo/v1/carddav.php +++ b/apps/dav/appinfo/v1/carddav.php @@ -69,10 +69,10 @@ $pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager $addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager); $addressBookRoot->disableListing = !$debugging; // Disable listing -$nodes = array( +$nodes = [ $principalCollection, $addressBookRoot, -); +]; // Fire up server $server = new \Sabre\DAV\Server($nodes); diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php index f0e3cc6438d..53f1b0d62b4 100644 --- a/apps/dav/appinfo/v1/publicwebdav.php +++ b/apps/dav/appinfo/v1/publicwebdav.php @@ -79,7 +79,7 @@ $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, funct // FIXME: should not add storage wrappers outside of preSetup, need to find a better way $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) { - return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE)); + return new \OC\Files\Storage\Wrapper\PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]); }); \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 96459566a5a..7280288c02d 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1944,7 +1944,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription } } - $valuesToInsert = array(); + $valuesToInsert = []; $query = $this->db->getQueryBuilder(); diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 982c579d3bb..3b66e84fc2b 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -237,13 +237,13 @@ class IMipPlugin extends SabreIMipPlugin { break; } - $data = array( + $data = [ 'attendee_name' => (string)$meetingAttendeeName ?: $defaultVal, 'invitee_name' => (string)$meetingInviteeName ?: $defaultVal, 'meeting_title' => (string)$meetingTitle ?: $defaultVal, 'meeting_description' => (string)$meetingDescription ?: $defaultVal, 'meeting_url' => (string)$meetingUrl ?: $defaultVal, - ); + ]; $fromEMail = \OCP\Util::getDefaultEmailAddress('invitations-noreply'); $fromName = $l10n->t('%1$s via %2$s', [$senderName, $this->defaults->getName()]); diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 24b91f7cec3..bd89b233aee 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -74,9 +74,9 @@ class CardDavBackend implements BackendInterface, SyncSupport { private $sharingBackend; /** @var array properties to index */ - public static $indexProperties = array( + public static $indexProperties = [ 'BDAY', 'UID', 'N', 'FN', 'TITLE', 'ROLE', 'NOTE', 'NICKNAME', - 'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO', 'CLOUD'); + 'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO', 'CLOUD']; /** * @var string[] Map of uid => display name @@ -909,7 +909,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { * - 'escape_like_param' - If set to false wildcards _ and % are not escaped, otherwise they are * @return array an array of contacts which are arrays of key-value-pairs */ - public function search($addressBookId, $pattern, $searchProperties, $options = array()) { + public function search($addressBookId, $pattern, $searchProperties, $options = []) { $query = $this->db->getQueryBuilder(); $query2 = $this->db->getQueryBuilder(); diff --git a/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php b/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php index 139044f9535..947b2960eab 100644 --- a/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php +++ b/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php @@ -74,7 +74,7 @@ class AppEnabledPlugin extends ServerPlugin { public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; - $this->server->on('beforeMethod', array($this, 'checkAppEnabled'), 30); + $this->server->on('beforeMethod', [$this, 'checkAppEnabled'], 30); } /** diff --git a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php index 1a069e548b4..22f0104940d 100644 --- a/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php @@ -67,7 +67,7 @@ class CommentPropertiesPlugin extends ServerPlugin { */ function initialize(\Sabre\DAV\Server $server) { $this->server = $server; - $this->server->on('propFind', array($this, 'handleGetProperties')); + $this->server->on('propFind', [$this, 'handleGetProperties']); } /** diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php index d17cfb81777..9b44997fb60 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -267,7 +267,7 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node throw new Locked(); } - $nodes = array(); + $nodes = []; foreach ($folderContent as $info) { $node = $this->getChild($info->getName(), $info); $nodes[] = $node; @@ -336,13 +336,13 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node } else { $free = $storageInfo['free']; } - $this->quotaInfo = array( + $this->quotaInfo = [ $storageInfo['used'], $free - ); + ]; return $this->quotaInfo; } catch (\OCP\Files\StorageNotAvailableException $e) { - return array(0, 0); + return [0, 0]; } } diff --git a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php index dc595197965..cf617152eb8 100644 --- a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php +++ b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php @@ -103,7 +103,7 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin { */ public function initialize(\Sabre\DAV\Server $server) { - $server->on('exception', array($this, 'logException'), 10); + $server->on('exception', [$this, 'logException'], 10); } /** diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 098961ce130..0bd01de408b 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -359,20 +359,20 @@ class File extends Node implements IFile { $run = true; if (!$exists) { - \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create, array( + \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create, [ \OC\Files\Filesystem::signal_param_path => $hookPath, \OC\Files\Filesystem::signal_param_run => &$run, - )); + ]); } else { - \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_update, array( + \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_update, [ \OC\Files\Filesystem::signal_param_path => $hookPath, \OC\Files\Filesystem::signal_param_run => &$run, - )); + ]); } - \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_write, array( + \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_write, [ \OC\Files\Filesystem::signal_param_path => $hookPath, \OC\Files\Filesystem::signal_param_run => &$run, - )); + ]); return $run; } @@ -385,17 +385,17 @@ class File extends Node implements IFile { } $hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path)); if (!$exists) { - \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, array( + \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, [ \OC\Files\Filesystem::signal_param_path => $hookPath - )); + ]); } else { - \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_update, array( + \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_update, [ \OC\Files\Filesystem::signal_param_path => $hookPath - )); + ]); } - \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_write, array( + \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_write, [ \OC\Files\Filesystem::signal_param_path => $hookPath - )); + ]); } /** diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index 498058f7c03..a35db1e77e4 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -173,12 +173,12 @@ class FilesPlugin extends ServerPlugin { $server->protectedProperties = array_diff($server->protectedProperties, $allowedProperties); $this->server = $server; - $this->server->on('propFind', array($this, 'handleGetProperties')); - $this->server->on('propPatch', array($this, 'handleUpdateProperties')); - $this->server->on('afterBind', array($this, 'sendFileIdHeader')); - $this->server->on('afterWriteContent', array($this, 'sendFileIdHeader')); + $this->server->on('propFind', [$this, 'handleGetProperties']); + $this->server->on('propPatch', [$this, 'handleUpdateProperties']); + $this->server->on('afterBind', [$this, 'sendFileIdHeader']); + $this->server->on('afterWriteContent', [$this, 'sendFileIdHeader']); $this->server->on('afterMethod:GET', [$this,'httpGet']); - $this->server->on('afterMethod:GET', array($this, 'handleDownloadToken')); + $this->server->on('afterMethod:GET', [$this, 'handleDownloadToken']); $this->server->on('afterResponse', function($request, ResponseInterface $response) { $body = $response->getBody(); if (is_resource($body)) { diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php index 41de6ea4ed8..a2de82fa9c5 100644 --- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php @@ -154,7 +154,7 @@ class FilesReportPlugin extends ServerPlugin { $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc'; $this->server = $server; - $this->server->on('report', array($this, 'onReport')); + $this->server->on('report', [$this, 'onReport']); } /** diff --git a/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php b/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php index d015bcbc21c..4076abe59fe 100644 --- a/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php +++ b/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php @@ -67,7 +67,7 @@ class MaintenancePlugin extends ServerPlugin { */ public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; - $this->server->on('beforeMethod', array($this, 'checkMaintenanceMode'), 1); + $this->server->on('beforeMethod', [$this, 'checkMaintenanceMode'], 1); } /** diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index f178b2fbfbd..5f9ecf88142 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -200,15 +200,15 @@ abstract class Node implements \Sabre\DAV\INode { * @return int file id of updated file or -1 on failure */ public function setETag($etag) { - return $this->fileView->putFileInfo($this->path, array('etag' => $etag)); + return $this->fileView->putFileInfo($this->path, ['etag' => $etag]); } public function setCreationTime(int $time) { - return $this->fileView->putFileInfo($this->path, array('creation_time' => $time)); + return $this->fileView->putFileInfo($this->path, ['creation_time' => $time]); } public function setUploadTime(int $time) { - return $this->fileView->putFileInfo($this->path, array('upload_time' => $time)); + return $this->fileView->putFileInfo($this->path, ['upload_time' => $time]); } /** diff --git a/apps/dav/lib/Connector/Sabre/SharesPlugin.php b/apps/dav/lib/Connector/Sabre/SharesPlugin.php index a4baa65948e..9d543e55a4b 100644 --- a/apps/dav/lib/Connector/Sabre/SharesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/SharesPlugin.php @@ -107,7 +107,7 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin { $server->protectedProperties[] = self::SHAREES_PROPERTYNAME; $this->server = $server; - $this->server->on('propFind', array($this, 'handleGetProperties')); + $this->server->on('propFind', [$this, 'handleGetProperties']); } private function getShare(\OCP\Files\Node $node): array { diff --git a/apps/dav/lib/Connector/Sabre/TagsPlugin.php b/apps/dav/lib/Connector/Sabre/TagsPlugin.php index fe19b434648..2ac7c01f426 100644 --- a/apps/dav/lib/Connector/Sabre/TagsPlugin.php +++ b/apps/dav/lib/Connector/Sabre/TagsPlugin.php @@ -98,7 +98,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin $this->tree = $tree; $this->tagManager = $tagManager; $this->tagger = null; - $this->cachedTags = array(); + $this->cachedTags = []; } /** @@ -118,8 +118,8 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin $server->xml->elementMap[self::TAGS_PROPERTYNAME] = TagList::class; $this->server = $server; - $this->server->on('propFind', array($this, 'handleGetProperties')); - $this->server->on('propPatch', array($this, 'handleUpdateProperties')); + $this->server->on('propFind', [$this, 'handleGetProperties']); + $this->server->on('propPatch', [$this, 'handleUpdateProperties']); } /** @@ -151,7 +151,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin unset($tags[$favPos]); } } - return array($tags, $isFav); + return [$tags, $isFav]; } /** @@ -164,10 +164,10 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin if (isset($this->cachedTags[$fileId])) { return $this->cachedTags[$fileId]; } else { - $tags = $this->getTagger()->getTagsForObjects(array($fileId)); + $tags = $this->getTagger()->getTagsForObjects([$fileId]); if ($tags !== false) { if (empty($tags)) { - return array(); + return []; } return current($tags); } @@ -232,7 +232,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin $tags = $this->getTagger()->getTagsForObjects($fileIds); if ($tags === false) { // the tags API returns false on error... - $tags = array(); + $tags = []; } $this->cachedTags = $this->cachedTags + $tags; diff --git a/apps/dav/lib/Files/BrowserErrorPagePlugin.php b/apps/dav/lib/Files/BrowserErrorPagePlugin.php index 9bc169601af..7b0d39f2fbb 100644 --- a/apps/dav/lib/Files/BrowserErrorPagePlugin.php +++ b/apps/dav/lib/Files/BrowserErrorPagePlugin.php @@ -48,7 +48,7 @@ class BrowserErrorPagePlugin extends ServerPlugin { */ function initialize(Server $server) { $this->server = $server; - $server->on('exception', array($this, 'logException'), 1000); + $server->on('exception', [$this, 'logException'], 1000); } /** diff --git a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php index b940fa55b5b..f580b7fe47a 100644 --- a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php +++ b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php @@ -88,7 +88,7 @@ class RemoveOrphanEventsAndContacts implements IRepairStep { $result = $qb->execute(); - $orphanItems = array(); + $orphanItems = []; while ($row = $result->fetch()) { $orphanItems[] = (int) $row['id']; } diff --git a/apps/dav/lib/SystemTag/SystemTagPlugin.php b/apps/dav/lib/SystemTag/SystemTagPlugin.php index c86f621a67d..d44b21b24c9 100644 --- a/apps/dav/lib/SystemTag/SystemTagPlugin.php +++ b/apps/dav/lib/SystemTag/SystemTagPlugin.php @@ -107,8 +107,8 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin { $server->protectedProperties[] = self::ID_PROPERTYNAME; - $server->on('propFind', array($this, 'handleGetProperties')); - $server->on('propPatch', array($this, 'handleUpdateProperties')); + $server->on('propFind', [$this, 'handleGetProperties']); + $server->on('propPatch', [$this, 'handleUpdateProperties']); $server->on('method:POST', [$this, 'httpPost']); $this->server = $server; diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 257c6665dfe..cc942b5662c 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -130,7 +130,7 @@ class CalDavBackendTest extends AbstractCalDavBackend { $l10n ->expects($this->any()) ->method('t') - ->willReturnCallback(function ($text, $parameters = array()) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); diff --git a/apps/dav/tests/unit/CalDAV/CalendarTest.php b/apps/dav/tests/unit/CalDAV/CalendarTest.php index 9a9f36c9309..42cbeb1c0b9 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarTest.php @@ -53,7 +53,7 @@ class CalendarTest extends TestCase { $this->l10n ->expects($this->any()) ->method('t') - ->willReturnCallback(function ($text, $parameters = array()) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); } diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php index 5cd4e69b7f5..518c0b9402a 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php @@ -97,9 +97,9 @@ class CustomPropertiesBackendTest extends \Test\TestCase { ' WHERE `userid` = ?' ); $deleteStatement->execute( - array( + [ $this->user->getUID(), - ) + ] ); $deleteStatement->closeCursor(); } @@ -121,10 +121,10 @@ class CustomPropertiesBackendTest extends \Test\TestCase { private function applyDefaultProps($path = '/dummypath') { // properties to set - $propPatch = new \Sabre\DAV\PropPatch(array( + $propPatch = new \Sabre\DAV\PropPatch([ 'customprop' => 'value1', 'customprop2' => 'value2', - )); + ]); $this->plugin->propPatch( $path, @@ -146,11 +146,11 @@ class CustomPropertiesBackendTest extends \Test\TestCase { public function testPropFindMissingFileSoftFail() { $propFind = new \Sabre\DAV\PropFind( '/dummypath', - array( + [ 'customprop', 'customprop2', 'unsetprop', - ), + ], 0 ); @@ -176,11 +176,11 @@ class CustomPropertiesBackendTest extends \Test\TestCase { $propFind = new \Sabre\DAV\PropFind( '/dummypath', - array( + [ 'customprop', 'customprop2', 'unsetprop', - ), + ], 0 ); @@ -191,7 +191,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase { $this->assertEquals('value1', $propFind->get('customprop')); $this->assertEquals('value2', $propFind->get('customprop2')); - $this->assertEquals(array('unsetprop'), $propFind->get404Properties()); + $this->assertEquals(['unsetprop'], $propFind->get404Properties()); } /** @@ -201,11 +201,11 @@ class CustomPropertiesBackendTest extends \Test\TestCase { $this->applyDefaultProps('/dummypath'); $this->applyDefaultProps('/dummypath/test.txt'); - $propNames = array( + $propNames = [ 'customprop', 'customprop2', 'unsetprop', - ); + ]; $propFindRoot = new \Sabre\DAV\PropFind( '/dummypath', @@ -234,11 +234,11 @@ class CustomPropertiesBackendTest extends \Test\TestCase { $this->assertEquals('value1', $propFindRoot->get('customprop')); $this->assertEquals('value2', $propFindRoot->get('customprop2')); - $this->assertEquals(array('unsetprop'), $propFindRoot->get404Properties()); + $this->assertEquals(['unsetprop'], $propFindRoot->get404Properties()); $this->assertEquals('value1', $propFindSub->get('customprop')); $this->assertEquals('value2', $propFindSub->get('customprop2')); - $this->assertEquals(array('unsetprop'), $propFindSub->get404Properties()); + $this->assertEquals(['unsetprop'], $propFindSub->get404Properties()); } /** @@ -247,9 +247,9 @@ class CustomPropertiesBackendTest extends \Test\TestCase { public function testDeleteProperty() { $this->applyDefaultProps(); - $propPatch = new \Sabre\DAV\PropPatch(array( + $propPatch = new \Sabre\DAV\PropPatch([ 'customprop' => null, - )); + ]); $this->plugin->propPatch( '/dummypath', diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index 1bf0b533966..9ace061fd0e 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -201,7 +201,7 @@ class DirectoryTest extends \Test\TestCase { $this->view->expects($this->once()) ->method('getDirectoryContent') ->with('') - ->willReturn(array($info1, $info2)); + ->willReturn([$info1, $info2]); $this->view->expects($this->any()) ->method('getRelativePath') diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index 96f5a2c385c..a898ba5dee7 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -202,9 +202,9 @@ class FileTest extends TestCase { ->method('getRelativePath') ->willReturnArgument(0); - $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); @@ -631,10 +631,10 @@ class FileTest extends TestCase { } public static function cancellingHook($params) { - self::$hookCalls[] = array( + self::$hookCalls[] = [ 'signal' => Filesystem::signal_post_create, 'params' => $params - ); + ]; } /** @@ -683,9 +683,9 @@ class FileTest extends TestCase { $_SERVER['CONTENT_LENGTH'] = 123456; $_SERVER['REQUEST_METHOD'] = 'PUT'; - $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); @@ -716,9 +716,9 @@ class FileTest extends TestCase { // simulate situation where the target file is locked $view->lockFile('/test.txt', ILockingProvider::LOCK_EXCLUSIVE); - $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); @@ -790,9 +790,9 @@ class FileTest extends TestCase { ->method('getRelativePath') ->willReturnArgument(0); - $info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); // action @@ -829,9 +829,9 @@ class FileTest extends TestCase { ->method('getRelativePath') ->willReturnArgument(0); - $info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file->setName('/super*star.txt'); } @@ -856,9 +856,9 @@ class FileTest extends TestCase { $_SERVER['CONTENT_LENGTH'] = 12345; $_SERVER['REQUEST_METHOD'] = 'PUT'; - $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); @@ -890,9 +890,9 @@ class FileTest extends TestCase { ->method('unlink') ->willReturn(true); - $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); @@ -908,9 +908,9 @@ class FileTest extends TestCase { $view = $this->getMockBuilder(View::class) ->getMock(); - $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [ 'permissions' => 0 - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); @@ -931,9 +931,9 @@ class FileTest extends TestCase { ->method('unlink') ->willReturn(false); - $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); @@ -954,9 +954,9 @@ class FileTest extends TestCase { ->method('unlink') ->willThrowException(new ForbiddenException('', true)); - $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); @@ -1122,9 +1122,9 @@ class FileTest extends TestCase { ->method('fopen') ->willReturn(false); - $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); @@ -1142,9 +1142,9 @@ class FileTest extends TestCase { ->method('fopen') ->willThrowException(new ForbiddenException('', true)); - $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( + $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [ 'permissions' => \OCP\Constants::PERMISSION_ALL - ), null); + ], null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php index d1e863b18ba..06495ccd5e2 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php @@ -181,7 +181,7 @@ class FilesPluginTest extends TestCase { $propFind = new PropFind( '/dummyPath', - array( + [ self::GETETAG_PROPERTYNAME, self::FILEID_PROPERTYNAME, self::INTERNAL_FILEID_PROPERTYNAME, @@ -191,7 +191,7 @@ class FilesPluginTest extends TestCase { self::OWNER_ID_PROPERTYNAME, self::OWNER_DISPLAY_NAME_PROPERTYNAME, self::DATA_FINGERPRINT_PROPERTYNAME, - ), + ], 0 ); @@ -208,7 +208,7 @@ class FilesPluginTest extends TestCase { $node->expects($this->once()) ->method('getDirectDownload') - ->willReturn(array('url' => 'http://example.com/')); + ->willReturn(['url' => 'http://example.com/']); $node->expects($this->exactly(2)) ->method('getOwner') ->willReturn($user); @@ -236,9 +236,9 @@ class FilesPluginTest extends TestCase { $propFind = new PropFind( '/dummyPath', - array( + [ self::DOWNLOADURL_PROPERTYNAME, - ), + ], 0 ); @@ -293,14 +293,14 @@ class FilesPluginTest extends TestCase { $propFind = new PropFind( '/dummyPath', - array( + [ self::GETETAG_PROPERTYNAME, self::FILEID_PROPERTYNAME, self::SIZE_PROPERTYNAME, self::PERMISSIONS_PROPERTYNAME, self::DOWNLOADURL_PROPERTYNAME, self::DATA_FINGERPRINT_PROPERTYNAME, - ), + ], 0 ); @@ -405,10 +405,10 @@ class FilesPluginTest extends TestCase { ->willReturn(true); // properties to set - $propPatch = new PropPatch(array( + $propPatch = new PropPatch([ self::GETETAG_PROPERTYNAME => 'newetag', self::LASTMODIFIED_PROPERTYNAME => $testDate - )); + ]); $this->plugin->handleUpdateProperties( '/dummypath', @@ -425,14 +425,14 @@ class FilesPluginTest extends TestCase { } public function testUpdatePropsForbidden() { - $propPatch = new PropPatch(array( + $propPatch = new PropPatch([ self::OWNER_ID_PROPERTYNAME => 'user2', self::OWNER_DISPLAY_NAME_PROPERTYNAME => 'User Two', self::FILEID_PROPERTYNAME => 12345, self::PERMISSIONS_PROPERTYNAME => 'C', self::SIZE_PROPERTYNAME => 123, self::DOWNLOADURL_PROPERTYNAME => 'http://example.com/', - )); + ]); $this->plugin->handleUpdateProperties( '/dummypath', @@ -588,9 +588,9 @@ class FilesPluginTest extends TestCase { $propFind = new PropFind( '/dummyPath', - array( + [ self::HAS_PREVIEW_PROPERTYNAME - ), + ], 0 ); diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php index 5d71a705362..93542f80368 100644 --- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php @@ -42,19 +42,19 @@ use OCP\Share\IShare; */ class NodeTest extends \Test\TestCase { public function davPermissionsProvider() { - return array( - array(\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RGDNVW'), - array(\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RGDNVCK'), - array(\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRGDNVW'), - array(\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMGDNVW'), - array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SGDNVW'), - array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_UPDATE, 'file', false, false, 'RGD'), - array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE, 'file', false, false, 'RGNVW'), - array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'file', false, false, 'RGDNVW'), - array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_READ, 'file', false, false, 'RDNVW'), - array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'dir', false, false, 'RGDNV'), - array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_READ, 'dir', false, false, 'RDNVCK'), - ); + return [ + [\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RGDNVW'], + [\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RGDNVCK'], + [\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRGDNVW'], + [\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMGDNVW'], + [\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SGDNVW'], + [\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_UPDATE, 'file', false, false, 'RGD'], + [\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE, 'file', false, false, 'RGNVW'], + [\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'file', false, false, 'RGDNVW'], + [\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_READ, 'file', false, false, 'RDNVW'], + [\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'dir', false, false, 'RGDNV'], + [\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_READ, 'dir', false, false, 'RDNVCK'], + ]; } /** @@ -63,7 +63,7 @@ class NodeTest extends \Test\TestCase { public function testDavPermissions($permissions, $type, $shared, $mounted, $expected) { $info = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() - ->setMethods(array('getPermissions', 'isShared', 'isMounted', 'getType')) + ->setMethods(['getPermissions', 'isShared', 'isMounted', 'getType']) ->getMock(); $info->expects($this->any()) ->method('getPermissions') diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php index 76ebbe30189..3a2c8d8c438 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php @@ -201,72 +201,72 @@ class ObjectTreeTest extends \Test\TestCase { } function nodeForPathProvider() { - return array( + return [ // regular file - array( + [ 'regularfile.txt', 'regularfile.txt', 'regularfile.txt', 'file', false - ), + ], // regular directory - array( + [ 'regulardir', 'regulardir', 'regulardir', 'dir', false - ), + ], // regular file with chunking - array( + [ 'regularfile.txt', 'regularfile.txt', 'regularfile.txt', 'file', true - ), + ], // regular directory with chunking - array( + [ 'regulardir', 'regulardir', 'regulardir', 'dir', true - ), + ], // file with chunky file name - array( + [ 'regularfile.txt-chunking-123566789-10-1', 'regularfile.txt', 'regularfile.txt', 'file', true - ), + ], // regular file in subdir - array( + [ 'subdir/regularfile.txt', 'subdir/regularfile.txt', 'regularfile.txt', 'file', false - ), + ], // regular directory in subdir - array( + [ 'subdir/regulardir', 'subdir/regulardir', 'regulardir', 'dir', false - ), + ], // file with chunky file name in subdir - array( + [ 'subdir/regularfile.txt-chunking-123566789-10-1', 'subdir/regularfile.txt', 'regularfile.txt', 'file', true - ), - ); + ], + ]; } diff --git a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php index 57613c19f64..55528a0f87f 100644 --- a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php @@ -410,7 +410,7 @@ class PrincipalTest extends TestCase { } public function testUpdatePrincipal() { - $this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch(array()))); + $this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch([]))); } public function testSearchPrincipalsWithEmptySearchProperties() { diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php index 50b3ff1c394..d7554741fc0 100644 --- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php @@ -112,30 +112,30 @@ class QuotaPluginTest extends TestCase { } public function quotaOkayProvider() { - return array( - array(1024, array()), - array(1024, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), - array(1024, array('CONTENT-LENGTH' => '512')), - array(1024, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), - - array(FileInfo::SPACE_UNKNOWN, array()), - array(FileInfo::SPACE_UNKNOWN, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), - array(FileInfo::SPACE_UNKNOWN, array('CONTENT-LENGTH' => '512')), - array(FileInfo::SPACE_UNKNOWN, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), - - array(FileInfo::SPACE_UNLIMITED, array()), - array(FileInfo::SPACE_UNLIMITED, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), - array(FileInfo::SPACE_UNLIMITED, array('CONTENT-LENGTH' => '512')), - array(FileInfo::SPACE_UNLIMITED, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), - ); + return [ + [1024, []], + [1024, ['X-EXPECTED-ENTITY-LENGTH' => '1024']], + [1024, ['CONTENT-LENGTH' => '512']], + [1024, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']], + + [FileInfo::SPACE_UNKNOWN, []], + [FileInfo::SPACE_UNKNOWN, ['X-EXPECTED-ENTITY-LENGTH' => '1024']], + [FileInfo::SPACE_UNKNOWN, ['CONTENT-LENGTH' => '512']], + [FileInfo::SPACE_UNKNOWN, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']], + + [FileInfo::SPACE_UNLIMITED, []], + [FileInfo::SPACE_UNLIMITED, ['X-EXPECTED-ENTITY-LENGTH' => '1024']], + [FileInfo::SPACE_UNLIMITED, ['CONTENT-LENGTH' => '512']], + [FileInfo::SPACE_UNLIMITED, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']], + ]; } public function quotaExceededProvider() { - return array( - array(1023, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), - array(511, array('CONTENT-LENGTH' => '512')), - array(2047, array('OC-TOTAL-LENGTH' => '2048', 'CONTENT-LENGTH' => '1024')), - ); + return [ + [1023, ['X-EXPECTED-ENTITY-LENGTH' => '1024']], + [511, ['CONTENT-LENGTH' => '512']], + [2047, ['OC-TOTAL-LENGTH' => '2048', 'CONTENT-LENGTH' => '1024']], + ]; } public function lengthProvider() { @@ -155,22 +155,22 @@ class QuotaPluginTest extends TestCase { } public function quotaChunkedOkProvider() { - return array( - array(1024, 0, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), - array(1024, 0, array('CONTENT-LENGTH' => '512')), - array(1024, 0, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), + return [ + [1024, 0, ['X-EXPECTED-ENTITY-LENGTH' => '1024']], + [1024, 0, ['CONTENT-LENGTH' => '512']], + [1024, 0, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']], // with existing chunks (allowed size = total length - chunk total size) - array(400, 128, array('X-EXPECTED-ENTITY-LENGTH' => '512')), - array(400, 128, array('CONTENT-LENGTH' => '512')), - array(400, 128, array('OC-TOTAL-LENGTH' => '512', 'CONTENT-LENGTH' => '500')), + [400, 128, ['X-EXPECTED-ENTITY-LENGTH' => '512']], + [400, 128, ['CONTENT-LENGTH' => '512']], + [400, 128, ['OC-TOTAL-LENGTH' => '512', 'CONTENT-LENGTH' => '500']], // \OCP\Files\FileInfo::SPACE-UNKNOWN = -2 - array(-2, 0, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), - array(-2, 0, array('CONTENT-LENGTH' => '512')), - array(-2, 0, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), - array(-2, 128, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), - array(-2, 128, array('CONTENT-LENGTH' => '512')), - array(-2, 128, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), - ); + [-2, 0, ['X-EXPECTED-ENTITY-LENGTH' => '1024']], + [-2, 0, ['CONTENT-LENGTH' => '512']], + [-2, 0, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']], + [-2, 128, ['X-EXPECTED-ENTITY-LENGTH' => '1024']], + [-2, 128, ['CONTENT-LENGTH' => '512']], + [-2, 128, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']], + ]; } /** @@ -197,15 +197,15 @@ class QuotaPluginTest extends TestCase { } public function quotaChunkedFailProvider() { - return array( - array(400, 0, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), - array(400, 0, array('CONTENT-LENGTH' => '512')), - array(400, 0, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), + return [ + [400, 0, ['X-EXPECTED-ENTITY-LENGTH' => '1024']], + [400, 0, ['CONTENT-LENGTH' => '512']], + [400, 0, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']], // with existing chunks (allowed size = total length - chunk total size) - array(380, 128, array('X-EXPECTED-ENTITY-LENGTH' => '512')), - array(380, 128, array('CONTENT-LENGTH' => '512')), - array(380, 128, array('OC-TOTAL-LENGTH' => '512', 'CONTENT-LENGTH' => '500')), - ); + [380, 128, ['X-EXPECTED-ENTITY-LENGTH' => '512']], + [380, 128, ['CONTENT-LENGTH' => '512']], + [380, 128, ['OC-TOTAL-LENGTH' => '512', 'CONTENT-LENGTH' => '500']], + ]; } /** diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php index c1eaaae42c3..c0450d3bbb6 100644 --- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php @@ -108,8 +108,8 @@ class TagsPluginTest extends \Test\TestCase { $this->tagger->expects($this->exactly($expectedCallCount)) ->method('getTagsForObjects') - ->with($this->equalTo(array(123))) - ->willReturn(array(123 => $tags)); + ->with($this->equalTo([123])) + ->willReturn([123 => $tags]); $propFind = new \Sabre\DAV\PropFind( '/dummyPath', @@ -162,16 +162,16 @@ class TagsPluginTest extends \Test\TestCase { ->willReturn(123); $node->expects($this->exactly($expectedCallCount)) ->method('getChildren') - ->willReturn(array($node1, $node2)); + ->willReturn([$node1, $node2]); $this->tagger->expects($this->exactly($expectedCallCount)) ->method('getTagsForObjects') - ->with($this->equalTo(array(123, 111, 222))) + ->with($this->equalTo([123, 111, 222])) ->willReturn( - array( + [ 111 => $tags, 123 => $tags - ) + ] ); // simulate sabre recursive PROPFIND traversal @@ -212,58 +212,58 @@ class TagsPluginTest extends \Test\TestCase { } function tagsGetPropertiesDataProvider() { - return array( + return [ // request both, receive both - array( - array('tag1', 'tag2', self::TAG_FAVORITE), - array(self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME), - array( - 200 => array( - self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array('tag1', 'tag2')), + [ + ['tag1', 'tag2', self::TAG_FAVORITE], + [self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME], + [ + 200 => [ + self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2']), self::FAVORITE_PROPERTYNAME => true, - ) - ) - ), + ] + ] + ], // request tags alone - array( - array('tag1', 'tag2', self::TAG_FAVORITE), - array(self::TAGS_PROPERTYNAME), - array( - 200 => array( - self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array('tag1', 'tag2')), - ) - ) - ), + [ + ['tag1', 'tag2', self::TAG_FAVORITE], + [self::TAGS_PROPERTYNAME], + [ + 200 => [ + self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2']), + ] + ] + ], // request fav alone - array( - array('tag1', 'tag2', self::TAG_FAVORITE), - array(self::FAVORITE_PROPERTYNAME), - array( - 200 => array( + [ + ['tag1', 'tag2', self::TAG_FAVORITE], + [self::FAVORITE_PROPERTYNAME], + [ + 200 => [ self::FAVORITE_PROPERTYNAME => true, - ) - ) - ), + ] + ] + ], // request none - array( - array('tag1', 'tag2', self::TAG_FAVORITE), - array(), - array( - 200 => array() - ), - ), + [ + ['tag1', 'tag2', self::TAG_FAVORITE], + [], + [ + 200 => [] + ], + ], // request both with none set, receive both - array( - array(), - array(self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME), - array( - 200 => array( - self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array()), + [ + [], + [self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME], + [ + 200 => [ + self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList([]), self::FAVORITE_PROPERTYNAME => false, - ) - ) - ), - ); + ] + ] + ], + ]; } public function testUpdateTags() { @@ -283,8 +283,8 @@ class TagsPluginTest extends \Test\TestCase { $this->tagger->expects($this->at(0)) ->method('getTagsForObjects') - ->with($this->equalTo(array(123))) - ->willReturn(array(123 => array('tagkeep', 'tagremove', self::TAG_FAVORITE))); + ->with($this->equalTo([123])) + ->willReturn([123 => ['tagkeep', 'tagremove', self::TAG_FAVORITE]]); // then tag as tag1 and tag2 $this->tagger->expects($this->at(1)) @@ -300,9 +300,9 @@ class TagsPluginTest extends \Test\TestCase { ->with(123, 'tagremove'); // properties to set - $propPatch = new \Sabre\DAV\PropPatch(array( - self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array('tag1', 'tag2', 'tagkeep')) - )); + $propPatch = new \Sabre\DAV\PropPatch([ + self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2', 'tagkeep']) + ]); $this->plugin->handleUpdateProperties( '/dummypath', @@ -334,8 +334,8 @@ class TagsPluginTest extends \Test\TestCase { $this->tagger->expects($this->at(0)) ->method('getTagsForObjects') - ->with($this->equalTo(array(123))) - ->willReturn(array()); + ->with($this->equalTo([123])) + ->willReturn([]); // then tag as tag1 and tag2 $this->tagger->expects($this->at(1)) @@ -346,9 +346,9 @@ class TagsPluginTest extends \Test\TestCase { ->with(123, 'tag2'); // properties to set - $propPatch = new \Sabre\DAV\PropPatch(array( - self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array('tag1', 'tag2', 'tagkeep')) - )); + $propPatch = new \Sabre\DAV\PropPatch([ + self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2', 'tagkeep']) + ]); $this->plugin->handleUpdateProperties( '/dummypath', @@ -386,9 +386,9 @@ class TagsPluginTest extends \Test\TestCase { ->with(123, self::TAG_FAVORITE); // properties to set - $propPatch = new \Sabre\DAV\PropPatch(array( + $propPatch = new \Sabre\DAV\PropPatch([ self::FAVORITE_PROPERTYNAME => true - )); + ]); $this->plugin->handleUpdateProperties( '/dummypath', @@ -411,9 +411,9 @@ class TagsPluginTest extends \Test\TestCase { ->with(123, self::TAG_FAVORITE); // properties to set - $propPatch = new \Sabre\DAV\PropPatch(array( + $propPatch = new \Sabre\DAV\PropPatch([ self::FAVORITE_PROPERTYNAME => false - )); + ]); $this->plugin->handleUpdateProperties( '/dummypath', diff --git a/apps/dav/tests/unit/DAV/GroupPrincipalTest.php b/apps/dav/tests/unit/DAV/GroupPrincipalTest.php index 08239dfd46a..6a78c2a0862 100644 --- a/apps/dav/tests/unit/DAV/GroupPrincipalTest.php +++ b/apps/dav/tests/unit/DAV/GroupPrincipalTest.php @@ -184,7 +184,7 @@ class GroupPrincipalTest extends \Test\TestCase { } public function testUpdatePrincipal() { - $this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch(array()))); + $this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch([]))); } public function testSearchPrincipalsWithEmptySearchProperties() { diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php index f634c717093..ecd65e7587c 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php @@ -308,12 +308,12 @@ class SystemTagPluginTest extends \Test\TestCase { ->with($systemTag, ['group1', 'group2']); // properties to set - $propPatch = new \Sabre\DAV\PropPatch(array( + $propPatch = new \Sabre\DAV\PropPatch([ self::DISPLAYNAME_PROPERTYNAME => 'Test changed', self::USERVISIBLE_PROPERTYNAME => 'false', self::USERASSIGNABLE_PROPERTYNAME => 'true', self::GROUPS_PROPERTYNAME => 'group1|group2', - )); + ]); $this->plugin->handleUpdateProperties( '/systemtag/1', @@ -364,9 +364,9 @@ class SystemTagPluginTest extends \Test\TestCase { ->method('setTagGroups'); // properties to set - $propPatch = new \Sabre\DAV\PropPatch(array( + $propPatch = new \Sabre\DAV\PropPatch([ self::GROUPS_PROPERTYNAME => 'group1|group2', - )); + ]); $this->plugin->handleUpdateProperties( '/systemtag/1', diff --git a/apps/encryption/lib/AppInfo/Application.php b/apps/encryption/lib/AppInfo/Application.php index 6d7c00687e3..745dfe59aa7 100644 --- a/apps/encryption/lib/AppInfo/Application.php +++ b/apps/encryption/lib/AppInfo/Application.php @@ -58,7 +58,7 @@ class Application extends \OCP\AppFramework\App { /** * @param array $urlParams */ - public function __construct($urlParams = array()) { + public function __construct($urlParams = []) { parent::__construct('encryption', $urlParams); $this->encryptionManager = \OC::$server->getEncryptionManager(); $this->config = \OC::$server->getConfig(); diff --git a/apps/encryption/lib/Crypto/EncryptAll.php b/apps/encryption/lib/Crypto/EncryptAll.php index 4865f06277e..1820140337c 100644 --- a/apps/encryption/lib/Crypto/EncryptAll.php +++ b/apps/encryption/lib/Crypto/EncryptAll.php @@ -120,7 +120,7 @@ class EncryptAll { $this->questionHelper = $questionHelper; $this->secureRandom = $secureRandom; // store one time passwords for the users - $this->userPasswords = array(); + $this->userPasswords = []; } /** @@ -265,7 +265,7 @@ class EncryptAll { protected function encryptUsersFiles($uid, ProgressBar $progress, $userCount) { $this->setupUserFS($uid); - $directories = array(); + $directories = []; $directories[] = '/' . $uid . '/files'; while($root = array_pop($directories)) { @@ -322,11 +322,11 @@ class EncryptAll { */ protected function outputPasswords() { $table = new Table($this->output); - $table->setHeaders(array('Username', 'Private key password')); + $table->setHeaders(['Username', 'Private key password']); //create rows - $newPasswords = array(); - $unchangedPasswords = array(); + $newPasswords = []; + $unchangedPasswords = []; foreach ($this->userPasswords as $uid => $password) { if (empty($password)) { $unchangedPasswords[] = $uid; @@ -451,7 +451,7 @@ class EncryptAll { $this->output->writeln("\n\nPassword successfully send to all users"); } else { $table = new Table($this->output); - $table->setHeaders(array('Username', 'Private key password')); + $table->setHeaders(['Username', 'Private key password']); $this->output->writeln("\n\nCould not send password to following users:\n"); $rows = []; foreach ($noMail as $uid) { diff --git a/apps/encryption/lib/Crypto/Encryption.php b/apps/encryption/lib/Crypto/Encryption.php index 8b5ec5e1e05..edeb04ce857 100644 --- a/apps/encryption/lib/Crypto/Encryption.php +++ b/apps/encryption/lib/Crypto/Encryption.php @@ -236,7 +236,7 @@ class Encryption implements IEncryptionModule { $this->cipher = $this->crypt->getLegacyCipher(); } - return array('cipher' => $this->cipher, 'signed' => 'true'); + return ['cipher' => $this->cipher, 'signed' => 'true']; } /** @@ -266,7 +266,7 @@ class Encryption implements IEncryptionModule { $result = $this->crypt->symmetricEncryptFileContent($this->writeCache, $this->fileKey, $this->version + 1, $position); $this->writeCache = ''; } - $publicKeys = array(); + $publicKeys = []; if ($this->useMasterPassword === true) { $publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey(); } else { @@ -402,7 +402,7 @@ class Encryption implements IEncryptionModule { if (!empty($fileKey)) { - $publicKeys = array(); + $publicKeys = []; if ($this->useMasterPassword === true) { $publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey(); } else { @@ -425,7 +425,7 @@ class Encryption implements IEncryptionModule { } else { $this->logger->debug('no file key found, we assume that the file "{file}" is not encrypted', - array('file' => $path, 'app' => 'encryption')); + ['file' => $path, 'app' => 'encryption']); return false; } diff --git a/apps/encryption/lib/Recovery.php b/apps/encryption/lib/Recovery.php index d586d330237..335e6c13d73 100644 --- a/apps/encryption/lib/Recovery.php +++ b/apps/encryption/lib/Recovery.php @@ -213,7 +213,7 @@ class Recovery { $fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID()); if (!empty($fileKey)) { $accessList = $this->file->getAccessList($filePath); - $publicKeys = array(); + $publicKeys = []; foreach ($accessList['users'] as $uid) { $publicKeys[$uid] = $this->keyManager->getPublicKey($uid); } @@ -299,7 +299,7 @@ class Recovery { if (!empty($fileKey)) { $accessList = $this->file->getAccessList($path); - $publicKeys = array(); + $publicKeys = []; foreach ($accessList['users'] as $user) { $publicKeys[$user] = $this->keyManager->getPublicKey($user); } diff --git a/apps/encryption/templates/altmail.php b/apps/encryption/templates/altmail.php index a5b1512aada..dde85e0af14 100644 --- a/apps/encryption/templates/altmail.php +++ b/apps/encryption/templates/altmail.php @@ -2,9 +2,9 @@ /** @var OC_Theme $theme */ /** @var array $_ */ -print_unescaped($l->t("Hey there,\n\nthe admin enabled server-side-encryption. Your files were encrypted using the password '%s'.\n\nPlease login to the web interface, go to the section 'basic encryption module' of your personal settings and update your encryption password by entering this password into the 'old log-in password' field and your current login-password.\n\n", array($_['password']))); +print_unescaped($l->t("Hey there,\n\nthe admin enabled server-side-encryption. Your files were encrypted using the password '%s'.\n\nPlease login to the web interface, go to the section 'basic encryption module' of your personal settings and update your encryption password by entering this password into the 'old log-in password' field and your current login-password.\n\n", [$_['password']])); if ( isset($_['expiration']) ) { - print_unescaped($l->t("The share will expire on %s.", array($_['expiration']))); + print_unescaped($l->t("The share will expire on %s.", [$_['expiration']])); print_unescaped("\n\n"); } // TRANSLATORS term at the end of a mail diff --git a/apps/encryption/templates/mail.php b/apps/encryption/templates/mail.php index 6e9f9885d33..1241cfd9f62 100644 --- a/apps/encryption/templates/mail.php +++ b/apps/encryption/templates/mail.php @@ -15,7 +15,7 @@ <td width="20px"> </td> <td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;"> <?php - print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', array($_['password']))); + print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', [$_['password']])); // TRANSLATORS term at the end of a mail p($l->t('Cheers!')); ?> diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php index 7428b3fe1af..31b61ee0664 100644 --- a/apps/encryption/tests/Crypto/CryptTest.php +++ b/apps/encryption/tests/Crypto/CryptTest.php @@ -80,7 +80,7 @@ class CryptTest extends TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('openssl'), $this->equalTo([])) - ->willReturn(array()); + ->willReturn([]); $result = self::invokePrivate($this->crypt, 'getOpenSSLConfig'); $this->assertSame(1, count($result)); @@ -96,7 +96,7 @@ class CryptTest extends TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with($this->equalTo('openssl'), $this->equalTo([])) - ->willReturn(array('foo' => 'bar', 'private_key_bits' => 1028)); + ->willReturn(['foo' => 'bar', 'private_key_bits' => 1028]); $result = self::invokePrivate($this->crypt, 'getOpenSSLConfig'); $this->assertSame(2, count($result)); @@ -185,14 +185,14 @@ class CryptTest extends TestCase { * @return array */ public function dataProviderGetCipher() { - return array( - array('AES-128-CFB', 'AES-128-CFB'), - array('AES-256-CFB', 'AES-256-CFB'), - array('AES-128-CTR', 'AES-128-CTR'), - array('AES-256-CTR', 'AES-256-CTR'), + return [ + ['AES-128-CFB', 'AES-128-CFB'], + ['AES-256-CFB', 'AES-256-CFB'], + ['AES-128-CTR', 'AES-128-CTR'], + ['AES-256-CTR', 'AES-256-CTR'], - array('unknown', 'AES-256-CTR') - ); + ['unknown', 'AES-256-CTR'] + ]; } /** @@ -203,7 +203,7 @@ class CryptTest extends TestCase { $result = self::invokePrivate( $this->crypt, 'concatIV', - array('content', 'my_iv')); + ['content', 'my_iv']); $this->assertSame('content00iv00my_iv', $result @@ -214,7 +214,7 @@ class CryptTest extends TestCase { * @dataProvider dataTestSplitMetaData */ public function testSplitMetaData($data, $expected) { - $result = self::invokePrivate($this->crypt, 'splitMetaData', array($data, 'AES-256-CFB')); + $result = self::invokePrivate($this->crypt, 'splitMetaData', [$data, 'AES-256-CFB']); $this->assertTrue(is_array($result)); $this->assertSame(3, count($result)); $this->assertArrayHasKey('encrypted', $result); @@ -239,7 +239,7 @@ class CryptTest extends TestCase { */ public function testHasSignature($data, $expected) { $this->assertSame($expected, - $this->invokePrivate($this->crypt, 'hasSignature', array($data, 'AES-256-CFB')) + $this->invokePrivate($this->crypt, 'hasSignature', [$data, 'AES-256-CFB']) ); } @@ -257,7 +257,7 @@ class CryptTest extends TestCase { $this->expectException(\OCP\Encryption\Exceptions\GenericEncryptionException::class); $data = 'encryptedContent00iv001234567890123456xx'; - $this->invokePrivate($this->crypt, 'hasSignature', array($data, $cipher)); + $this->invokePrivate($this->crypt, 'hasSignature', [$data, $cipher]); } public function dataTestHasSignatureFail() { @@ -273,7 +273,7 @@ class CryptTest extends TestCase { * test addPadding() */ public function testAddPadding() { - $result = self::invokePrivate($this->crypt, 'addPadding', array('data')); + $result = self::invokePrivate($this->crypt, 'addPadding', ['data']); $this->assertSame('dataxxx', $result); } @@ -285,7 +285,7 @@ class CryptTest extends TestCase { * @param $expected */ public function testRemovePadding($data, $expected) { - $result = self::invokePrivate($this->crypt, 'removePadding', array($data)); + $result = self::invokePrivate($this->crypt, 'removePadding', [$data]); $this->assertSame($expected, $result); } @@ -295,10 +295,10 @@ class CryptTest extends TestCase { * @return array */ public function dataProviderRemovePadding() { - return array( - array('dataxx', 'data'), - array('data', false) - ); + return [ + ['dataxx', 'data'], + ['data', false] + ]; } /** @@ -307,7 +307,7 @@ class CryptTest extends TestCase { public function testParseHeader() { $header= 'HBEGIN:foo:bar:cipher:AES-256-CFB:HEND'; - $result = self::invokePrivate($this->crypt, 'parseHeader', array($header)); + $result = self::invokePrivate($this->crypt, 'parseHeader', [$header]); $this->assertTrue(is_array($result)); $this->assertSame(2, count($result)); @@ -331,15 +331,15 @@ class CryptTest extends TestCase { $this->assertTrue(is_string($iv)); $this->assertSame(16, strlen($iv)); - $result = self::invokePrivate($this->crypt, 'encrypt', array($decrypted, $iv, $password)); + $result = self::invokePrivate($this->crypt, 'encrypt', [$decrypted, $iv, $password]); $this->assertTrue(is_string($result)); - return array( + return [ 'password' => $password, 'iv' => $iv, 'encrypted' => $result, - 'decrypted' => $decrypted); + 'decrypted' => $decrypted]; } @@ -353,7 +353,7 @@ class CryptTest extends TestCase { $result = self::invokePrivate( $this->crypt, 'decrypt', - array($data['encrypted'], $data['iv'], $data['password'])); + [$data['encrypted'], $data['iv'], $data['password']]); $this->assertSame($data['decrypted'], $result); diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 9a541880e79..cebb27580e2 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -124,7 +124,7 @@ class EncryptionTest extends TestCase { * test if public key from one of the recipients is missing */ public function testEndUser1() { - $this->instance->begin('/foo/bar', 'user1', 'r', array(), array('users' => array('user1', 'user2', 'user3'))); + $this->instance->begin('/foo/bar', 'user1', 'r', [], ['users' => ['user1', 'user2', 'user3']]); $this->endTest(); } @@ -135,7 +135,7 @@ class EncryptionTest extends TestCase { public function testEndUser2() { $this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class); - $this->instance->begin('/foo/bar', 'user2', 'r', array(), array('users' => array('user1', 'user2', 'user3'))); + $this->instance->begin('/foo/bar', 'user2', 'r', [], ['users' => ['user1', 'user2', 'user3']]); $this->endTest(); } @@ -182,17 +182,17 @@ class EncryptionTest extends TestCase { */ public function testGetPathToRealFile($path, $expected) { $this->assertSame($expected, - self::invokePrivate($this->instance, 'getPathToRealFile', array($path)) + self::invokePrivate($this->instance, 'getPathToRealFile', [$path]) ); } public function dataProviderForTestGetPathToRealFile() { - return array( - array('/user/files/foo/bar.txt', '/user/files/foo/bar.txt'), - array('/user/files/foo.txt', '/user/files/foo.txt'), - array('/user/files_versions/foo.txt.v543534', '/user/files/foo.txt'), - array('/user/files_versions/foo/bar.txt.v5454', '/user/files/foo/bar.txt'), - ); + return [ + ['/user/files/foo/bar.txt', '/user/files/foo/bar.txt'], + ['/user/files/foo.txt', '/user/files/foo.txt'], + ['/user/files_versions/foo.txt.v543534', '/user/files/foo.txt'], + ['/user/files_versions/foo/bar.txt.v5454', '/user/files/foo/bar.txt'], + ]; } /** @@ -241,12 +241,12 @@ class EncryptionTest extends TestCase { } public function dataTestBegin() { - return array( - array('w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'defaultCipher'), - array('r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'myCipher'), - array('w', [], 'legacyCipher', 'defaultCipher', '', 'defaultCipher'), - array('r', [], 'legacyCipher', 'defaultCipher', 'file_key', 'legacyCipher'), - ); + return [ + ['w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'defaultCipher'], + ['r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'myCipher'], + ['w', [], 'legacyCipher', 'defaultCipher', '', 'defaultCipher'], + ['r', [], 'legacyCipher', 'defaultCipher', 'file_key', 'legacyCipher'], + ]; } @@ -335,10 +335,10 @@ class EncryptionTest extends TestCase { } public function dataTestUpdate() { - return array( - array('', false), - array('fileKey', true) - ); + return [ + ['', false], + ['fileKey', true] + ]; } public function testUpdateNoUsers() { @@ -417,19 +417,19 @@ class EncryptionTest extends TestCase { } public function dataTestShouldEncrypt() { - return array( - array('/user1/files/foo.txt', true, true, true), - array('/user1/files_versions/foo.txt', true, true, true), - array('/user1/files_trashbin/foo.txt', true, true, true), - array('/user1/some_folder/foo.txt', true, true, false), - array('/user1/foo.txt', true, true, false), - array('/user1/files', true, true, false), - array('/user1/files_trashbin', true, true, false), - array('/user1/files_versions', true, true, false), + return [ + ['/user1/files/foo.txt', true, true, true], + ['/user1/files_versions/foo.txt', true, true, true], + ['/user1/files_trashbin/foo.txt', true, true, true], + ['/user1/some_folder/foo.txt', true, true, false], + ['/user1/foo.txt', true, true, false], + ['/user1/files', true, true, false], + ['/user1/files_trashbin', true, true, false], + ['/user1/files_versions', true, true, false], // test if shouldEncryptHomeStorage is set to false - array('/user1/files/foo.txt', false, true, false), - array('/user1/files_versions/foo.txt', false, false, true), - ); + ['/user1/files/foo.txt', false, true, false], + ['/user1/files_versions/foo.txt', false, false, true], + ]; } diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php index a9886a0b9ec..c7b9d62690e 100644 --- a/apps/encryption/tests/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -322,7 +322,7 @@ class KeyManagerTest extends TestCase { $this->assertTrue( $this->instance->setRecoveryKey('pass', - array('publicKey' => 'publicKey', 'privateKey' => 'privateKey')) + ['publicKey' => 'publicKey', 'privateKey' => 'privateKey']) ); } @@ -505,12 +505,12 @@ class KeyManagerTest extends TestCase { * @return array */ public function dataTestAddSystemKeys() { - return array( - array(['public' => true],[], 'user1', ['publicShareKey', 'recoveryKey']), - array(['public' => false], [], 'user1', ['recoveryKey']), - array(['public' => true],[], 'user2', ['publicShareKey']), - array(['public' => false], [], 'user2', []), - ); + return [ + [['public' => true],[], 'user1', ['publicShareKey', 'recoveryKey']], + [['public' => false], [], 'user1', ['recoveryKey']], + [['public' => true],[], 'user2', ['publicShareKey']], + [['public' => false], [], 'user2', []], + ]; } public function testGetMasterKeyId() { diff --git a/apps/federatedfilesharing/lib/AddressHandler.php b/apps/federatedfilesharing/lib/AddressHandler.php index 7a272781fe6..113978bab82 100644 --- a/apps/federatedfilesharing/lib/AddressHandler.php +++ b/apps/federatedfilesharing/lib/AddressHandler.php @@ -106,12 +106,12 @@ class AddressHandler { \OCP\Util::emitHook( '\OCA\Files_Sharing\API\Server2Server', 'preLoginNameUsedAsUserName', - array('uid' => &$user1) + ['uid' => &$user1] ); \OCP\Util::emitHook( '\OCA\Files_Sharing\API\Server2Server', 'preLoginNameUsedAsUserName', - array('uid' => &$user2) + ['uid' => &$user2] ); if ($user1 === $user2) { diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 575e3cdff57..5d44643899a 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -187,7 +187,7 @@ class FederatedShareProvider implements IShareProvider { $alreadySharedGroup = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_REMOTE_GROUP, $share->getNode(), 1, 0); if (!empty($alreadyShared) || !empty($alreadySharedGroup)) { $message = 'Sharing %1$s failed, because this item is already shared with %2$s'; - $message_t = $this->l->t('Sharing %1$s failed, because this item is already shared with %2$s', array($share->getNode()->getName(), $shareWith)); + $message_t = $this->l->t('Sharing %1$s failed, because this item is already shared with %2$s', [$share->getNode()->getName(), $shareWith]); $this->logger->debug(sprintf($message, $share->getNode()->getName(), $shareWith), ['app' => 'Federated File Sharing']); throw new \Exception($message_t); } diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php index 5df2173263c..70cf11c7672 100644 --- a/apps/federatedfilesharing/lib/Notifications.php +++ b/apps/federatedfilesharing/lib/Notifications.php @@ -99,7 +99,7 @@ class Notifications { if ($user && $remote) { $local = $this->addressHandler->generateRemoteURL(); - $fields = array( + $fields = [ 'shareWith' => $user, 'token' => $token, 'name' => $name, @@ -110,7 +110,7 @@ class Notifications { 'sharedByFederatedId' => $sharedByFederatedId, 'remote' => $local, 'shareType' => $shareType - ); + ]; $result = $this->tryHttpPostToShareEndpoint($remote, '', $fields); $status = json_decode($result['result'], true); @@ -144,12 +144,12 @@ class Notifications { */ public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) { - $fields = array( + $fields = [ 'shareWith' => $shareWith, 'token' => $token, 'permission' => $permission, 'remoteId' => $shareId, - ); + ]; $ocmFields = $fields; $ocmFields['remoteId'] = $id; diff --git a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php index e2e2f26ad3a..c87d4e273fc 100644 --- a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php @@ -215,7 +215,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { Util::emitHook( '\OCA\Files_Sharing\API\Server2Server', 'preLoginNameUsedAsUserName', - array('uid' => &$shareWith) + ['uid' => &$shareWith] ); $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); @@ -774,7 +774,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { } catch (NotFoundException $e) { $file = null; } - $args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file); + $args = Filesystem::is_dir($file) ? ['dir' => $file] : ['dir' => dirname($file), 'scrollto' => $file]; $link = Util::linkToAbsolute('files', 'index.php', $args); return [$file, $link]; diff --git a/apps/federatedfilesharing/tests/AddressHandlerTest.php b/apps/federatedfilesharing/tests/AddressHandlerTest.php index d6a7bdaf292..f69bc4209d3 100644 --- a/apps/federatedfilesharing/tests/AddressHandlerTest.php +++ b/apps/federatedfilesharing/tests/AddressHandlerTest.php @@ -104,21 +104,21 @@ class AddressHandlerTest extends \Test\TestCase { } public function dataTestSplitUserRemoteError() { - return array( + return [ // Invalid path - array('user@'), + ['user@'], // Invalid user - array('@server'), - array('us/er@server'), - array('us:er@server'), + ['@server'], + ['us/er@server'], + ['us:er@server'], // Invalid splitting - array('user'), - array(''), - array('us/erserver'), - array('us:erserver'), - ); + ['user'], + [''], + ['us/erserver'], + ['us:erserver'], + ]; } /** diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php index 5b29175a83c..d5ea0f634f2 100644 --- a/apps/files/ajax/download.php +++ b/apps/files/ajax/download.php @@ -38,7 +38,7 @@ $dir = isset($_GET['dir']) ? (string)$_GET['dir'] : ''; $files_list = json_decode($files); // in case we get only a single file if (!is_array($files_list)) { - $files_list = array($files); + $files_list = [$files]; } /** @@ -52,7 +52,7 @@ if(isset($_GET['downloadStartSecret']) setcookie('ocDownloadStarted', $_GET['downloadStartSecret'], time() + 20, '/'); } -$server_params = array( 'head' => \OC::$server->getRequest()->getMethod() === 'HEAD' ); +$server_params = [ 'head' => \OC::$server->getRequest()->getMethod() === 'HEAD' ]; /** * Http range requests support diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 0b66ed10897..8cbe5841aaf 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -43,7 +43,7 @@ try { exit(); } - $data = array(); + $data = []; $baseUrl = \OC::$server->getURLGenerator()->linkTo('files', 'index.php') . '?dir='; $permissions = $dirInfo->getPermissions(); @@ -80,7 +80,7 @@ try { $data['files'] = \OCA\Files\Helper::formatFileInfos($files); $data['permissions'] = $permissions; - \OC_JSON::success(array('data' => $data)); + \OC_JSON::success(['data' => $data]); } catch (\OCP\Files\StorageNotAvailableException $e) { \OC::$server->getLogger()->logException($e, ['app' => 'files']); \OC_JSON::error([ @@ -91,18 +91,18 @@ try { ]); } catch (\OCP\Files\StorageInvalidException $e) { \OC::$server->getLogger()->logException($e, ['app' => 'files']); - \OC_JSON::error(array( - 'data' => array( + \OC_JSON::error([ + 'data' => [ 'exception' => StorageInvalidException::class, 'message' => $l->t('Storage invalid') - ) - )); + ] + ]); } catch (\Exception $e) { \OC::$server->getLogger()->logException($e, ['app' => 'files']); - \OC_JSON::error(array( - 'data' => array( + \OC_JSON::error([ + 'data' => [ 'exception' => \Exception::class, 'message' => $l->t('Unknown error') - ) - )); + ] + ]); } diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php index 35e46c0c151..bb98613377c 100644 --- a/apps/files/appinfo/app.php +++ b/apps/files/appinfo/app.php @@ -36,7 +36,7 @@ $app = \OC::$server->query(Application::class); // t('Files') $l = \OC::$server->getL10N('files'); -\OC::$server->getSearch()->registerProvider(File::class, array('apps' => array('files'))); +\OC::$server->getSearch()->registerProvider(File::class, ['apps' => ['files']]); $templateManager = \OC_Helper::getFileTemplateManager(); $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp'); diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php index 8bda6329d29..b043cfeb6ac 100644 --- a/apps/files/lib/AppInfo/Application.php +++ b/apps/files/lib/AppInfo/Application.php @@ -50,7 +50,7 @@ class Application extends App { public const APP_ID = 'files'; - public function __construct(array $urlParams=array()) { + public function __construct(array $urlParams=[]) { parent::__construct(self::APP_ID, $urlParams); $container = $this->getContainer(); $server = $container->getServer(); diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index 39eebbb2c43..38d4b1cc979 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -174,7 +174,7 @@ class Scan extends Base { if ($inputPath) { $inputPath = '/' . trim($inputPath, '/'); list (, $user,) = explode('/', $inputPath, 3); - $users = array($user); + $users = [$user]; } else if ($input->getOption('all')) { $users = $this->userManager->search(''); } else { diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 70b878f43ad..7c5d2a08b88 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -200,7 +200,7 @@ class ViewController extends Controller { $collapseClasses = 'collapsible'; } - $favoritesSublistArray = Array(); + $favoritesSublistArray = []; $navBarPositionPosition = 6; $currentCount = 0; diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index f88689af266..c46d3028553 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -51,7 +51,7 @@ class Helper { $l = \OC::$server->getL10N('files'); $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']); $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize); - $maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize)); + $maxHumanFileSize = $l->t('Upload (max. %s)', [$maxHumanFileSize]); return [ 'uploadMaxFilesize' => $maxUploadFileSize, @@ -140,7 +140,7 @@ class Helper { * @return array formatted file info */ public static function formatFileInfo(FileInfo $i) { - $entry = array(); + $entry = []; $entry['id'] = $i['fileid']; $entry['parentId'] = $i['parent']; @@ -182,7 +182,7 @@ class Helper { * @return array */ public static function formatFileInfos($fileInfos) { - $files = array(); + $files = []; foreach ($fileInfos as $i) { $files[] = self::formatFileInfo($i); } @@ -262,7 +262,7 @@ class Helper { } else if ($sortAttribute === 'size') { $sortFunc = 'compareSize'; } - usort($files, array(Helper::class, $sortFunc)); + usort($files, [Helper::class, $sortFunc]); if ($sortDescending) { $files = array_reverse($files); } diff --git a/apps/files/lib/Service/TagService.php b/apps/files/lib/Service/TagService.php index a477db324ac..5df00ae5c5f 100644 --- a/apps/files/lib/Service/TagService.php +++ b/apps/files/lib/Service/TagService.php @@ -83,7 +83,7 @@ class TagService { public function updateFileTags($path, $tags) { $fileId = $this->homeFolder->get($path)->getId(); - $currentTags = $this->tagger->getTagsForObjects(array($fileId)); + $currentTags = $this->tagger->getTagsForObjects([$fileId]); if (!empty($currentTags)) { $currentTags = current($currentTags); diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index b14617f0ca3..9d6227c86b3 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -47,7 +47,7 @@ script(\OCA\Files\AppInfo\Application::APP_ID, 'dist/files-app-settings'); <label for="webdavurl"><?php p($l->t('WebDAV')); ?></label> <input id="webdavurl" type="text" readonly="readonly" value="<?php p($_['webdav_url']); ?>"/> - <em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer noopener">access your Files via WebDAV</a>', array(link_to_docs('user-webdav')))); ?></em> + <em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer noopener">access your Files via WebDAV</a>', [link_to_docs('user-webdav')])); ?></em> </div> </div> diff --git a/apps/files/tests/HelperTest.php b/apps/files/tests/HelperTest.php index b756386a2bf..8dda7be5a19 100644 --- a/apps/files/tests/HelperTest.php +++ b/apps/files/tests/HelperTest.php @@ -37,13 +37,13 @@ class HelperTest extends \Test\TestCase { '/' . $name, null, '/', - array( + [ 'name' => $name, 'size' => $size, 'mtime' => $mtime, 'type' => $isDir ? 'dir' : 'file', 'mimetype' => $isDir ? 'httpd/unix-directory' : 'application/octet-stream' - ), + ], null ); } @@ -52,49 +52,49 @@ class HelperTest extends \Test\TestCase { * Returns a file list for testing */ private function getTestFileList() { - return array( + return [ self::makeFileInfo('a.txt', 4, 2.3 * pow(10, 9)), self::makeFileInfo('q.txt', 5, 150), self::makeFileInfo('subdir2', 87, 128, true), self::makeFileInfo('b.txt', 2.2 * pow(10, 9), 800), self::makeFileInfo('o.txt', 12, 100), self::makeFileInfo('subdir', 88, 125, true), - ); + ]; } function sortDataProvider() { - return array( - array( + return [ + [ 'name', false, - array('subdir', 'subdir2', 'a.txt', 'b.txt', 'o.txt', 'q.txt'), - ), - array( + ['subdir', 'subdir2', 'a.txt', 'b.txt', 'o.txt', 'q.txt'], + ], + [ 'name', true, - array('q.txt', 'o.txt', 'b.txt', 'a.txt', 'subdir2', 'subdir'), - ), - array( + ['q.txt', 'o.txt', 'b.txt', 'a.txt', 'subdir2', 'subdir'], + ], + [ 'size', false, - array('a.txt', 'q.txt', 'o.txt', 'subdir2', 'subdir', 'b.txt'), - ), - array( + ['a.txt', 'q.txt', 'o.txt', 'subdir2', 'subdir', 'b.txt'], + ], + [ 'size', true, - array('b.txt', 'subdir', 'subdir2', 'o.txt', 'q.txt', 'a.txt'), - ), - array( + ['b.txt', 'subdir', 'subdir2', 'o.txt', 'q.txt', 'a.txt'], + ], + [ 'mtime', false, - array('o.txt', 'subdir', 'subdir2', 'q.txt', 'b.txt', 'a.txt'), - ), - array( + ['o.txt', 'subdir', 'subdir2', 'q.txt', 'b.txt', 'a.txt'], + ], + [ 'mtime', true, - array('a.txt', 'b.txt', 'q.txt', 'subdir2', 'subdir', 'o.txt'), - ), - ); + ['a.txt', 'b.txt', 'q.txt', 'subdir2', 'subdir', 'o.txt'], + ], + ]; } /** @@ -103,7 +103,7 @@ class HelperTest extends \Test\TestCase { public function testSortByName($sort, $sortDescending, $expectedOrder) { $files = self::getTestFileList(); $files = \OCA\Files\Helper::sortFiles($files, $sort, $sortDescending); - $fileNames = array(); + $fileNames = []; foreach ($files as $fileInfo) { $fileNames[] = $fileInfo->getName(); } diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php index bc7c803953b..a2792a38647 100644 --- a/apps/files/tests/Service/TagServiceTest.php +++ b/apps/files/tests/Service/TagServiceTest.php @@ -132,25 +132,25 @@ class TagServiceTest extends \Test\TestCase { $fileId = $testFile->getId(); // set tags - $this->tagService->updateFileTags('subdir/test.txt', array($tag1, $tag2)); + $this->tagService->updateFileTags('subdir/test.txt', [$tag1, $tag2]); - $this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag1)); - $this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag2)); + $this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag1)); + $this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag2)); // remove tag - $this->tagService->updateFileTags('subdir/test.txt', array($tag2)); - $this->assertEquals(array(), $this->tagger->getIdsForTag($tag1)); - $this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag2)); + $this->tagService->updateFileTags('subdir/test.txt', [$tag2]); + $this->assertEquals([], $this->tagger->getIdsForTag($tag1)); + $this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag2)); // clear tags - $this->tagService->updateFileTags('subdir/test.txt', array()); - $this->assertEquals(array(), $this->tagger->getIdsForTag($tag1)); - $this->assertEquals(array(), $this->tagger->getIdsForTag($tag2)); + $this->tagService->updateFileTags('subdir/test.txt', []); + $this->assertEquals([], $this->tagger->getIdsForTag($tag1)); + $this->assertEquals([], $this->tagger->getIdsForTag($tag2)); // non-existing file $caught = false; try { - $this->tagService->updateFileTags('subdir/unexist.txt', array($tag1)); + $this->tagService->updateFileTags('subdir/unexist.txt', [$tag1]); } catch (\OCP\Files\NotFoundException $e) { $caught = true; } diff --git a/apps/files_external/ajax/applicable.php b/apps/files_external/ajax/applicable.php index 0a6b9f5af46..bda2c919596 100644 --- a/apps/files_external/ajax/applicable.php +++ b/apps/files_external/ajax/applicable.php @@ -51,6 +51,6 @@ foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $of $users[$user->getUID()] = $user->getDisplayName(); } -$results = array('groups' => $groups, 'users' => $users); +$results = ['groups' => $groups, 'users' => $users]; \OC_JSON::success($results); diff --git a/apps/files_external/lib/Controller/AjaxController.php b/apps/files_external/lib/Controller/AjaxController.php index 347fa02e1b0..b9e414a410a 100644 --- a/apps/files_external/lib/Controller/AjaxController.php +++ b/apps/files_external/lib/Controller/AjaxController.php @@ -88,12 +88,12 @@ class AjaxController extends Controller { public function getSshKeys($keyLength = 1024) { $key = $this->generateSshKeys($keyLength); return new JSONResponse( - array('data' => array( + ['data' => [ 'private_key' => $key['privatekey'], 'public_key' => $key['publickey'] - ), + ], 'status' => 'success' - )); + ]); } /** diff --git a/apps/files_external/lib/Controller/ApiController.php b/apps/files_external/lib/Controller/ApiController.php index 1882ea31504..aa0c8ddb6a1 100644 --- a/apps/files_external/lib/Controller/ApiController.php +++ b/apps/files_external/lib/Controller/ApiController.php @@ -74,7 +74,7 @@ class ApiController extends OCSController { $permissions |= \OCP\Constants::PERMISSION_DELETE; } - $entry = array( + $entry = [ 'name' => basename($mountPoint), 'path' => $path, 'type' => 'dir', @@ -83,7 +83,7 @@ class ApiController extends OCSController { 'permissions' => $permissions, 'id' => $mountConfig['id'], 'class' => $mountConfig['class'] - ); + ]; return $entry; } diff --git a/apps/files_external/lib/Controller/GlobalStoragesController.php b/apps/files_external/lib/Controller/GlobalStoragesController.php index c8fc4b00ef8..a3c9fbb284c 100644 --- a/apps/files_external/lib/Controller/GlobalStoragesController.php +++ b/apps/files_external/lib/Controller/GlobalStoragesController.php @@ -171,7 +171,7 @@ class GlobalStoragesController extends StoragesController { } catch (NotFoundException $e) { return new DataResponse( [ - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) ], Http::STATUS_NOT_FOUND ); diff --git a/apps/files_external/lib/Controller/UserGlobalStoragesController.php b/apps/files_external/lib/Controller/UserGlobalStoragesController.php index 8e0dac5a898..a3a258c599a 100644 --- a/apps/files_external/lib/Controller/UserGlobalStoragesController.php +++ b/apps/files_external/lib/Controller/UserGlobalStoragesController.php @@ -124,7 +124,7 @@ class UserGlobalStoragesController extends StoragesController { } catch (NotFoundException $e) { return new DataResponse( [ - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) ], Http::STATUS_NOT_FOUND ); @@ -164,7 +164,7 @@ class UserGlobalStoragesController extends StoragesController { } else { return new DataResponse( [ - 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', array($id)) + 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id]) ], Http::STATUS_FORBIDDEN ); @@ -172,7 +172,7 @@ class UserGlobalStoragesController extends StoragesController { } catch (NotFoundException $e) { return new DataResponse( [ - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) ], Http::STATUS_NOT_FOUND ); diff --git a/apps/files_external/lib/Controller/UserStoragesController.php b/apps/files_external/lib/Controller/UserStoragesController.php index 46285c4758a..df42198aeb3 100644 --- a/apps/files_external/lib/Controller/UserStoragesController.php +++ b/apps/files_external/lib/Controller/UserStoragesController.php @@ -199,7 +199,7 @@ class UserStoragesController extends StoragesController { } catch (NotFoundException $e) { return new DataResponse( [ - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) ], Http::STATUS_NOT_FOUND ); diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 60e39a4d300..0d7cbacd8b5 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -128,10 +128,10 @@ class AmazonS3 extends \OC\Files\Storage\Common { private function headObject($key) { if (!isset($this->objectCache[$key])) { try { - $this->objectCache[$key] = $this->getConnection()->headObject(array( + $this->objectCache[$key] = $this->getConnection()->headObject([ 'Bucket' => $this->bucket, 'Key' => $key - )); + ]); } catch (S3Exception $e) { if ($e->getStatusCode() >= 500) { throw $e; @@ -191,7 +191,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { $stmt = \OC::$server->getDatabaseConnection()->prepare( 'SELECT `numeric_id`, `id` FROM `*PREFIX*storages` WHERE `id` IN (?, ?)' ); - $stmt->execute(array($oldId, $this->id)); + $stmt->execute([$oldId, $this->id]); while ($row = $stmt->fetch()) { $storages[$row['id']] = $row['numeric_id']; } @@ -204,7 +204,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { $stmt = \OC::$server->getDatabaseConnection()->prepare( 'UPDATE `*PREFIX*storages` SET `id` = ? WHERE `id` = ?' ); - $stmt->execute(array($this->id, $oldId)); + $stmt->execute([$this->id, $oldId]); } // only the bucket based id may exist, do nothing } @@ -235,12 +235,12 @@ class AmazonS3 extends \OC\Files\Storage\Common { } try { - $this->getConnection()->putObject(array( + $this->getConnection()->putObject([ 'Bucket' => $this->bucket, 'Key' => $path . '/', 'Body' => '', 'ContentType' => 'httpd/unix-directory' - )); + ]); $this->testTimeout(); } catch (S3Exception $e) { \OC::$server->getLogger()->logException($e, ['app' => 'files_external']); @@ -284,9 +284,9 @@ class AmazonS3 extends \OC\Files\Storage\Common { } private function batchDelete($path = null) { - $params = array( + $params = [ 'Bucket' => $this->bucket - ); + ]; if ($path !== null) { $params['Prefix'] = $path . '/'; } @@ -326,7 +326,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { } try { - $files = array(); + $files = []; $results = $this->getConnection()->getPaginator('ListObjects', [ 'Bucket' => $this->bucket, 'Delimiter' => '/', @@ -550,7 +550,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { public function touch($path, $mtime = null) { $path = $this->normalizePath($path); - $metadata = array(); + $metadata = []; if (is_null($mtime)) { $mtime = time(); } @@ -599,11 +599,11 @@ class AmazonS3 extends \OC\Files\Storage\Common { if ($this->is_file($path1)) { try { - $this->getConnection()->copyObject(array( + $this->getConnection()->copyObject([ 'Bucket' => $this->bucket, 'Key' => $this->cleanKey($path2), 'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1) - )); + ]); $this->testTimeout(); } catch (S3Exception $e) { \OC::$server->getLogger()->logException($e, ['app' => 'files_external']); @@ -613,11 +613,11 @@ class AmazonS3 extends \OC\Files\Storage\Common { $this->remove($path2); try { - $this->getConnection()->copyObject(array( + $this->getConnection()->copyObject([ 'Bucket' => $this->bucket, 'Key' => $path2 . '/', 'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1 . '/') - )); + ]); $this->testTimeout(); } catch (S3Exception $e) { \OC::$server->getLogger()->logException($e, ['app' => 'files_external']); diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php index 8f014ce921c..adf7f29a3d6 100644 --- a/apps/files_external/lib/Lib/Storage/FTP.php +++ b/apps/files_external/lib/Lib/Storage/FTP.php @@ -109,7 +109,7 @@ class FTP extends StreamWrapper{ case 'a': case 'ab': //these are supported by the wrapper - $context = stream_context_create(array('ftp' => array('overwrite' => true))); + $context = stream_context_create(['ftp' => ['overwrite' => true]]); $handle = fopen($this->constructUrl($path), $mode, false, $context); return RetryWrapper::wrap($handle); case 'r+': @@ -150,7 +150,7 @@ class FTP extends StreamWrapper{ if (function_exists('ftp_login')) { return true; } else { - return array('ftp'); + return ['ftp']; } } diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php index 5d83bf253e4..eaead3eea45 100644 --- a/apps/files_external/lib/Lib/Storage/SFTP.php +++ b/apps/files_external/lib/Lib/Storage/SFTP.php @@ -251,8 +251,8 @@ class SFTP extends \OC\Files\Storage\Common { try { $keyPath = $this->hostKeysPath(); if (file_exists($keyPath)) { - $hosts = array(); - $keys = array(); + $hosts = []; + $keys = []; $lines = file($keyPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if ($lines) { foreach ($lines as $line) { @@ -267,7 +267,7 @@ class SFTP extends \OC\Files\Storage\Common { } } catch (\Exception $e) { } - return array(); + return []; } /** @@ -307,7 +307,7 @@ class SFTP extends \OC\Files\Storage\Common { } $id = md5('sftp:' . $path); - $dirStream = array(); + $dirStream = []; foreach($list as $file) { if ($file !== '.' && $file !== '..') { $dirStream[] = $file; @@ -391,7 +391,7 @@ class SFTP extends \OC\Files\Storage\Common { case 'x+': case 'c': case 'c+': - $context = stream_context_create(array('sftp' => array('session' => $this->getConnection()))); + $context = stream_context_create(['sftp' => ['session' => $this->getConnection()]]); $handle = fopen($this->constructUrl($path), $mode, false, $context); return RetryWrapper::wrap($handle); } @@ -464,7 +464,7 @@ class SFTP extends \OC\Files\Storage\Common { $mtime = $stat ? $stat['mtime'] : -1; $size = $stat ? $stat['size'] : 0; - return array('mtime' => $mtime, 'size' => $size, 'ctime' => -1); + return ['mtime' => $mtime, 'size' => $size, 'ctime' => -1]; } catch (\Exception $e) { return false; } diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 6cf7bb7db85..8f7d594cd67 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -472,7 +472,7 @@ class SMB extends Common implements INotifyStorage { } try { - $this->statCache = array(); + $this->statCache = []; $content = $this->share->dir($this->buildPath($path)); foreach ($content as $file) { if ($file->isDirectory()) { diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index 0072f91d4ed..daa222def04 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -351,7 +351,7 @@ class Swift extends \OC\Files\Storage\Common { $mtime = floor($mtime); } - $stat = array(); + $stat = []; $stat['size'] = (int)$object->contentLength; $stat['mtime'] = $mtime; $stat['atime'] = time(); @@ -602,7 +602,7 @@ class Swift extends \OC\Files\Storage\Common { } $path = $this->normalizePath($path); $dh = $this->opendir($path); - $content = array(); + $content = []; while (($file = readdir($dh)) !== false) { $content[] = $file; } diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index f799fd25f57..a65b3b3a9c2 100644 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -96,7 +96,7 @@ class OC_Mount_Config { * @deprecated 8.2.0 use UserGlobalStoragesService::getStorages() and UserStoragesService::getStorages() */ public static function getAbsoluteMountPoints($uid) { - $mountPoints = array(); + $mountPoints = []; $userGlobalStoragesService = self::$app->getContainer()->query(UserGlobalStoragesService::class); $userStoragesService = self::$app->getContainer()->query(UserStoragesService::class); @@ -296,7 +296,7 @@ class OC_Mount_Config { return $mountPoints; } } - return array(); + return []; } /** @@ -430,14 +430,14 @@ class OC_Mount_Config { */ public static function makeConfigHash($config) { $data = json_encode( - array( + [ 'c' => $config['backend'], 'a' => $config['authMechanism'], 'm' => $config['mountpoint'], 'o' => $config['options'], 'p' => isset($config['priority']) ? $config['priority'] : -1, 'mo' => isset($config['mountOptions']) ? $config['mountOptions'] : [], - ) + ] ); return hash('md5', $data); } diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php index 3ecf47419b5..56311a7be4c 100644 --- a/apps/files_external/tests/Controller/StoragesControllerTest.php +++ b/apps/files_external/tests/Controller/StoragesControllerTest.php @@ -117,7 +117,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { 'mount', '\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Auth\NullMechanism', - array(), + [], [], [], [], @@ -159,7 +159,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { 'mount', '\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Auth\NullMechanism', - array(), + [], [], [], [], @@ -172,11 +172,11 @@ abstract class StoragesControllerTest extends \Test\TestCase { } function mountPointNamesProvider() { - return array( - array(''), - array('/'), - array('//'), - ); + return [ + [''], + ['/'], + ['//'], + ]; } /** @@ -201,7 +201,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { $mountPoint, '\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Auth\NullMechanism', - array(), + [], [], [], [], @@ -215,7 +215,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { $mountPoint, '\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Auth\NullMechanism', - array(), + [], [], [], [], @@ -238,7 +238,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { 'mount', '\OC\Files\Storage\InvalidStorage', '\OCA\Files_External\Lib\Auth\NullMechanism', - array(), + [], [], [], [], @@ -252,7 +252,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { 'mount', '\OC\Files\Storage\InvalidStorage', '\OCA\Files_External\Lib\Auth\NullMechanism', - array(), + [], [], [], [], @@ -292,7 +292,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { 'mount', '\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Auth\NullMechanism', - array(), + [], [], [], [], @@ -388,7 +388,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { 'mount', '\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Auth\NullMechanism', - array(), + [], [], [], [], diff --git a/apps/files_external/tests/Controller/UserStoragesControllerTest.php b/apps/files_external/tests/Controller/UserStoragesControllerTest.php index 7d8f60380c6..5f82121cf7a 100644 --- a/apps/files_external/tests/Controller/UserStoragesControllerTest.php +++ b/apps/files_external/tests/Controller/UserStoragesControllerTest.php @@ -86,7 +86,7 @@ class UserStoragesControllerTest extends StoragesControllerTest { 'mount', '\OCA\Files_External\Lib\Storage\SMB', '\Auth\Mechanism', - array(), + [], [], [], [], @@ -100,7 +100,7 @@ class UserStoragesControllerTest extends StoragesControllerTest { 'mount', '\OCA\Files_External\Lib\Storage\SMB', '\Auth\Mechanism', - array(), + [], [], [], [], diff --git a/apps/files_external/tests/OwnCloudFunctionsTest.php b/apps/files_external/tests/OwnCloudFunctionsTest.php index d87288edb10..060f8c61a44 100644 --- a/apps/files_external/tests/OwnCloudFunctionsTest.php +++ b/apps/files_external/tests/OwnCloudFunctionsTest.php @@ -36,72 +36,72 @@ namespace OCA\Files_External\Tests; class OwnCloudFunctionsTest extends \Test\TestCase { function configUrlProvider() { - return array( - array( - array( + return [ + [ + [ 'host' => 'testhost', 'root' => 'testroot', 'secure' => false - ), + ], 'http://testhost/remote.php/webdav/testroot/', - ), - array( - array( + ], + [ + [ 'host' => 'testhost', 'root' => 'testroot', 'secure' => true - ), + ], 'https://testhost/remote.php/webdav/testroot/', - ), - array( - array( + ], + [ + [ 'host' => 'http://testhost', 'root' => 'testroot', 'secure' => false - ), + ], 'http://testhost/remote.php/webdav/testroot/', - ), - array( - array( + ], + [ + [ 'host' => 'https://testhost', 'root' => 'testroot', 'secure' => false - ), + ], 'https://testhost/remote.php/webdav/testroot/', - ), - array( - array( + ], + [ + [ 'host' => 'https://testhost/testroot', 'root' => '', 'secure' => false - ), + ], 'https://testhost/testroot/remote.php/webdav/', - ), - array( - array( + ], + [ + [ 'host' => 'https://testhost/testroot', 'root' => 'subdir', 'secure' => false - ), + ], 'https://testhost/testroot/remote.php/webdav/subdir/', - ), - array( - array( + ], + [ + [ 'host' => 'http://testhost/testroot', 'root' => 'subdir', 'secure' => true - ), + ], 'http://testhost/testroot/remote.php/webdav/subdir/', - ), - array( - array( + ], + [ + [ 'host' => 'http://testhost/testroot/', 'root' => '/subdir', 'secure' => false - ), + ], 'http://testhost/testroot/remote.php/webdav/subdir/', - ), - ); + ], + ]; } /** diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php index 9d3a44042e0..dd35ee8f92c 100644 --- a/apps/files_external/tests/Service/StoragesServiceTest.php +++ b/apps/files_external/tests/Service/StoragesServiceTest.php @@ -95,7 +95,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); $this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto()); - self::$hookCalls = array(); + self::$hookCalls = []; $config = \OC::$server->getConfig(); $this->dataDir = $config->getSystemValue( 'datadirectory', @@ -177,7 +177,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { protected function tearDown(): void { \OC_Mount_Config::$skipTest = false; - self::$hookCalls = array(); + self::$hookCalls = []; if ($this->dbConfig) { $this->dbConfig->clean(); } @@ -448,17 +448,17 @@ abstract class StoragesServiceTest extends \Test\TestCase { } public static function createHookCallback($params) { - self::$hookCalls[] = array( + self::$hookCalls[] = [ 'signal' => Filesystem::signal_create_mount, 'params' => $params - ); + ]; } public static function deleteHookCallback($params) { - self::$hookCalls[] = array( + self::$hookCalls[] = [ 'signal' => Filesystem::signal_delete_mount, 'params' => $params - ); + ]; } /** diff --git a/apps/files_external/tests/Storage/FtpTest.php b/apps/files_external/tests/Storage/FtpTest.php index 65a1566ec1e..6b9ce2d5b31 100644 --- a/apps/files_external/tests/Storage/FtpTest.php +++ b/apps/files_external/tests/Storage/FtpTest.php @@ -63,11 +63,11 @@ class FtpTest extends \Test\Files\Storage\Storage { } public function testConstructUrl(){ - $config = array ( 'host' => 'localhost', + $config = [ 'host' => 'localhost', 'user' => 'ftp', 'password' => 'ftp', 'root' => '/', - 'secure' => false ); + 'secure' => false ]; $instance = new FTP($config); $this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl('')); diff --git a/apps/files_external/tests/Storage/SmbTest.php b/apps/files_external/tests/Storage/SmbTest.php index 2af9d00ebe9..87a5668be49 100644 --- a/apps/files_external/tests/Storage/SmbTest.php +++ b/apps/files_external/tests/Storage/SmbTest.php @@ -73,7 +73,7 @@ class SmbTest extends \Test\Files\Storage\Storage { public function directoryProvider() { // doesn't support leading/trailing spaces - return array(array('folder')); + return [['folder']]; } public function testRenameWithSpaces() { diff --git a/apps/files_external/tests/config.php b/apps/files_external/tests/config.php index a080b33e7fe..d6d3731c5a5 100644 --- a/apps/files_external/tests/config.php +++ b/apps/files_external/tests/config.php @@ -33,15 +33,15 @@ if (file_exists($privateConfigFile)) { } // this is now more a template now for your private configurations -return array( - 'ftp'=>array( +return [ + 'ftp'=>[ 'run'=>false, 'host'=>'localhost', 'user'=>'test', 'password'=>'test', 'root'=>'/test', - ), - 'webdav'=>array( + ], + 'webdav'=>[ 'run'=>false, 'host'=>'localhost', 'user'=>'test', @@ -51,15 +51,15 @@ return array( // (only in tests) // set to higher value for lighttpd webdav 'wait'=> 0 - ), - 'owncloud'=>array( + ], + 'owncloud'=>[ 'run'=>false, 'host'=>'localhost/owncloud', 'user'=>'test', 'password'=>'test', 'root'=>'', - ), - 'swift' => array( + ], + 'swift' => [ 'run' => false, 'user' => 'test', 'bucket' => 'test', @@ -70,16 +70,16 @@ return array( //'service_name' => 'swift', //should be 'swift' for OpenStack Object Storage and 'cloudFiles' for Rackspace Cloud Files (default value) //'url' => 'https://identity.api.rackspacecloud.com/v2.0/', //to be used with Rackspace Cloud Files and OpenStack Object Storage //'timeout' => 5 // timeout of HTTP requests in seconds - ), - 'smb'=>array( + ], + 'smb'=>[ 'run'=>false, 'user'=>'test', 'password'=>'test', 'host'=>'localhost', 'share'=>'/test', 'root'=>'/test/', - ), - 'amazons3'=>array( + ], + 'amazons3'=>[ 'run'=>false, 'key'=>'test', 'secret'=>'test', @@ -90,20 +90,20 @@ return array( //'region' => 'eu-west-1', //'test'=>'true', //'timeout'=>20 - ), - 'sftp' => array ( + ], + 'sftp' => [ 'run'=>false, 'host'=>'localhost', 'user'=>'test', 'password'=>'test', 'root'=>'/test' - ), - 'sftp_key' => array ( + ], + 'sftp_key' => [ 'run'=>false, 'host'=>'localhost', 'user'=>'test', 'public_key'=>'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDJPTvz3OLonF2KSGEKP/nd4CPmRYvemG2T4rIiNYjDj0U5y+2sKEWbjiUlQl2bsqYuVoJ+/UNJlGQbbZ08kQirFeo1GoWBzqioaTjUJfbLN6TzVVKXxR9YIVmH7Ajg2iEeGCndGgbmnPfj+kF9TR9IH8vMVvtubQwf7uEwB0ALhw== phpseclib-generated-key', 'private_key'=>'test', 'root'=>'/test' - ), -); + ], +]; diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 620aaf42c69..1022788ed2f 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -615,7 +615,7 @@ class ShareController extends AuthPublicShareController { $this->emitAccessShareHook($share); - $server_params = array( 'head' => $this->request->getMethod() === 'HEAD' ); + $server_params = [ 'head' => $this->request->getMethod() === 'HEAD' ]; /** * Http range requests support diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index c58e6e7b98a..c89bb2c2f4f 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -193,13 +193,13 @@ class Manager { $this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType); - $options = array( + $options = [ 'remote' => $remote, 'token' => $token, 'password' => $password, 'mountpoint' => $mountPoint, 'owner' => $owner - ); + ]; return $this->mountShare($options); } @@ -226,7 +226,7 @@ class Manager { (`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`, `accepted`, `remote_id`, `parent`, `share_type`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) '); - return $query->execute(array($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType)); + return $query->execute([$remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType]); } /** @@ -240,7 +240,7 @@ class Manager { SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`, `parent`, `share_type`, `password`, `mountpoint_hash` FROM `*PREFIX*share_external` WHERE `id` = ?'); - $result = $getShare->execute(array($id)); + $result = $getShare->execute([$id]); $share = $result ? $getShare->fetch() : []; @@ -286,7 +286,7 @@ class Manager { `mountpoint` = ?, `mountpoint_hash` = ? WHERE `id` = ? AND `user` = ?'); - $userShareAccepted = $acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid)); + $userShareAccepted = $acceptShare->execute([1, $mountPoint, $hash, $id, $this->uid]); } else { $result = $this->writeShareToDb( $share['remote'], @@ -327,7 +327,7 @@ class Manager { if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) { $removeShare = $this->connection->prepare(' DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?'); - $removeShare->execute(array($id, $this->uid)); + $removeShare->execute([$id, $this->uid]); $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); $this->processNotification($id); @@ -384,7 +384,7 @@ class Manager { $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT; - $fields = array('token' => $token); + $fields = ['token' => $token]; $client = $this->clientService->newClient(); @@ -502,7 +502,7 @@ class Manager { WHERE `mountpoint_hash` = ? AND `user` = ? '); - $result = (bool)$query->execute(array($target, $targetHash, $sourceHash, $this->uid)); + $result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]); return $result; } @@ -519,7 +519,7 @@ class Manager { SELECT `remote`, `share_token`, `remote_id`, `share_type`, `id` FROM `*PREFIX*share_external` WHERE `mountpoint_hash` = ? AND `user` = ?'); - $result = $getShare->execute(array($hash, $this->uid)); + $result = $getShare->execute([$hash, $this->uid]); $share = $getShare->fetch(); $getShare->closeCursor(); @@ -535,13 +535,13 @@ class Manager { DELETE FROM `*PREFIX*share_external` WHERE `id` = ? '); - $result = (bool)$query->execute(array((int)$share['id'])); + $result = (bool)$query->execute([(int)$share['id']]); } else if ($result && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { $query = $this->connection->prepare(' UPDATE `*PREFIX*share_external` SET `accepted` = ? WHERE `id` = ?'); - $result = (bool)$query->execute(array(0, (int)$share['id'])); + $result = (bool)$query->execute([0, (int)$share['id']]); } if($result) { @@ -585,7 +585,7 @@ class Manager { SELECT `remote`, `share_token`, `remote_id` FROM `*PREFIX*share_external` WHERE `user` = ?'); - $result = $getShare->execute(array($uid)); + $result = $getShare->execute([$uid]); if ($result) { $shares = $getShare->fetchAll(); @@ -598,7 +598,7 @@ class Manager { DELETE FROM `*PREFIX*share_external` WHERE `user` = ? '); - return (bool)$query->execute(array($uid)); + return (bool)$query->execute([$uid]); } /** diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index 97870f73343..e405d8c4472 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -85,13 +85,13 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage { $this->mountPoint = $options['mountpoint']; $this->token = $options['token']; - parent::__construct(array( + parent::__construct([ 'secure' => $secure, 'host' => $host, 'root' => $root, 'user' => $options['token'], 'password' => (string)$options['password'] - )); + ]); } public function getWatcher($path = '', $storage = null) { diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php index a3a041142eb..7bde5979ce1 100644 --- a/apps/files_sharing/lib/ShareBackend/File.php +++ b/apps/files_sharing/lib/ShareBackend/File.php @@ -117,7 +117,7 @@ class File implements \OCP\Share_Backend_File_Dependent { } } - $excludeList = is_array($exclude) ? $exclude : array(); + $excludeList = is_array($exclude) ? $exclude : []; return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $excludeList, $view); } @@ -126,17 +126,17 @@ class File implements \OCP\Share_Backend_File_Dependent { if ($format === self::FORMAT_SHARED_STORAGE) { // Only 1 item should come through for this format call $item = array_shift($items); - return array( + return [ 'parent' => $item['parent'], 'path' => $item['path'], 'storage' => $item['storage'], 'permissions' => $item['permissions'], 'uid_owner' => $item['uid_owner'], - ); + ]; } else if ($format === self::FORMAT_GET_FOLDER_CONTENTS) { - $files = array(); + $files = []; foreach ($items as $item) { - $file = array(); + $file = []; $file['fileid'] = $item['file_source']; $file['storage'] = $item['storage']; $file['path'] = $item['file_target']; @@ -157,31 +157,31 @@ class File implements \OCP\Share_Backend_File_Dependent { } return $files; } else if ($format === self::FORMAT_OPENDIR) { - $files = array(); + $files = []; foreach ($items as $item) { $files[] = basename($item['file_target']); } return $files; } else if ($format === self::FORMAT_GET_ALL) { - $ids = array(); + $ids = []; foreach ($items as $item) { $ids[] = $item['file_source']; } return $ids; } else if ($format === self::FORMAT_PERMISSIONS) { - $filePermissions = array(); + $filePermissions = []; foreach ($items as $item) { $filePermissions[$item['file_source']] = $item['permissions']; } return $filePermissions; } else if ($format === self::FORMAT_TARGET_NAMES) { - $targets = array(); + $targets = []; foreach ($items as $item) { $targets[] = $item['file_target']; } return $targets; } - return array(); + return []; } /** diff --git a/apps/files_sharing/lib/ShareBackend/Folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php index fd4bb2491fa..0c1ea18667c 100644 --- a/apps/files_sharing/lib/ShareBackend/Folder.php +++ b/apps/files_sharing/lib/ShareBackend/Folder.php @@ -39,7 +39,7 @@ class Folder extends File implements \OCP\Share_Backend_Collection { * @return array with shares */ public function getParents($itemSource, $shareWith = null, $owner = null) { - $result = array(); + $result = []; $parent = $this->getParentId($itemSource); $userManager = \OC::$server->getUserManager(); @@ -89,8 +89,8 @@ class Folder extends File implements \OCP\Share_Backend_Collection { } public function getChildren($itemSource) { - $children = array(); - $parents = array($itemSource); + $children = []; + $parents = [$itemSource]; $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); $qb->select('id') @@ -123,9 +123,9 @@ class Folder extends File implements \OCP\Share_Backend_Collection { $result = $qb->execute(); - $parents = array(); + $parents = []; while ($file = $result->fetch()) { - $children[] = array('source' => $file['fileid'], 'file_path' => $file['name']); + $children[] = ['source' => $file['fileid'], 'file_path' => $file['name']]; // If a child folder is found look inside it if ((int) $file['mimetype'] === $mimetype) { $parents[] = $file['fileid']; diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 0baa36ac985..ea0163e80b2 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -285,11 +285,11 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto } } } - $info = array( + $info = [ 'target' => $this->getMountPoint() . $path, 'source' => $source, 'mode' => $mode, - ); + ]; \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info); return $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode); } diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 1fcdf2fe505..99cdb882206 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -34,7 +34,7 @@ if ($token !== '') { } else { http_response_code(307); } - header('Location: ' . $urlGenerator->linkToRoute($route, array('token' => $token))); + header('Location: ' . $urlGenerator->linkToRoute($route, ['token' => $token])); } else { http_response_code(404); $tmpl = new OCP\Template('', '404', 'guest'); diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 792b4d23804..a9cfaae9df1 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -75,7 +75,7 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size); <div class="directDownload"> <a href="<?php p($_['downloadURL']); ?>" id="downloadFile" class="button"> <span class="icon icon-download"></span> - <?php p($l->t('Download %s', array($_['filename'])))?> (<?php p($_['fileSize']) ?>) + <?php p($l->t('Download %s', [$_['filename']]))?> (<?php p($_['fileSize']) ?>) </a> </div> <?php endif; ?> diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index c510c4dad98..a356525260f 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -648,12 +648,12 @@ class ApiTest extends TestCase { $share3->setStatus(IShare::STATUS_ACCEPTED); $this->shareManager->updateShare($share3); - $testValues=array( - array('query' => $this->folder, - 'expectedResult' => $this->folder . $this->filename), - array('query' => $this->folder . $this->subfolder, - 'expectedResult' => $this->folder . $this->subfolder . $this->filename), - ); + $testValues=[ + ['query' => $this->folder, + 'expectedResult' => $this->folder . $this->filename], + ['query' => $this->folder . $this->subfolder, + 'expectedResult' => $this->folder . $this->subfolder . $this->filename], + ]; foreach ($testValues as $value) { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); @@ -1214,7 +1214,7 @@ class ApiTest extends TestCase { */ public static function initTestMountPointsHook($data) { if ($data['user'] === self::TEST_FILES_SHARING_API_USER1) { - \OC\Files\Filesystem::mount(self::$tempStorage, array(), '/' . self::TEST_FILES_SHARING_API_USER1 . '/files' . self::TEST_FOLDER_NAME); + \OC\Files\Filesystem::mount(self::$tempStorage, [], '/' . self::TEST_FILES_SHARING_API_USER1 . '/files' . self::TEST_FOLDER_NAME); } } @@ -1222,7 +1222,7 @@ class ApiTest extends TestCase { * Tests mounting a folder that is an external storage mount point. */ public function testShareStorageMountPoint() { - $tempStorage = new \OC\Files\Storage\Temporary(array()); + $tempStorage = new \OC\Files\Storage\Temporary([]); $tempStorage->file_put_contents('test.txt', 'abcdef'); $tempStorage->getScanner()->scan(''); diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php index 1c05e70f080..cba90e8f9e6 100644 --- a/apps/files_sharing/tests/CacheTest.php +++ b/apps/files_sharing/tests/CacheTest.php @@ -148,63 +148,63 @@ class CacheTest extends TestCase { } function searchDataProvider() { - return array( - array('%another%', - array( - array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), - array('name' => 'another.txt', 'path' => 'subdir/another.txt'), - ) - ), - array('%Another%', - array( - array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), - array('name' => 'another.txt', 'path' => 'subdir/another.txt'), - ) - ), - array('%dir%', - array( - array('name' => 'emptydir', 'path' => 'emptydir'), - array('name' => 'subdir', 'path' => 'subdir'), - array('name' => 'shareddir', 'path' => ''), - ) - ), - array('%Dir%', - array( - array('name' => 'emptydir', 'path' => 'emptydir'), - array('name' => 'subdir', 'path' => 'subdir'), - array('name' => 'shareddir', 'path' => ''), - ) - ), - array('%txt%', - array( - array('name' => 'bar.txt', 'path' => 'bar.txt'), - array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), - array('name' => 'another.txt', 'path' => 'subdir/another.txt'), - ) - ), - array('%Txt%', - array( - array('name' => 'bar.txt', 'path' => 'bar.txt'), - array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), - array('name' => 'another.txt', 'path' => 'subdir/another.txt'), - ) - ), - array('%', - array( - array('name' => 'bar.txt', 'path' => 'bar.txt'), - array('name' => 'emptydir', 'path' => 'emptydir'), - array('name' => 'subdir', 'path' => 'subdir'), - array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), - array('name' => 'another.txt', 'path' => 'subdir/another.txt'), - array('name' => 'not a text file.xml', 'path' => 'subdir/not a text file.xml'), - array('name' => 'shareddir', 'path' => ''), - ) - ), - array('%nonexistent%', - array( - ) - ), - ); + return [ + ['%another%', + [ + ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'], + ['name' => 'another.txt', 'path' => 'subdir/another.txt'], + ] + ], + ['%Another%', + [ + ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'], + ['name' => 'another.txt', 'path' => 'subdir/another.txt'], + ] + ], + ['%dir%', + [ + ['name' => 'emptydir', 'path' => 'emptydir'], + ['name' => 'subdir', 'path' => 'subdir'], + ['name' => 'shareddir', 'path' => ''], + ] + ], + ['%Dir%', + [ + ['name' => 'emptydir', 'path' => 'emptydir'], + ['name' => 'subdir', 'path' => 'subdir'], + ['name' => 'shareddir', 'path' => ''], + ] + ], + ['%txt%', + [ + ['name' => 'bar.txt', 'path' => 'bar.txt'], + ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'], + ['name' => 'another.txt', 'path' => 'subdir/another.txt'], + ] + ], + ['%Txt%', + [ + ['name' => 'bar.txt', 'path' => 'bar.txt'], + ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'], + ['name' => 'another.txt', 'path' => 'subdir/another.txt'], + ] + ], + ['%', + [ + ['name' => 'bar.txt', 'path' => 'bar.txt'], + ['name' => 'emptydir', 'path' => 'emptydir'], + ['name' => 'subdir', 'path' => 'subdir'], + ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'], + ['name' => 'another.txt', 'path' => 'subdir/another.txt'], + ['name' => 'not a text file.xml', 'path' => 'subdir/not a text file.xml'], + ['name' => 'shareddir', 'path' => ''], + ] + ], + ['%nonexistent%', + [ + ] + ], + ]; } /** @@ -226,20 +226,20 @@ class CacheTest extends TestCase { */ function testSearchByMime() { $results = $this->sharedStorage->getCache()->searchByMime('text'); - $check = array( - array( + $check = [ + [ 'name' => 'bar.txt', 'path' => 'bar.txt' - ), - array( + ], + [ 'name' => 'another too.txt', 'path' => 'subdir/another too.txt' - ), - array( + ], + [ 'name' => 'another.txt', 'path' => 'subdir/another.txt' - ), - ); + ], + ]; $this->verifyFiles($check, $results); } @@ -250,27 +250,27 @@ class CacheTest extends TestCase { // additional root will always contain the example file "welcome.txt", // so this will be part of the result $this->verifyFiles( - array( - array( + [ + [ 'name' => 'welcome.txt', 'path' => 'files/welcome.txt', 'mimetype' => 'text/plain', - ), - array( + ], + [ 'name' => 'shareddir', 'path' => 'files/shareddir', 'mimetype' => 'httpd/unix-directory', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One', - ), - array( + ], + [ 'name' => 'shared single file.txt', 'path' => 'files/shared single file.txt', 'mimetype' => 'text/plain', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One', - ), - ), + ], + ], $results ); } @@ -279,29 +279,29 @@ class CacheTest extends TestCase { $results = $this->user2View->getDirectoryContent('/shareddir'); $this->verifyFiles( - array( - array( + [ + [ 'name' => 'bar.txt', 'path' => 'bar.txt', 'mimetype' => 'text/plain', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One', - ), - array( + ], + [ 'name' => 'emptydir', 'path' => 'emptydir', 'mimetype' => 'httpd/unix-directory', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One', - ), - array( + ], + [ 'name' => 'subdir', 'path' => 'subdir', 'mimetype' => 'httpd/unix-directory', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One', - ), - ), + ], + ], $results ); } @@ -327,29 +327,29 @@ class CacheTest extends TestCase { $results = $thirdView->getDirectoryContent('/subdir'); $this->verifyFiles( - array( - array( + [ + [ 'name' => 'another too.txt', 'path' => 'another too.txt', 'mimetype' => 'text/plain', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One', - ), - array( + ], + [ 'name' => 'another.txt', 'path' => 'another.txt', 'mimetype' => 'text/plain', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One', - ), - array( + ], + [ 'name' => 'not a text file.xml', 'path' => 'not a text file.xml', 'mimetype' => 'application/xml', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One', - ), - ), + ], + ], $results ); @@ -376,7 +376,7 @@ class CacheTest extends TestCase { } } } - $this->assertEquals(array(), $results); + $this->assertEquals([], $results); } /** diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 69b00ff9424..e8fb3454e1e 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -1525,7 +1525,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn(true); $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController') - ->setMethods(array('canAccessShare')) + ->setMethods(['canAccessShare']) ->getMock(); $helper->method('canAccessShare') ->with($share, $this->currentUser) @@ -2170,7 +2170,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn(true); $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController') - ->setMethods(array('createShare')) + ->setMethods(['createShare']) ->getMock(); $helper->method('createShare') ->with( @@ -2293,7 +2293,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn(true); $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController') - ->setMethods(array('createShare')) + ->setMethods(['createShare']) ->getMock(); $helper->method('createShare') ->with( @@ -4291,7 +4291,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn(true); $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController') - ->setMethods(array('formatShare')) + ->setMethods(['formatShare']) ->getMock(); $helper->method('formatShare') ->with($share) diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 35807dffe82..c560595a7b4 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -287,7 +287,7 @@ class ShareControllerTest extends \Test\TestCase { }); $response = $this->shareController->showShare(); - $sharedTmplParams = array( + $sharedTmplParams = [ 'displayName' => 'ownerDisplay', 'owner' => 'ownerUID', 'filename' => 'file1.txt', @@ -315,7 +315,7 @@ class ShareControllerTest extends \Test\TestCase { 'note' => $note, 'hideDownload' => false, 'showgridview' => false - ); + ]; $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); @@ -427,7 +427,7 @@ class ShareControllerTest extends \Test\TestCase { }); $response = $this->shareController->showShare(); - $sharedTmplParams = array( + $sharedTmplParams = [ 'displayName' => 'ownerDisplay', 'owner' => 'ownerUID', 'filename' => 'file1.txt', @@ -455,7 +455,7 @@ class ShareControllerTest extends \Test\TestCase { 'note' => $note, 'hideDownload' => true, 'showgridview' => false - ); + ]; $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); @@ -541,7 +541,7 @@ class ShareControllerTest extends \Test\TestCase { unset($responseParams['folder']); $response->setParams($responseParams); - $sharedTmplParams = array( + $sharedTmplParams = [ 'displayName' => 'ownerDisplay', 'owner' => 'ownerUID', 'filename' => '/fileDrop', @@ -569,7 +569,7 @@ class ShareControllerTest extends \Test\TestCase { 'note' => '', 'hideDownload' => false, 'showgridview' => false - ); + ]; $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); diff --git a/apps/files_sharing/tests/External/CacheTest.php b/apps/files_sharing/tests/External/CacheTest.php index 766f0232b87..42cd05ebdf4 100644 --- a/apps/files_sharing/tests/External/CacheTest.php +++ b/apps/files_sharing/tests/External/CacheTest.php @@ -76,11 +76,11 @@ class CacheTest extends TestCase { ); $this->cache->put( 'test.txt', - array( + [ 'mimetype' => 'text/plain', 'size' => 5, 'mtime' => 123, - ) + ] ); } @@ -107,19 +107,19 @@ class CacheTest extends TestCase { public function testGetFolderPopulatesOwner() { $dirId = $this->cache->put( 'subdir', - array( + [ 'mimetype' => 'httpd/unix-directory', 'size' => 5, 'mtime' => 123, - ) + ] ); $this->cache->put( 'subdir/contents.txt', - array( + [ 'mimetype' => 'text/plain', 'size' => 5, 'mtime' => 123, - ) + ] ); $results = $this->cache->getFolderContentsById($dirId); diff --git a/apps/files_sharing/tests/ExternalStorageTest.php b/apps/files_sharing/tests/ExternalStorageTest.php index b4e84846ed4..2a9577bccb9 100644 --- a/apps/files_sharing/tests/ExternalStorageTest.php +++ b/apps/files_sharing/tests/ExternalStorageTest.php @@ -39,37 +39,37 @@ use OCP\Http\Client\IResponse; class ExternalStorageTest extends \Test\TestCase { function optionsProvider() { - return array( - array( + return [ + [ 'http://remoteserver:8080/owncloud', 'http://remoteserver:8080/owncloud/public.php/webdav/', - ), + ], // extra slash - array( + [ 'http://remoteserver:8080/owncloud/', 'http://remoteserver:8080/owncloud/public.php/webdav/', - ), + ], // extra path - array( + [ 'http://remoteserver:8080/myservices/owncloud/', 'http://remoteserver:8080/myservices/owncloud/public.php/webdav/', - ), + ], // root path - array( + [ 'http://remoteserver:8080/', 'http://remoteserver:8080/public.php/webdav/', - ), + ], // without port - array( + [ 'http://remoteserver/oc.test', 'http://remoteserver/oc.test/public.php/webdav/', - ), + ], // https - array( + [ 'https://remoteserver/', 'https://remoteserver/public.php/webdav/', - ), - ); + ], + ]; } private function getTestStorage($uri) { @@ -91,7 +91,7 @@ class ExternalStorageTest extends \Test\TestCase { ->willReturn($client); return new TestSharingExternalStorage( - array( + [ 'cloudId' => new CloudId('testOwner@' . $uri, 'testOwner', $uri), 'remote' => $uri, 'owner' => 'testOwner', @@ -101,7 +101,7 @@ class ExternalStorageTest extends \Test\TestCase { 'manager' => null, 'certificateManager' => $certificateManager, 'HttpClientService' => $httpClientService, - ) + ] ); } diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php index 50859984133..dddeb5cf551 100644 --- a/apps/files_sharing/tests/ShareTest.php +++ b/apps/files_sharing/tests/ShareTest.php @@ -226,13 +226,13 @@ class ShareTest extends TestCase { $permission5 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE; $permission6 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE; - return array( - array($permission1, false), - array($permission3, true), - array($permission4, true), - array($permission5, false), - array($permission6, false), - ); + return [ + [$permission1, false], + [$permission3, true], + [$permission4, true], + [$permission5, false], + [$permission6, false], + ]; } public function testFileOwner() { diff --git a/apps/files_sharing/tests/SharedMountTest.php b/apps/files_sharing/tests/SharedMountTest.php index 55abbd20cba..e63cb597950 100644 --- a/apps/files_sharing/tests/SharedMountTest.php +++ b/apps/files_sharing/tests/SharedMountTest.php @@ -251,14 +251,14 @@ class SharedMountTest extends TestCase { } public function dataProviderTestStripUserFilesPath() { - return array( - array('/user/files/foo.txt', '/foo.txt', false), - array('/user/files/folder/foo.txt', '/folder/foo.txt', false), - array('/data/user/files/foo.txt', null, true), - array('/data/user/files/', null, true), - array('/files/foo.txt', null, true), - array('/foo.txt', null, true), - ); + return [ + ['/user/files/foo.txt', '/foo.txt', false], + ['/user/files/folder/foo.txt', '/folder/foo.txt', false], + ['/data/user/files/foo.txt', null, true], + ['/data/user/files/', null, true], + ['/files/foo.txt', null, true], + ['/foo.txt', null, true], + ]; } public function dataPermissionMovedGroupShare() { diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php index 59e411e47f7..1c222055d4e 100644 --- a/apps/files_sharing/tests/SharedStorageTest.php +++ b/apps/files_sharing/tests/SharedStorageTest.php @@ -406,7 +406,7 @@ class SharedStorageTest extends TestCase { $mountConfigManager = \OC::$server->getMountProviderCollection(); $mounts = $mountConfigManager->getMountsForUser(\OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3)); - array_walk($mounts, array(\OC\Files\Filesystem::getMountManager(), 'addMount')); + array_walk($mounts, [\OC\Files\Filesystem::getMountManager(), 'addMount']); $this->assertTrue($rootView->file_exists('/' . self::TEST_FILES_SHARING_API_USER3 . '/files/' . $this->filename)); @@ -443,7 +443,7 @@ class SharedStorageTest extends TestCase { list($sharedStorage,) = $view->resolvePath($this->folder); $this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')); - $sourceStorage = new \OC\Files\Storage\Temporary(array()); + $sourceStorage = new \OC\Files\Storage\Temporary([]); $sourceStorage->file_put_contents('foo.txt', 'asd'); $sharedStorage->copyFromStorage($sourceStorage, 'foo.txt', 'bar.txt'); @@ -476,7 +476,7 @@ class SharedStorageTest extends TestCase { list($sharedStorage,) = $view->resolvePath($this->folder); $this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')); - $sourceStorage = new \OC\Files\Storage\Temporary(array()); + $sourceStorage = new \OC\Files\Storage\Temporary([]); $sourceStorage->file_put_contents('foo.txt', 'asd'); $sharedStorage->moveFromStorage($sourceStorage, 'foo.txt', 'bar.txt'); diff --git a/apps/files_sharing/tests/WatcherTest.php b/apps/files_sharing/tests/WatcherTest.php index 093f6139dd3..0386828c4ca 100644 --- a/apps/files_sharing/tests/WatcherTest.php +++ b/apps/files_sharing/tests/WatcherTest.php @@ -115,9 +115,9 @@ class WatcherTest extends TestCase { $textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $dataLen = strlen($textData); - $this->sharedCache->put('bar.txt', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain')); + $this->sharedCache->put('bar.txt', ['mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain']); $this->sharedStorage->file_put_contents('bar.txt', $textData); - $this->sharedCache->put('', array('mtime' => 10, 'storage_mtime' => 10, 'size' => '-1', 'mimetype' => 'httpd/unix-directory')); + $this->sharedCache->put('', ['mtime' => 10, 'storage_mtime' => 10, 'size' => '-1', 'mimetype' => 'httpd/unix-directory']); // run the propagation code $this->sharedStorage->getWatcher()->checkUpdate(''); @@ -145,9 +145,9 @@ class WatcherTest extends TestCase { $textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $dataLen = strlen($textData); - $this->sharedCache->put('subdir/bar.txt', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain')); + $this->sharedCache->put('subdir/bar.txt', ['mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain']); $this->sharedStorage->file_put_contents('subdir/bar.txt', $textData); - $this->sharedCache->put('subdir', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain')); + $this->sharedCache->put('subdir', ['mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain']); // run the propagation code $this->sharedStorage->getWatcher()->checkUpdate('subdir'); @@ -173,7 +173,7 @@ class WatcherTest extends TestCase { * @param string $path */ function getOwnerDirSizes($path) { - $result = array(); + $result = []; while ($path != '' && $path != '' && $path != '.') { $cachedData = $this->ownerCache->get($path); diff --git a/apps/files_trashbin/lib/Helper.php b/apps/files_trashbin/lib/Helper.php index 343734f882a..3cc096decbb 100644 --- a/apps/files_trashbin/lib/Helper.php +++ b/apps/files_trashbin/lib/Helper.php @@ -46,7 +46,7 @@ class Helper { * @return \OCP\Files\FileInfo[] */ public static function getTrashFiles($dir, $user, $sortAttribute = '', $sortDescending = false) { - $result = array(); + $result = []; $timestamp = null; $view = new \OC\Files\View('/' . $user . '/files_trashbin/files'); @@ -84,7 +84,7 @@ class Helper { } } $type = $entry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE ? 'dir' : 'file'; - $i = array( + $i = [ 'name' => $name, 'mtime' => $timestamp, 'mimetype' => $type === 'dir' ? 'httpd/unix-directory' : \OC::$server->getMimeTypeDetector()->detectPath($name), @@ -94,7 +94,7 @@ class Helper { 'etag' => '', 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE, 'fileid' => $entry->getId(), - ); + ]; if ($originalPath) { if ($originalPath !== '.') { $i['extraData'] = $originalPath . '/' . $originalName; @@ -117,7 +117,7 @@ class Helper { * @param \OCP\Files\FileInfo[] $fileInfos file infos */ public static function formatFileInfos($fileInfos) { - $files = array(); + $files = []; foreach ($fileInfos as $i) { $entry = \OCA\Files\Helper::formatFileInfo($i); $entry['id'] = $i->getId(); diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 8e94a215400..0f1787223a2 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -122,13 +122,13 @@ class Trashbin { public static function getLocations($user) { $query = \OC_DB::prepare('SELECT `id`, `timestamp`, `location`' . ' FROM `*PREFIX*files_trash` WHERE `user`=?'); - $result = $query->execute(array($user)); - $array = array(); + $result = $query->execute([$user]); + $array = []; while ($row = $result->fetchRow()) { if (isset($array[$row['id']])) { $array[$row['id']][$row['timestamp']] = $row['location']; } else { - $array[$row['id']] = array($row['timestamp'] => $row['location']); + $array[$row['id']] = [$row['timestamp'] => $row['location']]; } } return $array; @@ -145,7 +145,7 @@ class Trashbin { public static function getLocation($user, $filename, $timestamp) { $query = \OC_DB::prepare('SELECT `location` FROM `*PREFIX*files_trash`' . ' WHERE `user`=? AND `id`=? AND `timestamp`=?'); - $result = $query->execute(array($user, $filename, $timestamp))->fetchAll(); + $result = $query->execute([$user, $filename, $timestamp])->fetchAll(); if (isset($result[0]['location'])) { return $result[0]['location']; } else { @@ -201,7 +201,7 @@ class Trashbin { if ($view->file_exists($target)) { $query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)"); - $result = $query->execute(array($targetFilename, $timestamp, $targetLocation, $user)); + $result = $query->execute([$targetFilename, $timestamp, $targetLocation, $user]); if (!$result) { \OC::$server->getLogger()->error('trash bin database couldn\'t be updated for the files owner', ['app' => 'files_trashbin']); } @@ -281,12 +281,12 @@ class Trashbin { if ($moveSuccessful) { $query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)"); - $result = $query->execute(array($filename, $timestamp, $location, $owner)); + $result = $query->execute([$filename, $timestamp, $location, $owner]); if (!$result) { \OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']); } - \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', array('filePath' => Filesystem::normalizePath($file_path), - 'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp))); + \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path), + 'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp)]); self::retainVersions($filename, $owner, $ownerPath, $timestamp); @@ -433,14 +433,14 @@ class Trashbin { $view->chroot('/' . $user . '/files'); $view->touch('/' . $location . '/' . $uniqueFilename, $mtime); $view->chroot($fakeRoot); - \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', array('filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename), - 'trashPath' => Filesystem::normalizePath($file))); + \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename), + 'trashPath' => Filesystem::normalizePath($file)]); self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp); if ($timestamp) { $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?'); - $query->execute(array($user, $filename, $timestamp)); + $query->execute([$user, $filename, $timestamp]); } return true; @@ -512,14 +512,14 @@ class Trashbin { } // Array to store the relative path in (after the file is deleted, the view won't be able to relativise the path anymore) - $filePaths = array(); + $filePaths = []; foreach($fileInfos as $fileInfo){ $filePaths[] = $view->getRelativePath($fileInfo->getPath()); } unset($fileInfos); // save memory // Bulk PreDelete-Hook - \OC_Hook::emit('\OCP\Trashbin', 'preDeleteAll', array('paths' => $filePaths)); + \OC_Hook::emit('\OCP\Trashbin', 'preDeleteAll', ['paths' => $filePaths]); // Single-File Hooks foreach($filePaths as $path){ @@ -529,10 +529,10 @@ class Trashbin { // actual file deletion $trash->delete(); $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=?'); - $query->execute(array($user)); + $query->execute([$user]); // Bulk PostDelete-Hook - \OC_Hook::emit('\OCP\Trashbin', 'deleteAll', array('paths' => $filePaths)); + \OC_Hook::emit('\OCP\Trashbin', 'deleteAll', ['paths' => $filePaths]); // Single-File Hooks foreach($filePaths as $path){ @@ -550,7 +550,7 @@ class Trashbin { * @param string $path */ protected static function emitTrashbinPreDelete($path){ - \OC_Hook::emit('\OCP\Trashbin', 'preDelete', array('path' => $path)); + \OC_Hook::emit('\OCP\Trashbin', 'preDelete', ['path' => $path]); } /** @@ -558,7 +558,7 @@ class Trashbin { * @param string $path */ protected static function emitTrashbinPostDelete($path){ - \OC_Hook::emit('\OCP\Trashbin', 'delete', array('path' => $path)); + \OC_Hook::emit('\OCP\Trashbin', 'delete', ['path' => $path]); } /** @@ -577,7 +577,7 @@ class Trashbin { if ($timestamp) { $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?'); - $query->execute(array($user, $filename, $timestamp)); + $query->execute([$user, $filename, $timestamp]); $file = $filename . '.d' . $timestamp; } else { $file = $filename; @@ -660,7 +660,7 @@ class Trashbin { */ public static function deleteUser($uid) { $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=?'); - return $query->execute(array($uid)); + return $query->execute([$uid]); } /** @@ -818,7 +818,7 @@ class Trashbin { } } - return array($size, $count); + return [$size, $count]; } /** @@ -868,7 +868,7 @@ class Trashbin { */ private static function getVersionsFromTrash($filename, $timestamp, $user) { $view = new View('/' . $user . '/files_trashbin/versions'); - $versions = array(); + $versions = []; //force rescan of versions, local storage may not have updated the cache if (!self::$scannedVersions) { @@ -1015,6 +1015,6 @@ class Trashbin { * @return string */ public static function preview_icon($path) { - return \OC::$server->getURLGenerator()->linkToRoute('core_ajax_trashbin_preview', array('x' => 32, 'y' => 32, 'file' => $path)); + return \OC::$server->getURLGenerator()->linkToRoute('core_ajax_trashbin_preview', ['x' => 32, 'y' => 32, 'file' => $path]); } } diff --git a/apps/files_trashbin/tests/Command/CleanUpTest.php b/apps/files_trashbin/tests/Command/CleanUpTest.php index 3bfbf2b35fd..a906bf75853 100644 --- a/apps/files_trashbin/tests/Command/CleanUpTest.php +++ b/apps/files_trashbin/tests/Command/CleanUpTest.php @@ -81,12 +81,12 @@ class CleanUpTest extends TestCase { $query->delete($this->trashTable)->execute(); for ($i = 0; $i < 10; $i++) { $query->insert($this->trashTable) - ->values(array( + ->values([ 'id' => $query->expr()->literal('file'.$i), 'timestamp' => $query->expr()->literal($i), 'location' => $query->expr()->literal('.'), 'user' => $query->expr()->literal('user'.$i%2) - ))->execute(); + ])->execute(); } $getAllQuery = $this->dbConnection->getQueryBuilder(); $result = $getAllQuery->select('id') @@ -143,10 +143,10 @@ class CleanUpTest extends TestCase { } public function dataTestRemoveDeletedFiles() { - return array( - array(true), - array(false) - ); + return [ + [true], + [false] + ]; } /** diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index 6b57d111ea9..6047e488a77 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -145,8 +145,8 @@ class StorageTest extends \Test\TestCase { * isn't. */ public function testCrossStorageDeleteFile() { - $storage2 = new Temporary(array()); - \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage'); + $storage2 = new Temporary([]); + \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage'); $this->userView->file_put_contents('substorage/subfile.txt', 'foo'); $storage2->getScanner()->scan(''); @@ -171,8 +171,8 @@ class StorageTest extends \Test\TestCase { * isn't. */ public function testCrossStorageDeleteFolder() { - $storage2 = new Temporary(array()); - \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage'); + $storage2 = new Temporary([]); + \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage'); $this->userView->mkdir('substorage/folder'); $this->userView->file_put_contents('substorage/folder/subfile.txt', 'bar'); @@ -388,8 +388,8 @@ class StorageTest extends \Test\TestCase { public function testKeepFileAndVersionsWhenMovingFileBetweenStorages() { \OCA\Files_Versions\Hooks::connectHooks(); - $storage2 = new Temporary(array()); - \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage'); + $storage2 = new Temporary([]); + \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage'); // trigger a version (multiple would not work because of the expire logic) $this->userView->file_put_contents('test.txt', 'v1'); @@ -429,8 +429,8 @@ class StorageTest extends \Test\TestCase { public function testKeepFileAndVersionsWhenMovingFolderBetweenStorages() { \OCA\Files_Versions\Hooks::connectHooks(); - $storage2 = new Temporary(array()); - \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage'); + $storage2 = new Temporary([]); + \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage'); // trigger a version (multiple would not work because of the expire logic) $this->userView->file_put_contents('folder/inside.txt', 'v1'); diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index 4465bfbab3c..bdcef91e37c 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -270,14 +270,14 @@ class TrashbinTest extends \Test\TestCase { $filesInTrashUser2AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2); // user2-1.txt should have been expired - $this->verifyArray($filesInTrashUser2AfterDelete, array('user2-2.txt', 'user1-4.txt')); + $this->verifyArray($filesInTrashUser2AfterDelete, ['user2-2.txt', 'user1-4.txt']); self::loginHelper(self::TEST_TRASHBIN_USER1); // user1-1.txt and user1-3.txt should have been expired $filesInTrashUser1AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1); - $this->verifyArray($filesInTrashUser1AfterDelete, array('user1-2.txt', 'user1-4.txt')); + $this->verifyArray($filesInTrashUser1AfterDelete, ['user1-2.txt', 'user1-4.txt']); } /** diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 8df98d087d8..b1d6c689c61 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -67,24 +67,24 @@ class Storage { const DELETE_TRIGGER_QUOTA_EXCEEDED = 2; // files for which we can remove the versions after the delete operation was successful - private static $deletedFiles = array(); + private static $deletedFiles = []; - private static $sourcePathAndUser = array(); + private static $sourcePathAndUser = []; - private static $max_versions_per_interval = array( + private static $max_versions_per_interval = [ //first 10sec, one version every 2sec - 1 => array('intervalEndsAfter' => 10, 'step' => 2), + 1 => ['intervalEndsAfter' => 10, 'step' => 2], //next minute, one version every 10sec - 2 => array('intervalEndsAfter' => 60, 'step' => 10), + 2 => ['intervalEndsAfter' => 60, 'step' => 10], //next hour, one version every minute - 3 => array('intervalEndsAfter' => 3600, 'step' => 60), + 3 => ['intervalEndsAfter' => 3600, 'step' => 60], //next 24h, one version every hour - 4 => array('intervalEndsAfter' => 86400, 'step' => 3600), + 4 => ['intervalEndsAfter' => 86400, 'step' => 3600], //next 30days, one version per day - 5 => array('intervalEndsAfter' => 2592000, 'step' => 86400), + 5 => ['intervalEndsAfter' => 2592000, 'step' => 86400], //until the end one version per week - 6 => array('intervalEndsAfter' => -1, 'step' => 604800), - ); + 6 => ['intervalEndsAfter' => -1, 'step' => 604800], + ]; /** @var \OCA\Files_Versions\AppInfo\Application */ private static $application; @@ -129,7 +129,7 @@ class Storage { */ public static function setSourcePathAndUser($source) { list($uid, $path) = self::getUidAndFilename($source); - self::$sourcePathAndUser[$source] = array('uid' => $uid, 'path' => $path); + self::$sourcePathAndUser[$source] = ['uid' => $uid, 'path' => $path]; } /** @@ -147,7 +147,7 @@ class Storage { } else { $uid = $path = false; } - return array($uid, $path); + return [$uid, $path]; } /** @@ -215,9 +215,9 @@ class Storage { */ public static function markDeletedFile($path) { list($uid, $filename) = self::getUidAndFilename($path); - self::$deletedFiles[$path] = array( + self::$deletedFiles[$path] = [ 'uid' => $uid, - 'filename' => $filename); + 'filename' => $filename]; } /** @@ -253,9 +253,9 @@ class Storage { $versions = self::getVersions($uid, $filename); if (!empty($versions)) { foreach ($versions as $v) { - \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED)); + \OC_Hook::emit('\OCP\Versions', 'preDelete', ['path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED]); self::deleteVersion($view, $filename . '.v' . $v['version']); - \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED)); + \OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED]); } } } @@ -378,11 +378,11 @@ class Storage { $node = $userFolder->get($file); // TODO: move away from those legacy hooks! - \OC_Hook::emit('\OCP\Versions', 'rollback', array( + \OC_Hook::emit('\OCP\Versions', 'rollback', [ 'path' => $filename, 'revision' => $revision, 'node' => $node, - )); + ]); return true; } else if ($versionCreated) { self::deleteVersion($users_view, $version); @@ -439,7 +439,7 @@ class Storage { * @return array versions newest version first */ public static function getVersions($uid, $filename, $userFullPath = '') { - $versions = array(); + $versions = []; if (empty($filename)) { return $versions; } @@ -518,9 +518,9 @@ class Storage { $view = new View('/' . $uid . '/files_versions'); if (!empty($toDelete)) { foreach ($toDelete as $version) { - \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT)); + \OC_Hook::emit('\OCP\Versions', 'preDelete', ['path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT]); self::deleteVersion($view, $version['path'] . '.v' . $version['version']); - \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT)); + \OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT]); } } } @@ -559,8 +559,8 @@ class Storage { */ private static function getAllVersions($uid) { $view = new View('/' . $uid . '/'); - $dirs = array(self::VERSIONS_ROOT); - $versions = array(); + $dirs = [self::VERSIONS_ROOT]; + $versions = []; while (!empty($dirs)) { $dir = array_pop($dirs); @@ -577,7 +577,7 @@ class Storage { $version = substr($filePath, $versionsBegin + 2); $relpath = substr($filePath, $relPathStart, $versionsBegin - $relPathStart); $key = $version . '#' . $relpath; - $versions[$key] = array('path' => $relpath, 'timestamp' => $version); + $versions[$key] = ['path' => $relpath, 'timestamp' => $version]; } } } @@ -585,7 +585,7 @@ class Storage { // newest version first krsort($versions); - $result = array(); + $result = []; foreach ($versions as $key => $value) { $size = $view->filesize(self::VERSIONS_ROOT.'/'.$value['path'].'.v'.$value['timestamp']); @@ -638,7 +638,7 @@ class Storage { */ protected static function getAutoExpireList($time, $versions) { $size = 0; - $toDelete = array(); // versions we want to delete + $toDelete = []; // versions we want to delete $interval = 1; $step = Storage::$max_versions_per_interval[$interval]['step']; @@ -682,7 +682,7 @@ class Storage { } } - return array($toDelete, $size); + return [$toDelete, $size]; } /** @@ -791,9 +791,9 @@ class Storage { $logger = \OC::$server->getLogger(); foreach($toDelete as $key => $path) { - \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); + \OC_Hook::emit('\OCP\Versions', 'preDelete', ['path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED]); self::deleteVersion($versionsFileview, $path); - \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); + \OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED]); unset($allVersions[$key]); // update array with the versions we keep $logger->info('Expire: ' . $path, ['app' => 'files_versions']); } @@ -808,9 +808,9 @@ class Storage { reset($allVersions); while ($availableSpace < 0 && $i < $numOfVersions) { $version = current($allVersions); - \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); + \OC_Hook::emit('\OCP\Versions', 'preDelete', ['path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED]); self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']); - \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); + \OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED]); \OC::$server->getLogger()->info('running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'], ['app' => 'files_versions']); $versionsSize -= $version['size']; $availableSpace += $version['size']; diff --git a/apps/files_versions/tests/Command/CleanupTest.php b/apps/files_versions/tests/Command/CleanupTest.php index b5ed6c33a07..94f54f96d89 100644 --- a/apps/files_versions/tests/Command/CleanupTest.php +++ b/apps/files_versions/tests/Command/CleanupTest.php @@ -90,10 +90,10 @@ class CleanupTest extends TestCase { } public function dataTestDeleteVersions() { - return array( - array(true), - array(false) - ); + return [ + [true], + [false] + ]; } diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index 53179bd6b30..c7eaec0a699 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -159,121 +159,121 @@ class VersioningTest extends \Test\TestCase { } public function versionsProvider() { - return array( + return [ // first set of versions uniformly distributed versions - array( - array( + [ + [ // first slice (10sec) keep one version every 2 seconds - array("version" => 4999999, "path" => "keep", "size" => 1), - array("version" => 4999998, "path" => "delete", "size" => 1), - array("version" => 4999997, "path" => "keep", "size" => 1), - array("version" => 4999995, "path" => "keep", "size" => 1), - array("version" => 4999994, "path" => "delete", "size" => 1), + ["version" => 4999999, "path" => "keep", "size" => 1], + ["version" => 4999998, "path" => "delete", "size" => 1], + ["version" => 4999997, "path" => "keep", "size" => 1], + ["version" => 4999995, "path" => "keep", "size" => 1], + ["version" => 4999994, "path" => "delete", "size" => 1], //next slice (60sec) starts at 4999990 keep one version every 10 secons - array("version" => 4999988, "path" => "keep", "size" => 1), - array("version" => 4999978, "path" => "keep", "size" => 1), - array("version" => 4999975, "path" => "delete", "size" => 1), - array("version" => 4999972, "path" => "delete", "size" => 1), - array("version" => 4999967, "path" => "keep", "size" => 1), - array("version" => 4999958, "path" => "delete", "size" => 1), - array("version" => 4999957, "path" => "keep", "size" => 1), + ["version" => 4999988, "path" => "keep", "size" => 1], + ["version" => 4999978, "path" => "keep", "size" => 1], + ["version" => 4999975, "path" => "delete", "size" => 1], + ["version" => 4999972, "path" => "delete", "size" => 1], + ["version" => 4999967, "path" => "keep", "size" => 1], + ["version" => 4999958, "path" => "delete", "size" => 1], + ["version" => 4999957, "path" => "keep", "size" => 1], //next slice (3600sec) start at 4999940 keep one version every 60 seconds - array("version" => 4999900, "path" => "keep", "size" => 1), - array("version" => 4999841, "path" => "delete", "size" => 1), - array("version" => 4999840, "path" => "keep", "size" => 1), - array("version" => 4999780, "path" => "keep", "size" => 1), - array("version" => 4996401, "path" => "keep", "size" => 1), + ["version" => 4999900, "path" => "keep", "size" => 1], + ["version" => 4999841, "path" => "delete", "size" => 1], + ["version" => 4999840, "path" => "keep", "size" => 1], + ["version" => 4999780, "path" => "keep", "size" => 1], + ["version" => 4996401, "path" => "keep", "size" => 1], // next slice (86400sec) start at 4996400 keep one version every 3600 seconds - array("version" => 4996350, "path" => "delete", "size" => 1), - array("version" => 4992800, "path" => "keep", "size" => 1), - array("version" => 4989800, "path" => "delete", "size" => 1), - array("version" => 4989700, "path" => "delete", "size" => 1), - array("version" => 4989200, "path" => "keep", "size" => 1), + ["version" => 4996350, "path" => "delete", "size" => 1], + ["version" => 4992800, "path" => "keep", "size" => 1], + ["version" => 4989800, "path" => "delete", "size" => 1], + ["version" => 4989700, "path" => "delete", "size" => 1], + ["version" => 4989200, "path" => "keep", "size" => 1], // next slice (2592000sec) start at 4913600 keep one version every 86400 seconds - array("version" => 4913600, "path" => "keep", "size" => 1), - array("version" => 4852800, "path" => "delete", "size" => 1), - array("version" => 4827201, "path" => "delete", "size" => 1), - array("version" => 4827200, "path" => "keep", "size" => 1), - array("version" => 4777201, "path" => "delete", "size" => 1), - array("version" => 4777501, "path" => "delete", "size" => 1), - array("version" => 4740000, "path" => "keep", "size" => 1), + ["version" => 4913600, "path" => "keep", "size" => 1], + ["version" => 4852800, "path" => "delete", "size" => 1], + ["version" => 4827201, "path" => "delete", "size" => 1], + ["version" => 4827200, "path" => "keep", "size" => 1], + ["version" => 4777201, "path" => "delete", "size" => 1], + ["version" => 4777501, "path" => "delete", "size" => 1], + ["version" => 4740000, "path" => "keep", "size" => 1], // final slice starts at 2408000 keep one version every 604800 secons - array("version" => 2408000, "path" => "keep", "size" => 1), - array("version" => 1803201, "path" => "delete", "size" => 1), - array("version" => 1803200, "path" => "keep", "size" => 1), - array("version" => 1800199, "path" => "delete", "size" => 1), - array("version" => 1800100, "path" => "delete", "size" => 1), - array("version" => 1198300, "path" => "keep", "size" => 1), - ), + ["version" => 2408000, "path" => "keep", "size" => 1], + ["version" => 1803201, "path" => "delete", "size" => 1], + ["version" => 1803200, "path" => "keep", "size" => 1], + ["version" => 1800199, "path" => "delete", "size" => 1], + ["version" => 1800100, "path" => "delete", "size" => 1], + ["version" => 1198300, "path" => "keep", "size" => 1], + ], 16 // size of all deleted files (every file has the size 1) - ), + ], // second set of versions, here we have only really old versions - array( - array( + [ + [ // first slice (10sec) keep one version every 2 seconds // next slice (60sec) starts at 4999990 keep one version every 10 secons // next slice (3600sec) start at 4999940 keep one version every 60 seconds // next slice (86400sec) start at 4996400 keep one version every 3600 seconds - array("version" => 4996400, "path" => "keep", "size" => 1), - array("version" => 4996350, "path" => "delete", "size" => 1), - array("version" => 4996350, "path" => "delete", "size" => 1), - array("version" => 4992800, "path" => "keep", "size" => 1), - array("version" => 4989800, "path" => "delete", "size" => 1), - array("version" => 4989700, "path" => "delete", "size" => 1), - array("version" => 4989200, "path" => "keep", "size" => 1), + ["version" => 4996400, "path" => "keep", "size" => 1], + ["version" => 4996350, "path" => "delete", "size" => 1], + ["version" => 4996350, "path" => "delete", "size" => 1], + ["version" => 4992800, "path" => "keep", "size" => 1], + ["version" => 4989800, "path" => "delete", "size" => 1], + ["version" => 4989700, "path" => "delete", "size" => 1], + ["version" => 4989200, "path" => "keep", "size" => 1], // next slice (2592000sec) start at 4913600 keep one version every 86400 seconds - array("version" => 4913600, "path" => "keep", "size" => 1), - array("version" => 4852800, "path" => "delete", "size" => 1), - array("version" => 4827201, "path" => "delete", "size" => 1), - array("version" => 4827200, "path" => "keep", "size" => 1), - array("version" => 4777201, "path" => "delete", "size" => 1), - array("version" => 4777501, "path" => "delete", "size" => 1), - array("version" => 4740000, "path" => "keep", "size" => 1), + ["version" => 4913600, "path" => "keep", "size" => 1], + ["version" => 4852800, "path" => "delete", "size" => 1], + ["version" => 4827201, "path" => "delete", "size" => 1], + ["version" => 4827200, "path" => "keep", "size" => 1], + ["version" => 4777201, "path" => "delete", "size" => 1], + ["version" => 4777501, "path" => "delete", "size" => 1], + ["version" => 4740000, "path" => "keep", "size" => 1], // final slice starts at 2408000 keep one version every 604800 secons - array("version" => 2408000, "path" => "keep", "size" => 1), - array("version" => 1803201, "path" => "delete", "size" => 1), - array("version" => 1803200, "path" => "keep", "size" => 1), - array("version" => 1800199, "path" => "delete", "size" => 1), - array("version" => 1800100, "path" => "delete", "size" => 1), - array("version" => 1198300, "path" => "keep", "size" => 1), - ), + ["version" => 2408000, "path" => "keep", "size" => 1], + ["version" => 1803201, "path" => "delete", "size" => 1], + ["version" => 1803200, "path" => "keep", "size" => 1], + ["version" => 1800199, "path" => "delete", "size" => 1], + ["version" => 1800100, "path" => "delete", "size" => 1], + ["version" => 1198300, "path" => "keep", "size" => 1], + ], 11 // size of all deleted files (every file has the size 1) - ), + ], // third set of versions, with some gaps between - array( - array( + [ + [ // first slice (10sec) keep one version every 2 seconds - array("version" => 4999999, "path" => "keep", "size" => 1), - array("version" => 4999998, "path" => "delete", "size" => 1), - array("version" => 4999997, "path" => "keep", "size" => 1), - array("version" => 4999995, "path" => "keep", "size" => 1), - array("version" => 4999994, "path" => "delete", "size" => 1), + ["version" => 4999999, "path" => "keep", "size" => 1], + ["version" => 4999998, "path" => "delete", "size" => 1], + ["version" => 4999997, "path" => "keep", "size" => 1], + ["version" => 4999995, "path" => "keep", "size" => 1], + ["version" => 4999994, "path" => "delete", "size" => 1], //next slice (60sec) starts at 4999990 keep one version every 10 secons - array("version" => 4999988, "path" => "keep", "size" => 1), - array("version" => 4999978, "path" => "keep", "size" => 1), + ["version" => 4999988, "path" => "keep", "size" => 1], + ["version" => 4999978, "path" => "keep", "size" => 1], //next slice (3600sec) start at 4999940 keep one version every 60 seconds // next slice (86400sec) start at 4996400 keep one version every 3600 seconds - array("version" => 4989200, "path" => "keep", "size" => 1), + ["version" => 4989200, "path" => "keep", "size" => 1], // next slice (2592000sec) start at 4913600 keep one version every 86400 seconds - array("version" => 4913600, "path" => "keep", "size" => 1), - array("version" => 4852800, "path" => "delete", "size" => 1), - array("version" => 4827201, "path" => "delete", "size" => 1), - array("version" => 4827200, "path" => "keep", "size" => 1), - array("version" => 4777201, "path" => "delete", "size" => 1), - array("version" => 4777501, "path" => "delete", "size" => 1), - array("version" => 4740000, "path" => "keep", "size" => 1), + ["version" => 4913600, "path" => "keep", "size" => 1], + ["version" => 4852800, "path" => "delete", "size" => 1], + ["version" => 4827201, "path" => "delete", "size" => 1], + ["version" => 4827200, "path" => "keep", "size" => 1], + ["version" => 4777201, "path" => "delete", "size" => 1], + ["version" => 4777501, "path" => "delete", "size" => 1], + ["version" => 4740000, "path" => "keep", "size" => 1], // final slice starts at 2408000 keep one version every 604800 secons - array("version" => 2408000, "path" => "keep", "size" => 1), - array("version" => 1803201, "path" => "delete", "size" => 1), - array("version" => 1803200, "path" => "keep", "size" => 1), - array("version" => 1800199, "path" => "delete", "size" => 1), - array("version" => 1800100, "path" => "delete", "size" => 1), - array("version" => 1198300, "path" => "keep", "size" => 1), - ), + ["version" => 2408000, "path" => "keep", "size" => 1], + ["version" => 1803201, "path" => "delete", "size" => 1], + ["version" => 1803200, "path" => "keep", "size" => 1], + ["version" => 1800199, "path" => "delete", "size" => 1], + ["version" => 1800100, "path" => "delete", "size" => 1], + ["version" => 1198300, "path" => "keep", "size" => 1], + ], 9 // size of all deleted files (every file has the size 1) - ), + ], - ); + ]; } public function testRename() { @@ -647,8 +647,8 @@ class VersioningTest extends \Test\TestCase { } public function testRestoreCrossStorage() { - $storage2 = new Temporary(array()); - \OC\Files\Filesystem::mount($storage2, array(), self::TEST_VERSIONS_USER . '/files/sub'); + $storage2 = new Temporary([]); + \OC\Files\Filesystem::mount($storage2, [], self::TEST_VERSIONS_USER . '/files/sub'); $this->doTestRestore(); } @@ -787,13 +787,13 @@ class VersioningTest extends \Test\TestCase { $this->assertEquals('test file', $this->rootView->file_get_contents($filePath)); $info1 = $this->rootView->getFileInfo($filePath); - $params = array(); + $params = []; $this->connectMockHooks('rollback', $params); $this->assertTrue(\OCA\Files_Versions\Storage::rollback('sub/test.txt', $t2, $this->user1)); - $expectedParams = array( + $expectedParams = [ 'path' => '/sub/test.txt', - ); + ]; $this->assertEquals($expectedParams['path'], $params['path']); $this->assertTrue(array_key_exists('revision', $params)); diff --git a/apps/provisioning_api/lib/AppInfo/Application.php b/apps/provisioning_api/lib/AppInfo/Application.php index 63ea0b5e76e..a2dfa5bac41 100644 --- a/apps/provisioning_api/lib/AppInfo/Application.php +++ b/apps/provisioning_api/lib/AppInfo/Application.php @@ -36,7 +36,7 @@ use OCP\Defaults; use OCP\Util; class Application extends App { - public function __construct(array $urlParams = array()) { + public function __construct(array $urlParams = []) { parent::__construct('provisioning_api', $urlParams); $container = $this->getContainer(); diff --git a/apps/provisioning_api/tests/Controller/AppsControllerTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php index 7c9de539c7c..e54025856fe 100644 --- a/apps/provisioning_api/tests/Controller/AppsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php @@ -101,7 +101,7 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase { $result = $this->api->getApps('disabled'); $data = $result->getData(); $apps = (new \OC_App)->listAllApps(); - $list = array(); + $list = []; foreach($apps as $app) { $list[] = $app['id']; } diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index 5416e686ee3..bb50786ee86 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -241,15 +241,15 @@ class GroupsControllerTest extends \Test\TestCase { $result = $this->api->getGroupsDetails($search, $limit, $offset); $this->assertEquals(['groups' => [ - Array( + [ 'id' => 'group1', 'displayname' => 'group1-name', 'usercount' => 123, 'disabled' => 11, 'canAdd' => true, 'canRemove' => true - ), - Array( + ], + [ 'id' => 'group2', 'displayname' => 'group2-name', 'usercount' => 123, @@ -257,7 +257,7 @@ class GroupsControllerTest extends \Test\TestCase { 'canAdd' => true, 'canRemove' => true - ) + ] ]], $result->getData()); } diff --git a/apps/provisioning_api/tests/TestCase.php b/apps/provisioning_api/tests/TestCase.php index 12580abd757..3d1310ca5d0 100644 --- a/apps/provisioning_api/tests/TestCase.php +++ b/apps/provisioning_api/tests/TestCase.php @@ -32,7 +32,7 @@ use OCP\IUserManager; abstract class TestCase extends \Test\TestCase { /** @var IUser[] */ - protected $users = array(); + protected $users = []; /** @var IUserManager */ protected $userManager; @@ -54,7 +54,7 @@ abstract class TestCase extends \Test\TestCase { * @return IUser[]|IUser */ protected function generateUsers($num = 1) { - $users = array(); + $users = []; for ($i = 0; $i < $num; $i++) { $user = $this->userManager->createUser($this->getUniqueID(), 'password'); $this->users[] = $user; diff --git a/apps/settings/lib/Controller/AdminSettingsController.php b/apps/settings/lib/Controller/AdminSettingsController.php index acc44501e64..e7b1a27a637 100644 --- a/apps/settings/lib/Controller/AdminSettingsController.php +++ b/apps/settings/lib/Controller/AdminSettingsController.php @@ -101,15 +101,15 @@ class AdminSettingsController extends Controller { $anchor = strtolower($sectionName); $anchor = str_replace(' ', '-', $anchor); - return array( + return [ 'anchor' => $anchor, 'section-name' => $sectionName, 'form' => $form - ); + ]; } - return array( + return [ 'form' => $form - ); + ]; }, $forms); $out = new Template('settings', 'settings/additional'); diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index 47067a9fcf5..fc92fe8c775 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -258,7 +258,7 @@ class AppSettingsController extends Controller { } // fix groups to be an array - $groups = array(); + $groups = []; if (is_string($appData['groups'])) { $groups = json_decode($appData['groups']); } diff --git a/apps/settings/lib/Controller/PersonalSettingsController.php b/apps/settings/lib/Controller/PersonalSettingsController.php index 18719a85652..12d8af3af17 100644 --- a/apps/settings/lib/Controller/PersonalSettingsController.php +++ b/apps/settings/lib/Controller/PersonalSettingsController.php @@ -94,15 +94,15 @@ class PersonalSettingsController extends Controller { $anchor = strtolower($sectionName); $anchor = str_replace(' ', '-', $anchor); - return array( + return [ 'anchor' => $anchor, 'section-name' => $sectionName, 'form' => $form - ); + ]; } - return array( + return [ 'form' => $form - ); + ]; }, $forms); $out = new Template('settings', 'settings/additional'); diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index cfbe35eb201..3f6bcd3a46c 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -226,7 +226,7 @@ class UsersController extends Controller { $languages = $this->l10nFactory->getLanguages(); /* FINAL DATA */ - $serverData = array(); + $serverData = []; // groups $serverData['groups'] = array_merge_recursive($adminGroup, [$disabledUsersGroup], $groups); // Various data diff --git a/apps/settings/lib/Middleware/SubadminMiddleware.php b/apps/settings/lib/Middleware/SubadminMiddleware.php index ab1b6b5c745..ffc507e50e0 100644 --- a/apps/settings/lib/Middleware/SubadminMiddleware.php +++ b/apps/settings/lib/Middleware/SubadminMiddleware.php @@ -82,7 +82,7 @@ class SubadminMiddleware extends Middleware { */ public function afterException($controller, $methodName, \Exception $exception) { if($exception instanceof NotAdminException) { - $response = new TemplateResponse('core', '403', array(), 'guest'); + $response = new TemplateResponse('core', '403', [], 'guest'); $response->setStatus(Http::STATUS_FORBIDDEN); return $response; } diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php index c8d9b3f8128..69363cdd08f 100644 --- a/apps/settings/lib/Settings/Personal/PersonalInfo.php +++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php @@ -220,7 +220,7 @@ class PersonalInfo implements ISettings { } return array_merge( - array('activelanguage' => $userLang), + ['activelanguage' => $userLang], $languages ); } diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index 46769434f42..5e59bfe353a 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -969,7 +969,7 @@ class CheckSetupControllerTest extends TestCase { $this->checker ->expects($this->once()) ->method('getResults') - ->willReturn(array ( 'core' => array ( 'EXTRA_FILE' => array('/testfile' => array()), 'INVALID_HASH' => array ( '/.idea/workspace.xml' => array ( 'expected' => 'f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216', 'current' => 'ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094', ), '/lib/private/integritycheck/checker.php' => array ( 'expected' => 'c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea', 'current' => '88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585', ), '/settings/controller/checksetupcontroller.php' => array ( 'expected' => '3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4', 'current' => '09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a', ), ), ), 'bookmarks' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'dav' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'encryption' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'external' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'federation' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_antivirus' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_drop' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_external' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_pdfviewer' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_sharing' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_trashbin' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_versions' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_videoviewer' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'firstrunwizard' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'gitsmart' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'logreader' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature could not get verified.', ), ), 'password_policy' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'provisioning_api' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'sketch' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'threatblock' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'two_factor_auth' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'user_ldap' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'user_shibboleth' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), )); + ->willReturn( [ 'core' => [ 'EXTRA_FILE' => ['/testfile' => []], 'INVALID_HASH' => [ '/.idea/workspace.xml' => [ 'expected' => 'f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216', 'current' => 'ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094', ], '/lib/private/integritycheck/checker.php' => [ 'expected' => 'c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea', 'current' => '88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585', ], '/settings/controller/checksetupcontroller.php' => [ 'expected' => '3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4', 'current' => '09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a', ], ], ], 'bookmarks' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'dav' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'encryption' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'external' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'federation' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_antivirus' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_drop' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_external' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_pdfviewer' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_sharing' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_trashbin' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_versions' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_videoviewer' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'firstrunwizard' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'gitsmart' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'logreader' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature could not get verified.', ], ], 'password_policy' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'provisioning_api' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'sketch' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'threatblock' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'two_factor_auth' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'user_ldap' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'user_shibboleth' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], ]); $expected = new DataDisplayResponse( 'Technical information diff --git a/apps/settings/tests/Middleware/SubadminMiddlewareTest.php b/apps/settings/tests/Middleware/SubadminMiddlewareTest.php index 8b40f002c32..ad68d3b615e 100644 --- a/apps/settings/tests/Middleware/SubadminMiddlewareTest.php +++ b/apps/settings/tests/Middleware/SubadminMiddlewareTest.php @@ -105,7 +105,7 @@ class SubadminMiddlewareTest extends \Test\TestCase { } public function testAfterNotAdminException() { - $expectedResponse = new TemplateResponse('core', '403', array(), 'guest'); + $expectedResponse = new TemplateResponse('core', '403', [], 'guest'); $expectedResponse->setStatus(403); $this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new NotAdminException(''))); } @@ -114,7 +114,7 @@ class SubadminMiddlewareTest extends \Test\TestCase { public function testAfterRegularException() { $this->expectException(\Exception::class); - $expectedResponse = new TemplateResponse('core', '403', array(), 'guest'); + $expectedResponse = new TemplateResponse('core', '403', [], 'guest'); $expectedResponse->setStatus(403); $this->subadminMiddleware->afterException($this->controller, 'foo', new \Exception()); } diff --git a/apps/sharebymail/lib/AppInfo/Application.php b/apps/sharebymail/lib/AppInfo/Application.php index c6546860028..e24743aa40b 100644 --- a/apps/sharebymail/lib/AppInfo/Application.php +++ b/apps/sharebymail/lib/AppInfo/Application.php @@ -33,7 +33,7 @@ use OCP\Util; class Application extends App { - public function __construct(array $urlParams = array()) { + public function __construct(array $urlParams = []) { parent::__construct('sharebymail', $urlParams); $settingsManager = \OC::$server->query(Settings\SettingsManager::class); diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index d2465a5797b..9f0362f1908 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -180,7 +180,7 @@ class ShareByMailProvider implements IShareProvider { $alreadyShared = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_EMAIL, $share->getNode(), 1, 0); if (!empty($alreadyShared)) { $message = 'Sharing %1$s failed, this item is already shared with %2$s'; - $message_t = $this->l->t('Sharing %1$s failed, this item is already shared with %2$s', array($share->getNode()->getName(), $shareWith)); + $message_t = $this->l->t('Sharing %1$s failed, this item is already shared with %2$s', [$share->getNode()->getName(), $shareWith]); $this->logger->debug(sprintf($message, $share->getNode()->getName(), $shareWith), ['app' => 'Federated File Sharing']); throw new \Exception($message_t); } @@ -416,7 +416,7 @@ class ShareByMailProvider implements IShareProvider { 'shareWith' => $shareWith, ]); - $emailTemplate->setSubject($this->l->t('%1$s shared »%2$s« with you', array($initiatorDisplayName, $filename))); + $emailTemplate->setSubject($this->l->t('%1$s shared »%2$s« with you', [$initiatorDisplayName, $filename])); $emailTemplate->addHeader(); $emailTemplate->addHeading($this->l->t('%1$s shared »%2$s« with you', [$initiatorDisplayName, $filename]), false); $text = $this->l->t('%1$s shared »%2$s« with you.', [$initiatorDisplayName, $filename]); diff --git a/apps/testing/lib/AppInfo/Application.php b/apps/testing/lib/AppInfo/Application.php index da34d419d32..79ee279170a 100644 --- a/apps/testing/lib/AppInfo/Application.php +++ b/apps/testing/lib/AppInfo/Application.php @@ -27,7 +27,7 @@ use OCA\Testing\AlternativeHomeUserBackend; use OCP\AppFramework\App; class Application extends App { - public function __construct (array $urlParams = array()) { + public function __construct (array $urlParams = []) { $appName = 'testing'; parent::__construct($appName, $urlParams); diff --git a/apps/theming/appinfo/routes.php b/apps/theming/appinfo/routes.php index 30dcf3d5a4f..c61f776ac09 100644 --- a/apps/theming/appinfo/routes.php +++ b/apps/theming/appinfo/routes.php @@ -62,25 +62,25 @@ return ['routes' => [ 'name' => 'Theming#getManifest', 'url' => '/manifest/{app}', 'verb' => 'GET', - 'defaults' => array('app' => 'core') + 'defaults' => ['app' => 'core'] ], [ 'name' => 'Icon#getFavicon', 'url' => '/favicon/{app}', 'verb' => 'GET', - 'defaults' => array('app' => 'core'), + 'defaults' => ['app' => 'core'], ], [ 'name' => 'Icon#getTouchIcon', 'url' => '/icon/{app}', 'verb' => 'GET', - 'defaults' => array('app' => 'core'), + 'defaults' => ['app' => 'core'], ], [ 'name' => 'Icon#getThemedIcon', 'url' => '/img/{app}/{image}', 'verb' => 'GET', - 'requirements' => array('image' => '.+') + 'requirements' => ['image' => '.+'] ], ]]; diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php index 9e4efb6a4dc..0a60d9f38f8 100644 --- a/apps/theming/lib/Util.php +++ b/apps/theming/lib/Util.php @@ -142,7 +142,7 @@ class Util { * @return string|ISimpleFile path to app icon / file of logo */ public function getAppIcon($app) { - $app = str_replace(array('\0', '/', '\\', '..'), '', $app); + $app = str_replace(['\0', '/', '\\', '..'], '', $app); try { $appPath = $this->appManager->getAppPath($app); $icon = $appPath . '/img/' . $app . '.svg'; @@ -173,8 +173,8 @@ class Util { * @return string|false absolute path to image */ public function getAppImage($app, $image) { - $app = str_replace(array('\0', '/', '\\', '..'), '', $app); - $image = str_replace(array('\0', '\\', '..'), '', $image); + $app = str_replace(['\0', '/', '\\', '..'], '', $app); + $image = str_replace(['\0', '\\', '..'], '', $image); if ($app === "core") { $icon = \OC::$SERVERROOT . '/core/img/' . $image; if (file_exists($icon)) { 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); |