Use the short array syntax, everywhere

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2020-03-26 09:30:18 +01:00
parent 62403d0932
commit b80ebc9674
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
454 changed files with 4214 additions and 4214 deletions

View File

@ -57,7 +57,7 @@ class AccessibilityProvider {
} }
public function getThemes() { public function getThemes() {
return array( return [
[ [
'id' => 'dark', 'id' => 'dark',
'img' => $this->urlGenerator->imagePath($this->appName, 'theme-dark.jpg'), 'img' => $this->urlGenerator->imagePath($this->appName, 'theme-dark.jpg'),
@ -65,7 +65,7 @@ class AccessibilityProvider {
'enableLabel' => $this->l->t('Enable dark theme'), '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.') '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() { public function getHighContrast() {
@ -79,7 +79,7 @@ class AccessibilityProvider {
} }
public function getFonts() { public function getFonts() {
return array( return [
[ [
'id' => 'fontdyslexic', 'id' => 'fontdyslexic',
'img' => $this->urlGenerator->imagePath($this->appName, 'font-opendyslexic.jpg'), 'img' => $this->urlGenerator->imagePath($this->appName, 'font-opendyslexic.jpg'),
@ -87,7 +87,7 @@ class AccessibilityProvider {
'enableLabel' => $this->l->t('Enable dyslexia font'), '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.') 'text' => $this->l->t('OpenDyslexic is a free typeface/font designed to mitigate some of the common reading errors caused by dyslexia.')
] ]
); ];
} }
} }

View File

@ -113,7 +113,7 @@ class ConfigController extends OCSController {
} }
$themes = $this->accessibilityProvider->getThemes(); $themes = $this->accessibilityProvider->getThemes();
$highcontrast = array($this->accessibilityProvider->getHighContrast()); $highcontrast = [$this->accessibilityProvider->getHighContrast()];
$fonts = $this->accessibilityProvider->getFonts(); $fonts = $this->accessibilityProvider->getFonts();
$availableOptions = array_map(function($option) { $availableOptions = array_map(function($option) {

View File

@ -290,7 +290,7 @@ class RequestHandlerController extends Controller {
\OCP\Util::emitHook( \OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server', '\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName', 'preLoginNameUsedAsUserName',
array('uid' => &$uid) ['uid' => &$uid]
); );
$this->logger->debug('shareWith after, ' . $uid, ['app' => $this->appName]); $this->logger->debug('shareWith after, ' . $uid, ['app' => $this->appName]);

View File

@ -44,7 +44,7 @@ class Application extends App {
const APP_ID = 'comments'; const APP_ID = 'comments';
public function __construct (array $urlParams = array()) { public function __construct (array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams); parent::__construct(self::APP_ID, $urlParams);
$container = $this->getContainer(); $container = $this->getContainer();

View File

@ -69,10 +69,10 @@ $principalCollection->disableListing = !$debugging; // Disable listing
$addressBookRoot = new CalendarRoot($principalBackend, $calDavBackend); $addressBookRoot = new CalendarRoot($principalBackend, $calDavBackend);
$addressBookRoot->disableListing = !$debugging; // Disable listing $addressBookRoot->disableListing = !$debugging; // Disable listing
$nodes = array( $nodes = [
$principalCollection, $principalCollection,
$addressBookRoot, $addressBookRoot,
); ];
// Fire up server // Fire up server
$server = new \Sabre\DAV\Server($nodes); $server = new \Sabre\DAV\Server($nodes);

View File

@ -69,10 +69,10 @@ $pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager
$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager); $addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager);
$addressBookRoot->disableListing = !$debugging; // Disable listing $addressBookRoot->disableListing = !$debugging; // Disable listing
$nodes = array( $nodes = [
$principalCollection, $principalCollection,
$addressBookRoot, $addressBookRoot,
); ];
// Fire up server // Fire up server
$server = new \Sabre\DAV\Server($nodes); $server = new \Sabre\DAV\Server($nodes);

View File

@ -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 // FIXME: should not add storage wrappers outside of preSetup, need to find a better way
$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) { \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); \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);

View File

@ -1944,7 +1944,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
} }
} }
$valuesToInsert = array(); $valuesToInsert = [];
$query = $this->db->getQueryBuilder(); $query = $this->db->getQueryBuilder();

View File

@ -237,13 +237,13 @@ class IMipPlugin extends SabreIMipPlugin {
break; break;
} }
$data = array( $data = [
'attendee_name' => (string)$meetingAttendeeName ?: $defaultVal, 'attendee_name' => (string)$meetingAttendeeName ?: $defaultVal,
'invitee_name' => (string)$meetingInviteeName ?: $defaultVal, 'invitee_name' => (string)$meetingInviteeName ?: $defaultVal,
'meeting_title' => (string)$meetingTitle ?: $defaultVal, 'meeting_title' => (string)$meetingTitle ?: $defaultVal,
'meeting_description' => (string)$meetingDescription ?: $defaultVal, 'meeting_description' => (string)$meetingDescription ?: $defaultVal,
'meeting_url' => (string)$meetingUrl ?: $defaultVal, 'meeting_url' => (string)$meetingUrl ?: $defaultVal,
); ];
$fromEMail = \OCP\Util::getDefaultEmailAddress('invitations-noreply'); $fromEMail = \OCP\Util::getDefaultEmailAddress('invitations-noreply');
$fromName = $l10n->t('%1$s via %2$s', [$senderName, $this->defaults->getName()]); $fromName = $l10n->t('%1$s via %2$s', [$senderName, $this->defaults->getName()]);

View File

@ -74,9 +74,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
private $sharingBackend; private $sharingBackend;
/** @var array properties to index */ /** @var array properties to index */
public static $indexProperties = array( public static $indexProperties = [
'BDAY', 'UID', 'N', 'FN', 'TITLE', 'ROLE', 'NOTE', 'NICKNAME', '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 * @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 * - '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 * @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(); $query = $this->db->getQueryBuilder();
$query2 = $this->db->getQueryBuilder(); $query2 = $this->db->getQueryBuilder();

View File

@ -74,7 +74,7 @@ class AppEnabledPlugin extends ServerPlugin {
public function initialize(\Sabre\DAV\Server $server) { public function initialize(\Sabre\DAV\Server $server) {
$this->server = $server; $this->server = $server;
$this->server->on('beforeMethod', array($this, 'checkAppEnabled'), 30); $this->server->on('beforeMethod', [$this, 'checkAppEnabled'], 30);
} }
/** /**

View File

@ -67,7 +67,7 @@ class CommentPropertiesPlugin extends ServerPlugin {
*/ */
function initialize(\Sabre\DAV\Server $server) { function initialize(\Sabre\DAV\Server $server) {
$this->server = $server; $this->server = $server;
$this->server->on('propFind', array($this, 'handleGetProperties')); $this->server->on('propFind', [$this, 'handleGetProperties']);
} }
/** /**

View File

@ -267,7 +267,7 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node
throw new Locked(); throw new Locked();
} }
$nodes = array(); $nodes = [];
foreach ($folderContent as $info) { foreach ($folderContent as $info) {
$node = $this->getChild($info->getName(), $info); $node = $this->getChild($info->getName(), $info);
$nodes[] = $node; $nodes[] = $node;
@ -336,13 +336,13 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node
} else { } else {
$free = $storageInfo['free']; $free = $storageInfo['free'];
} }
$this->quotaInfo = array( $this->quotaInfo = [
$storageInfo['used'], $storageInfo['used'],
$free $free
); ];
return $this->quotaInfo; return $this->quotaInfo;
} catch (\OCP\Files\StorageNotAvailableException $e) { } catch (\OCP\Files\StorageNotAvailableException $e) {
return array(0, 0); return [0, 0];
} }
} }

View File

@ -103,7 +103,7 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
*/ */
public function initialize(\Sabre\DAV\Server $server) { public function initialize(\Sabre\DAV\Server $server) {
$server->on('exception', array($this, 'logException'), 10); $server->on('exception', [$this, 'logException'], 10);
} }
/** /**

View File

@ -359,20 +359,20 @@ class File extends Node implements IFile {
$run = true; $run = true;
if (!$exists) { 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_path => $hookPath,
\OC\Files\Filesystem::signal_param_run => &$run, \OC\Files\Filesystem::signal_param_run => &$run,
)); ]);
} else { } 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_path => $hookPath,
\OC\Files\Filesystem::signal_param_run => &$run, \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_path => $hookPath,
\OC\Files\Filesystem::signal_param_run => &$run, \OC\Files\Filesystem::signal_param_run => &$run,
)); ]);
return $run; return $run;
} }
@ -385,17 +385,17 @@ class File extends Node implements IFile {
} }
$hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path)); $hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
if (!$exists) { 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 \OC\Files\Filesystem::signal_param_path => $hookPath
)); ]);
} else { } 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\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 \OC\Files\Filesystem::signal_param_path => $hookPath
)); ]);
} }
/** /**

View File

@ -173,12 +173,12 @@ class FilesPlugin extends ServerPlugin {
$server->protectedProperties = array_diff($server->protectedProperties, $allowedProperties); $server->protectedProperties = array_diff($server->protectedProperties, $allowedProperties);
$this->server = $server; $this->server = $server;
$this->server->on('propFind', array($this, 'handleGetProperties')); $this->server->on('propFind', [$this, 'handleGetProperties']);
$this->server->on('propPatch', array($this, 'handleUpdateProperties')); $this->server->on('propPatch', [$this, 'handleUpdateProperties']);
$this->server->on('afterBind', array($this, 'sendFileIdHeader')); $this->server->on('afterBind', [$this, 'sendFileIdHeader']);
$this->server->on('afterWriteContent', array($this, 'sendFileIdHeader')); $this->server->on('afterWriteContent', [$this, 'sendFileIdHeader']);
$this->server->on('afterMethod:GET', [$this,'httpGet']); $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) { $this->server->on('afterResponse', function($request, ResponseInterface $response) {
$body = $response->getBody(); $body = $response->getBody();
if (is_resource($body)) { if (is_resource($body)) {

View File

@ -154,7 +154,7 @@ class FilesReportPlugin extends ServerPlugin {
$server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc'; $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
$this->server = $server; $this->server = $server;
$this->server->on('report', array($this, 'onReport')); $this->server->on('report', [$this, 'onReport']);
} }
/** /**

View File

@ -67,7 +67,7 @@ class MaintenancePlugin extends ServerPlugin {
*/ */
public function initialize(\Sabre\DAV\Server $server) { public function initialize(\Sabre\DAV\Server $server) {
$this->server = $server; $this->server = $server;
$this->server->on('beforeMethod', array($this, 'checkMaintenanceMode'), 1); $this->server->on('beforeMethod', [$this, 'checkMaintenanceMode'], 1);
} }
/** /**

View File

@ -200,15 +200,15 @@ abstract class Node implements \Sabre\DAV\INode {
* @return int file id of updated file or -1 on failure * @return int file id of updated file or -1 on failure
*/ */
public function setETag($etag) { 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) { 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) { public function setUploadTime(int $time) {
return $this->fileView->putFileInfo($this->path, array('upload_time' => $time)); return $this->fileView->putFileInfo($this->path, ['upload_time' => $time]);
} }
/** /**

View File

@ -107,7 +107,7 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
$server->protectedProperties[] = self::SHAREES_PROPERTYNAME; $server->protectedProperties[] = self::SHAREES_PROPERTYNAME;
$this->server = $server; $this->server = $server;
$this->server->on('propFind', array($this, 'handleGetProperties')); $this->server->on('propFind', [$this, 'handleGetProperties']);
} }
private function getShare(\OCP\Files\Node $node): array { private function getShare(\OCP\Files\Node $node): array {

View File

@ -98,7 +98,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin
$this->tree = $tree; $this->tree = $tree;
$this->tagManager = $tagManager; $this->tagManager = $tagManager;
$this->tagger = null; $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; $server->xml->elementMap[self::TAGS_PROPERTYNAME] = TagList::class;
$this->server = $server; $this->server = $server;
$this->server->on('propFind', array($this, 'handleGetProperties')); $this->server->on('propFind', [$this, 'handleGetProperties']);
$this->server->on('propPatch', array($this, 'handleUpdateProperties')); $this->server->on('propPatch', [$this, 'handleUpdateProperties']);
} }
/** /**
@ -151,7 +151,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin
unset($tags[$favPos]); 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])) { if (isset($this->cachedTags[$fileId])) {
return $this->cachedTags[$fileId]; return $this->cachedTags[$fileId];
} else { } else {
$tags = $this->getTagger()->getTagsForObjects(array($fileId)); $tags = $this->getTagger()->getTagsForObjects([$fileId]);
if ($tags !== false) { if ($tags !== false) {
if (empty($tags)) { if (empty($tags)) {
return array(); return [];
} }
return current($tags); return current($tags);
} }
@ -232,7 +232,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin
$tags = $this->getTagger()->getTagsForObjects($fileIds); $tags = $this->getTagger()->getTagsForObjects($fileIds);
if ($tags === false) { if ($tags === false) {
// the tags API returns false on error... // the tags API returns false on error...
$tags = array(); $tags = [];
} }
$this->cachedTags = $this->cachedTags + $tags; $this->cachedTags = $this->cachedTags + $tags;

View File

@ -48,7 +48,7 @@ class BrowserErrorPagePlugin extends ServerPlugin {
*/ */
function initialize(Server $server) { function initialize(Server $server) {
$this->server = $server; $this->server = $server;
$server->on('exception', array($this, 'logException'), 1000); $server->on('exception', [$this, 'logException'], 1000);
} }
/** /**

View File

@ -88,7 +88,7 @@ class RemoveOrphanEventsAndContacts implements IRepairStep {
$result = $qb->execute(); $result = $qb->execute();
$orphanItems = array(); $orphanItems = [];
while ($row = $result->fetch()) { while ($row = $result->fetch()) {
$orphanItems[] = (int) $row['id']; $orphanItems[] = (int) $row['id'];
} }

View File

@ -107,8 +107,8 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
$server->protectedProperties[] = self::ID_PROPERTYNAME; $server->protectedProperties[] = self::ID_PROPERTYNAME;
$server->on('propFind', array($this, 'handleGetProperties')); $server->on('propFind', [$this, 'handleGetProperties']);
$server->on('propPatch', array($this, 'handleUpdateProperties')); $server->on('propPatch', [$this, 'handleUpdateProperties']);
$server->on('method:POST', [$this, 'httpPost']); $server->on('method:POST', [$this, 'httpPost']);
$this->server = $server; $this->server = $server;

View File

@ -130,7 +130,7 @@ class CalDavBackendTest extends AbstractCalDavBackend {
$l10n $l10n
->expects($this->any()) ->expects($this->any())
->method('t') ->method('t')
->willReturnCallback(function ($text, $parameters = array()) { ->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters); return vsprintf($text, $parameters);
}); });

View File

@ -53,7 +53,7 @@ class CalendarTest extends TestCase {
$this->l10n $this->l10n
->expects($this->any()) ->expects($this->any())
->method('t') ->method('t')
->willReturnCallback(function ($text, $parameters = array()) { ->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters); return vsprintf($text, $parameters);
}); });
} }

View File

@ -97,9 +97,9 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
' WHERE `userid` = ?' ' WHERE `userid` = ?'
); );
$deleteStatement->execute( $deleteStatement->execute(
array( [
$this->user->getUID(), $this->user->getUID(),
) ]
); );
$deleteStatement->closeCursor(); $deleteStatement->closeCursor();
} }
@ -121,10 +121,10 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
private function applyDefaultProps($path = '/dummypath') { private function applyDefaultProps($path = '/dummypath') {
// properties to set // properties to set
$propPatch = new \Sabre\DAV\PropPatch(array( $propPatch = new \Sabre\DAV\PropPatch([
'customprop' => 'value1', 'customprop' => 'value1',
'customprop2' => 'value2', 'customprop2' => 'value2',
)); ]);
$this->plugin->propPatch( $this->plugin->propPatch(
$path, $path,
@ -146,11 +146,11 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
public function testPropFindMissingFileSoftFail() { public function testPropFindMissingFileSoftFail() {
$propFind = new \Sabre\DAV\PropFind( $propFind = new \Sabre\DAV\PropFind(
'/dummypath', '/dummypath',
array( [
'customprop', 'customprop',
'customprop2', 'customprop2',
'unsetprop', 'unsetprop',
), ],
0 0
); );
@ -176,11 +176,11 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
$propFind = new \Sabre\DAV\PropFind( $propFind = new \Sabre\DAV\PropFind(
'/dummypath', '/dummypath',
array( [
'customprop', 'customprop',
'customprop2', 'customprop2',
'unsetprop', 'unsetprop',
), ],
0 0
); );
@ -191,7 +191,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
$this->assertEquals('value1', $propFind->get('customprop')); $this->assertEquals('value1', $propFind->get('customprop'));
$this->assertEquals('value2', $propFind->get('customprop2')); $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');
$this->applyDefaultProps('/dummypath/test.txt'); $this->applyDefaultProps('/dummypath/test.txt');
$propNames = array( $propNames = [
'customprop', 'customprop',
'customprop2', 'customprop2',
'unsetprop', 'unsetprop',
); ];
$propFindRoot = new \Sabre\DAV\PropFind( $propFindRoot = new \Sabre\DAV\PropFind(
'/dummypath', '/dummypath',
@ -234,11 +234,11 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
$this->assertEquals('value1', $propFindRoot->get('customprop')); $this->assertEquals('value1', $propFindRoot->get('customprop'));
$this->assertEquals('value2', $propFindRoot->get('customprop2')); $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('value1', $propFindSub->get('customprop'));
$this->assertEquals('value2', $propFindSub->get('customprop2')); $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() { public function testDeleteProperty() {
$this->applyDefaultProps(); $this->applyDefaultProps();
$propPatch = new \Sabre\DAV\PropPatch(array( $propPatch = new \Sabre\DAV\PropPatch([
'customprop' => null, 'customprop' => null,
)); ]);
$this->plugin->propPatch( $this->plugin->propPatch(
'/dummypath', '/dummypath',

View File

@ -201,7 +201,7 @@ class DirectoryTest extends \Test\TestCase {
$this->view->expects($this->once()) $this->view->expects($this->once())
->method('getDirectoryContent') ->method('getDirectoryContent')
->with('') ->with('')
->willReturn(array($info1, $info2)); ->willReturn([$info1, $info2]);
$this->view->expects($this->any()) $this->view->expects($this->any())
->method('getRelativePath') ->method('getRelativePath')

View File

@ -202,9 +202,9 @@ class FileTest extends TestCase {
->method('getRelativePath') ->method('getRelativePath')
->willReturnArgument(0); ->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 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@ -631,10 +631,10 @@ class FileTest extends TestCase {
} }
public static function cancellingHook($params) { public static function cancellingHook($params) {
self::$hookCalls[] = array( self::$hookCalls[] = [
'signal' => Filesystem::signal_post_create, 'signal' => Filesystem::signal_post_create,
'params' => $params 'params' => $params
); ];
} }
/** /**
@ -683,9 +683,9 @@ class FileTest extends TestCase {
$_SERVER['CONTENT_LENGTH'] = 123456; $_SERVER['CONTENT_LENGTH'] = 123456;
$_SERVER['REQUEST_METHOD'] = 'PUT'; $_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 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $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 // simulate situation where the target file is locked
$view->lockFile('/test.txt', ILockingProvider::LOCK_EXCLUSIVE); $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 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@ -790,9 +790,9 @@ class FileTest extends TestCase {
->method('getRelativePath') ->method('getRelativePath')
->willReturnArgument(0); ->willReturnArgument(0);
$info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, array( $info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, [
'permissions' => \OCP\Constants::PERMISSION_ALL 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
// action // action
@ -829,9 +829,9 @@ class FileTest extends TestCase {
->method('getRelativePath') ->method('getRelativePath')
->willReturnArgument(0); ->willReturnArgument(0);
$info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, array( $info = new \OC\Files\FileInfo('/*', $this->getMockStorage(), null, [
'permissions' => \OCP\Constants::PERMISSION_ALL 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
$file->setName('/super*star.txt'); $file->setName('/super*star.txt');
} }
@ -856,9 +856,9 @@ class FileTest extends TestCase {
$_SERVER['CONTENT_LENGTH'] = 12345; $_SERVER['CONTENT_LENGTH'] = 12345;
$_SERVER['REQUEST_METHOD'] = 'PUT'; $_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 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@ -890,9 +890,9 @@ class FileTest extends TestCase {
->method('unlink') ->method('unlink')
->willReturn(true); ->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 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@ -908,9 +908,9 @@ class FileTest extends TestCase {
$view = $this->getMockBuilder(View::class) $view = $this->getMockBuilder(View::class)
->getMock(); ->getMock();
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
'permissions' => 0 'permissions' => 0
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@ -931,9 +931,9 @@ class FileTest extends TestCase {
->method('unlink') ->method('unlink')
->willReturn(false); ->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 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@ -954,9 +954,9 @@ class FileTest extends TestCase {
->method('unlink') ->method('unlink')
->willThrowException(new ForbiddenException('', true)); ->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 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@ -1122,9 +1122,9 @@ class FileTest extends TestCase {
->method('fopen') ->method('fopen')
->willReturn(false); ->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 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);
@ -1142,9 +1142,9 @@ class FileTest extends TestCase {
->method('fopen') ->method('fopen')
->willThrowException(new ForbiddenException('', true)); ->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 'permissions' => \OCP\Constants::PERMISSION_ALL
), null); ], null);
$file = new \OCA\DAV\Connector\Sabre\File($view, $info); $file = new \OCA\DAV\Connector\Sabre\File($view, $info);

View File

@ -181,7 +181,7 @@ class FilesPluginTest extends TestCase {
$propFind = new PropFind( $propFind = new PropFind(
'/dummyPath', '/dummyPath',
array( [
self::GETETAG_PROPERTYNAME, self::GETETAG_PROPERTYNAME,
self::FILEID_PROPERTYNAME, self::FILEID_PROPERTYNAME,
self::INTERNAL_FILEID_PROPERTYNAME, self::INTERNAL_FILEID_PROPERTYNAME,
@ -191,7 +191,7 @@ class FilesPluginTest extends TestCase {
self::OWNER_ID_PROPERTYNAME, self::OWNER_ID_PROPERTYNAME,
self::OWNER_DISPLAY_NAME_PROPERTYNAME, self::OWNER_DISPLAY_NAME_PROPERTYNAME,
self::DATA_FINGERPRINT_PROPERTYNAME, self::DATA_FINGERPRINT_PROPERTYNAME,
), ],
0 0
); );
@ -208,7 +208,7 @@ class FilesPluginTest extends TestCase {
$node->expects($this->once()) $node->expects($this->once())
->method('getDirectDownload') ->method('getDirectDownload')
->willReturn(array('url' => 'http://example.com/')); ->willReturn(['url' => 'http://example.com/']);
$node->expects($this->exactly(2)) $node->expects($this->exactly(2))
->method('getOwner') ->method('getOwner')
->willReturn($user); ->willReturn($user);
@ -236,9 +236,9 @@ class FilesPluginTest extends TestCase {
$propFind = new PropFind( $propFind = new PropFind(
'/dummyPath', '/dummyPath',
array( [
self::DOWNLOADURL_PROPERTYNAME, self::DOWNLOADURL_PROPERTYNAME,
), ],
0 0
); );
@ -293,14 +293,14 @@ class FilesPluginTest extends TestCase {
$propFind = new PropFind( $propFind = new PropFind(
'/dummyPath', '/dummyPath',
array( [
self::GETETAG_PROPERTYNAME, self::GETETAG_PROPERTYNAME,
self::FILEID_PROPERTYNAME, self::FILEID_PROPERTYNAME,
self::SIZE_PROPERTYNAME, self::SIZE_PROPERTYNAME,
self::PERMISSIONS_PROPERTYNAME, self::PERMISSIONS_PROPERTYNAME,
self::DOWNLOADURL_PROPERTYNAME, self::DOWNLOADURL_PROPERTYNAME,
self::DATA_FINGERPRINT_PROPERTYNAME, self::DATA_FINGERPRINT_PROPERTYNAME,
), ],
0 0
); );
@ -405,10 +405,10 @@ class FilesPluginTest extends TestCase {
->willReturn(true); ->willReturn(true);
// properties to set // properties to set
$propPatch = new PropPatch(array( $propPatch = new PropPatch([
self::GETETAG_PROPERTYNAME => 'newetag', self::GETETAG_PROPERTYNAME => 'newetag',
self::LASTMODIFIED_PROPERTYNAME => $testDate self::LASTMODIFIED_PROPERTYNAME => $testDate
)); ]);
$this->plugin->handleUpdateProperties( $this->plugin->handleUpdateProperties(
'/dummypath', '/dummypath',
@ -425,14 +425,14 @@ class FilesPluginTest extends TestCase {
} }
public function testUpdatePropsForbidden() { public function testUpdatePropsForbidden() {
$propPatch = new PropPatch(array( $propPatch = new PropPatch([
self::OWNER_ID_PROPERTYNAME => 'user2', self::OWNER_ID_PROPERTYNAME => 'user2',
self::OWNER_DISPLAY_NAME_PROPERTYNAME => 'User Two', self::OWNER_DISPLAY_NAME_PROPERTYNAME => 'User Two',
self::FILEID_PROPERTYNAME => 12345, self::FILEID_PROPERTYNAME => 12345,
self::PERMISSIONS_PROPERTYNAME => 'C', self::PERMISSIONS_PROPERTYNAME => 'C',
self::SIZE_PROPERTYNAME => 123, self::SIZE_PROPERTYNAME => 123,
self::DOWNLOADURL_PROPERTYNAME => 'http://example.com/', self::DOWNLOADURL_PROPERTYNAME => 'http://example.com/',
)); ]);
$this->plugin->handleUpdateProperties( $this->plugin->handleUpdateProperties(
'/dummypath', '/dummypath',
@ -588,9 +588,9 @@ class FilesPluginTest extends TestCase {
$propFind = new PropFind( $propFind = new PropFind(
'/dummyPath', '/dummyPath',
array( [
self::HAS_PREVIEW_PROPERTYNAME self::HAS_PREVIEW_PROPERTYNAME
), ],
0 0
); );

View File

@ -42,19 +42,19 @@ use OCP\Share\IShare;
*/ */
class NodeTest extends \Test\TestCase { class NodeTest extends \Test\TestCase {
public function davPermissionsProvider() { public function davPermissionsProvider() {
return array( return [
array(\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RGDNVW'), [\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RGDNVW'],
array(\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RGDNVCK'), [\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RGDNVCK'],
array(\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRGDNVW'), [\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRGDNVW'],
array(\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMGDNVW'), [\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMGDNVW'],
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SGDNVW'), [\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'), [\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'), [\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'), [\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'), [\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'), [\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'), [\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) { public function testDavPermissions($permissions, $type, $shared, $mounted, $expected) {
$info = $this->getMockBuilder(FileInfo::class) $info = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(array('getPermissions', 'isShared', 'isMounted', 'getType')) ->setMethods(['getPermissions', 'isShared', 'isMounted', 'getType'])
->getMock(); ->getMock();
$info->expects($this->any()) $info->expects($this->any())
->method('getPermissions') ->method('getPermissions')

View File

@ -201,72 +201,72 @@ class ObjectTreeTest extends \Test\TestCase {
} }
function nodeForPathProvider() { function nodeForPathProvider() {
return array( return [
// regular file // regular file
array( [
'regularfile.txt', 'regularfile.txt',
'regularfile.txt', 'regularfile.txt',
'regularfile.txt', 'regularfile.txt',
'file', 'file',
false false
), ],
// regular directory // regular directory
array( [
'regulardir', 'regulardir',
'regulardir', 'regulardir',
'regulardir', 'regulardir',
'dir', 'dir',
false false
), ],
// regular file with chunking // regular file with chunking
array( [
'regularfile.txt', 'regularfile.txt',
'regularfile.txt', 'regularfile.txt',
'regularfile.txt', 'regularfile.txt',
'file', 'file',
true true
), ],
// regular directory with chunking // regular directory with chunking
array( [
'regulardir', 'regulardir',
'regulardir', 'regulardir',
'regulardir', 'regulardir',
'dir', 'dir',
true true
), ],
// file with chunky file name // file with chunky file name
array( [
'regularfile.txt-chunking-123566789-10-1', 'regularfile.txt-chunking-123566789-10-1',
'regularfile.txt', 'regularfile.txt',
'regularfile.txt', 'regularfile.txt',
'file', 'file',
true true
), ],
// regular file in subdir // regular file in subdir
array( [
'subdir/regularfile.txt', 'subdir/regularfile.txt',
'subdir/regularfile.txt', 'subdir/regularfile.txt',
'regularfile.txt', 'regularfile.txt',
'file', 'file',
false false
), ],
// regular directory in subdir // regular directory in subdir
array( [
'subdir/regulardir', 'subdir/regulardir',
'subdir/regulardir', 'subdir/regulardir',
'regulardir', 'regulardir',
'dir', 'dir',
false false
), ],
// file with chunky file name in subdir // file with chunky file name in subdir
array( [
'subdir/regularfile.txt-chunking-123566789-10-1', 'subdir/regularfile.txt-chunking-123566789-10-1',
'subdir/regularfile.txt', 'subdir/regularfile.txt',
'regularfile.txt', 'regularfile.txt',
'file', 'file',
true true
), ],
); ];
} }

View File

@ -410,7 +410,7 @@ class PrincipalTest extends TestCase {
} }
public function testUpdatePrincipal() { 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() { public function testSearchPrincipalsWithEmptySearchProperties() {

View File

@ -112,30 +112,30 @@ class QuotaPluginTest extends TestCase {
} }
public function quotaOkayProvider() { public function quotaOkayProvider() {
return array( return [
array(1024, array()), [1024, []],
array(1024, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), [1024, ['X-EXPECTED-ENTITY-LENGTH' => '1024']],
array(1024, array('CONTENT-LENGTH' => '512')), [1024, ['CONTENT-LENGTH' => '512']],
array(1024, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), [1024, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']],
array(FileInfo::SPACE_UNKNOWN, array()), [FileInfo::SPACE_UNKNOWN, []],
array(FileInfo::SPACE_UNKNOWN, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), [FileInfo::SPACE_UNKNOWN, ['X-EXPECTED-ENTITY-LENGTH' => '1024']],
array(FileInfo::SPACE_UNKNOWN, array('CONTENT-LENGTH' => '512')), [FileInfo::SPACE_UNKNOWN, ['CONTENT-LENGTH' => '512']],
array(FileInfo::SPACE_UNKNOWN, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), [FileInfo::SPACE_UNKNOWN, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']],
array(FileInfo::SPACE_UNLIMITED, array()), [FileInfo::SPACE_UNLIMITED, []],
array(FileInfo::SPACE_UNLIMITED, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), [FileInfo::SPACE_UNLIMITED, ['X-EXPECTED-ENTITY-LENGTH' => '1024']],
array(FileInfo::SPACE_UNLIMITED, array('CONTENT-LENGTH' => '512')), [FileInfo::SPACE_UNLIMITED, ['CONTENT-LENGTH' => '512']],
array(FileInfo::SPACE_UNLIMITED, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), [FileInfo::SPACE_UNLIMITED, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']],
); ];
} }
public function quotaExceededProvider() { public function quotaExceededProvider() {
return array( return [
array(1023, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), [1023, ['X-EXPECTED-ENTITY-LENGTH' => '1024']],
array(511, array('CONTENT-LENGTH' => '512')), [511, ['CONTENT-LENGTH' => '512']],
array(2047, array('OC-TOTAL-LENGTH' => '2048', 'CONTENT-LENGTH' => '1024')), [2047, ['OC-TOTAL-LENGTH' => '2048', 'CONTENT-LENGTH' => '1024']],
); ];
} }
public function lengthProvider() { public function lengthProvider() {
@ -155,22 +155,22 @@ class QuotaPluginTest extends TestCase {
} }
public function quotaChunkedOkProvider() { public function quotaChunkedOkProvider() {
return array( return [
array(1024, 0, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), [1024, 0, ['X-EXPECTED-ENTITY-LENGTH' => '1024']],
array(1024, 0, array('CONTENT-LENGTH' => '512')), [1024, 0, ['CONTENT-LENGTH' => '512']],
array(1024, 0, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), [1024, 0, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']],
// with existing chunks (allowed size = total length - chunk total size) // with existing chunks (allowed size = total length - chunk total size)
array(400, 128, array('X-EXPECTED-ENTITY-LENGTH' => '512')), [400, 128, ['X-EXPECTED-ENTITY-LENGTH' => '512']],
array(400, 128, array('CONTENT-LENGTH' => '512')), [400, 128, ['CONTENT-LENGTH' => '512']],
array(400, 128, array('OC-TOTAL-LENGTH' => '512', 'CONTENT-LENGTH' => '500')), [400, 128, ['OC-TOTAL-LENGTH' => '512', 'CONTENT-LENGTH' => '500']],
// \OCP\Files\FileInfo::SPACE-UNKNOWN = -2 // \OCP\Files\FileInfo::SPACE-UNKNOWN = -2
array(-2, 0, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), [-2, 0, ['X-EXPECTED-ENTITY-LENGTH' => '1024']],
array(-2, 0, array('CONTENT-LENGTH' => '512')), [-2, 0, ['CONTENT-LENGTH' => '512']],
array(-2, 0, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), [-2, 0, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']],
array(-2, 128, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), [-2, 128, ['X-EXPECTED-ENTITY-LENGTH' => '1024']],
array(-2, 128, array('CONTENT-LENGTH' => '512')), [-2, 128, ['CONTENT-LENGTH' => '512']],
array(-2, 128, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), [-2, 128, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']],
); ];
} }
/** /**
@ -197,15 +197,15 @@ class QuotaPluginTest extends TestCase {
} }
public function quotaChunkedFailProvider() { public function quotaChunkedFailProvider() {
return array( return [
array(400, 0, array('X-EXPECTED-ENTITY-LENGTH' => '1024')), [400, 0, ['X-EXPECTED-ENTITY-LENGTH' => '1024']],
array(400, 0, array('CONTENT-LENGTH' => '512')), [400, 0, ['CONTENT-LENGTH' => '512']],
array(400, 0, array('OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512')), [400, 0, ['OC-TOTAL-LENGTH' => '1024', 'CONTENT-LENGTH' => '512']],
// with existing chunks (allowed size = total length - chunk total size) // with existing chunks (allowed size = total length - chunk total size)
array(380, 128, array('X-EXPECTED-ENTITY-LENGTH' => '512')), [380, 128, ['X-EXPECTED-ENTITY-LENGTH' => '512']],
array(380, 128, array('CONTENT-LENGTH' => '512')), [380, 128, ['CONTENT-LENGTH' => '512']],
array(380, 128, array('OC-TOTAL-LENGTH' => '512', 'CONTENT-LENGTH' => '500')), [380, 128, ['OC-TOTAL-LENGTH' => '512', 'CONTENT-LENGTH' => '500']],
); ];
} }
/** /**

View File

@ -108,8 +108,8 @@ class TagsPluginTest extends \Test\TestCase {
$this->tagger->expects($this->exactly($expectedCallCount)) $this->tagger->expects($this->exactly($expectedCallCount))
->method('getTagsForObjects') ->method('getTagsForObjects')
->with($this->equalTo(array(123))) ->with($this->equalTo([123]))
->willReturn(array(123 => $tags)); ->willReturn([123 => $tags]);
$propFind = new \Sabre\DAV\PropFind( $propFind = new \Sabre\DAV\PropFind(
'/dummyPath', '/dummyPath',
@ -162,16 +162,16 @@ class TagsPluginTest extends \Test\TestCase {
->willReturn(123); ->willReturn(123);
$node->expects($this->exactly($expectedCallCount)) $node->expects($this->exactly($expectedCallCount))
->method('getChildren') ->method('getChildren')
->willReturn(array($node1, $node2)); ->willReturn([$node1, $node2]);
$this->tagger->expects($this->exactly($expectedCallCount)) $this->tagger->expects($this->exactly($expectedCallCount))
->method('getTagsForObjects') ->method('getTagsForObjects')
->with($this->equalTo(array(123, 111, 222))) ->with($this->equalTo([123, 111, 222]))
->willReturn( ->willReturn(
array( [
111 => $tags, 111 => $tags,
123 => $tags 123 => $tags
) ]
); );
// simulate sabre recursive PROPFIND traversal // simulate sabre recursive PROPFIND traversal
@ -212,58 +212,58 @@ class TagsPluginTest extends \Test\TestCase {
} }
function tagsGetPropertiesDataProvider() { function tagsGetPropertiesDataProvider() {
return array( return [
// request both, receive both // request both, receive both
array( [
array('tag1', 'tag2', self::TAG_FAVORITE), ['tag1', 'tag2', self::TAG_FAVORITE],
array(self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME), [self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME],
array( [
200 => array( 200 => [
self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array('tag1', 'tag2')), self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2']),
self::FAVORITE_PROPERTYNAME => true, self::FAVORITE_PROPERTYNAME => true,
) ]
) ]
), ],
// request tags alone // request tags alone
array( [
array('tag1', 'tag2', self::TAG_FAVORITE), ['tag1', 'tag2', self::TAG_FAVORITE],
array(self::TAGS_PROPERTYNAME), [self::TAGS_PROPERTYNAME],
array( [
200 => array( 200 => [
self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array('tag1', 'tag2')), self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2']),
) ]
) ]
), ],
// request fav alone // request fav alone
array( [
array('tag1', 'tag2', self::TAG_FAVORITE), ['tag1', 'tag2', self::TAG_FAVORITE],
array(self::FAVORITE_PROPERTYNAME), [self::FAVORITE_PROPERTYNAME],
array( [
200 => array( 200 => [
self::FAVORITE_PROPERTYNAME => true, self::FAVORITE_PROPERTYNAME => true,
) ]
) ]
), ],
// request none // request none
array( [
array('tag1', 'tag2', self::TAG_FAVORITE), ['tag1', 'tag2', self::TAG_FAVORITE],
array(), [],
array( [
200 => array() 200 => []
), ],
), ],
// request both with none set, receive both // request both with none set, receive both
array( [
array(), [],
array(self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME), [self::TAGS_PROPERTYNAME, self::FAVORITE_PROPERTYNAME],
array( [
200 => array( 200 => [
self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array()), self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList([]),
self::FAVORITE_PROPERTYNAME => false, self::FAVORITE_PROPERTYNAME => false,
) ]
) ]
), ],
); ];
} }
public function testUpdateTags() { public function testUpdateTags() {
@ -283,8 +283,8 @@ class TagsPluginTest extends \Test\TestCase {
$this->tagger->expects($this->at(0)) $this->tagger->expects($this->at(0))
->method('getTagsForObjects') ->method('getTagsForObjects')
->with($this->equalTo(array(123))) ->with($this->equalTo([123]))
->willReturn(array(123 => array('tagkeep', 'tagremove', self::TAG_FAVORITE))); ->willReturn([123 => ['tagkeep', 'tagremove', self::TAG_FAVORITE]]);
// then tag as tag1 and tag2 // then tag as tag1 and tag2
$this->tagger->expects($this->at(1)) $this->tagger->expects($this->at(1))
@ -300,9 +300,9 @@ class TagsPluginTest extends \Test\TestCase {
->with(123, 'tagremove'); ->with(123, 'tagremove');
// properties to set // properties to set
$propPatch = new \Sabre\DAV\PropPatch(array( $propPatch = new \Sabre\DAV\PropPatch([
self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array('tag1', 'tag2', 'tagkeep')) self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2', 'tagkeep'])
)); ]);
$this->plugin->handleUpdateProperties( $this->plugin->handleUpdateProperties(
'/dummypath', '/dummypath',
@ -334,8 +334,8 @@ class TagsPluginTest extends \Test\TestCase {
$this->tagger->expects($this->at(0)) $this->tagger->expects($this->at(0))
->method('getTagsForObjects') ->method('getTagsForObjects')
->with($this->equalTo(array(123))) ->with($this->equalTo([123]))
->willReturn(array()); ->willReturn([]);
// then tag as tag1 and tag2 // then tag as tag1 and tag2
$this->tagger->expects($this->at(1)) $this->tagger->expects($this->at(1))
@ -346,9 +346,9 @@ class TagsPluginTest extends \Test\TestCase {
->with(123, 'tag2'); ->with(123, 'tag2');
// properties to set // properties to set
$propPatch = new \Sabre\DAV\PropPatch(array( $propPatch = new \Sabre\DAV\PropPatch([
self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(array('tag1', 'tag2', 'tagkeep')) self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2', 'tagkeep'])
)); ]);
$this->plugin->handleUpdateProperties( $this->plugin->handleUpdateProperties(
'/dummypath', '/dummypath',
@ -386,9 +386,9 @@ class TagsPluginTest extends \Test\TestCase {
->with(123, self::TAG_FAVORITE); ->with(123, self::TAG_FAVORITE);
// properties to set // properties to set
$propPatch = new \Sabre\DAV\PropPatch(array( $propPatch = new \Sabre\DAV\PropPatch([
self::FAVORITE_PROPERTYNAME => true self::FAVORITE_PROPERTYNAME => true
)); ]);
$this->plugin->handleUpdateProperties( $this->plugin->handleUpdateProperties(
'/dummypath', '/dummypath',
@ -411,9 +411,9 @@ class TagsPluginTest extends \Test\TestCase {
->with(123, self::TAG_FAVORITE); ->with(123, self::TAG_FAVORITE);
// properties to set // properties to set
$propPatch = new \Sabre\DAV\PropPatch(array( $propPatch = new \Sabre\DAV\PropPatch([
self::FAVORITE_PROPERTYNAME => false self::FAVORITE_PROPERTYNAME => false
)); ]);
$this->plugin->handleUpdateProperties( $this->plugin->handleUpdateProperties(
'/dummypath', '/dummypath',

View File

@ -184,7 +184,7 @@ class GroupPrincipalTest extends \Test\TestCase {
} }
public function testUpdatePrincipal() { 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() { public function testSearchPrincipalsWithEmptySearchProperties() {

View File

@ -308,12 +308,12 @@ class SystemTagPluginTest extends \Test\TestCase {
->with($systemTag, ['group1', 'group2']); ->with($systemTag, ['group1', 'group2']);
// properties to set // properties to set
$propPatch = new \Sabre\DAV\PropPatch(array( $propPatch = new \Sabre\DAV\PropPatch([
self::DISPLAYNAME_PROPERTYNAME => 'Test changed', self::DISPLAYNAME_PROPERTYNAME => 'Test changed',
self::USERVISIBLE_PROPERTYNAME => 'false', self::USERVISIBLE_PROPERTYNAME => 'false',
self::USERASSIGNABLE_PROPERTYNAME => 'true', self::USERASSIGNABLE_PROPERTYNAME => 'true',
self::GROUPS_PROPERTYNAME => 'group1|group2', self::GROUPS_PROPERTYNAME => 'group1|group2',
)); ]);
$this->plugin->handleUpdateProperties( $this->plugin->handleUpdateProperties(
'/systemtag/1', '/systemtag/1',
@ -364,9 +364,9 @@ class SystemTagPluginTest extends \Test\TestCase {
->method('setTagGroups'); ->method('setTagGroups');
// properties to set // properties to set
$propPatch = new \Sabre\DAV\PropPatch(array( $propPatch = new \Sabre\DAV\PropPatch([
self::GROUPS_PROPERTYNAME => 'group1|group2', self::GROUPS_PROPERTYNAME => 'group1|group2',
)); ]);
$this->plugin->handleUpdateProperties( $this->plugin->handleUpdateProperties(
'/systemtag/1', '/systemtag/1',

View File

@ -58,7 +58,7 @@ class Application extends \OCP\AppFramework\App {
/** /**
* @param array $urlParams * @param array $urlParams
*/ */
public function __construct($urlParams = array()) { public function __construct($urlParams = []) {
parent::__construct('encryption', $urlParams); parent::__construct('encryption', $urlParams);
$this->encryptionManager = \OC::$server->getEncryptionManager(); $this->encryptionManager = \OC::$server->getEncryptionManager();
$this->config = \OC::$server->getConfig(); $this->config = \OC::$server->getConfig();

View File

@ -120,7 +120,7 @@ class EncryptAll {
$this->questionHelper = $questionHelper; $this->questionHelper = $questionHelper;
$this->secureRandom = $secureRandom; $this->secureRandom = $secureRandom;
// store one time passwords for the users // 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) { protected function encryptUsersFiles($uid, ProgressBar $progress, $userCount) {
$this->setupUserFS($uid); $this->setupUserFS($uid);
$directories = array(); $directories = [];
$directories[] = '/' . $uid . '/files'; $directories[] = '/' . $uid . '/files';
while($root = array_pop($directories)) { while($root = array_pop($directories)) {
@ -322,11 +322,11 @@ class EncryptAll {
*/ */
protected function outputPasswords() { protected function outputPasswords() {
$table = new Table($this->output); $table = new Table($this->output);
$table->setHeaders(array('Username', 'Private key password')); $table->setHeaders(['Username', 'Private key password']);
//create rows //create rows
$newPasswords = array(); $newPasswords = [];
$unchangedPasswords = array(); $unchangedPasswords = [];
foreach ($this->userPasswords as $uid => $password) { foreach ($this->userPasswords as $uid => $password) {
if (empty($password)) { if (empty($password)) {
$unchangedPasswords[] = $uid; $unchangedPasswords[] = $uid;
@ -451,7 +451,7 @@ class EncryptAll {
$this->output->writeln("\n\nPassword successfully send to all users"); $this->output->writeln("\n\nPassword successfully send to all users");
} else { } else {
$table = new Table($this->output); $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"); $this->output->writeln("\n\nCould not send password to following users:\n");
$rows = []; $rows = [];
foreach ($noMail as $uid) { foreach ($noMail as $uid) {

View File

@ -236,7 +236,7 @@ class Encryption implements IEncryptionModule {
$this->cipher = $this->crypt->getLegacyCipher(); $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); $result = $this->crypt->symmetricEncryptFileContent($this->writeCache, $this->fileKey, $this->version + 1, $position);
$this->writeCache = ''; $this->writeCache = '';
} }
$publicKeys = array(); $publicKeys = [];
if ($this->useMasterPassword === true) { if ($this->useMasterPassword === true) {
$publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey(); $publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey();
} else { } else {
@ -402,7 +402,7 @@ class Encryption implements IEncryptionModule {
if (!empty($fileKey)) { if (!empty($fileKey)) {
$publicKeys = array(); $publicKeys = [];
if ($this->useMasterPassword === true) { if ($this->useMasterPassword === true) {
$publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey(); $publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey();
} else { } else {
@ -425,7 +425,7 @@ class Encryption implements IEncryptionModule {
} else { } else {
$this->logger->debug('no file key found, we assume that the file "{file}" is not encrypted', $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; return false;
} }

View File

@ -213,7 +213,7 @@ class Recovery {
$fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID()); $fileKey = $this->keyManager->getFileKey($filePath, $this->user->getUID());
if (!empty($fileKey)) { if (!empty($fileKey)) {
$accessList = $this->file->getAccessList($filePath); $accessList = $this->file->getAccessList($filePath);
$publicKeys = array(); $publicKeys = [];
foreach ($accessList['users'] as $uid) { foreach ($accessList['users'] as $uid) {
$publicKeys[$uid] = $this->keyManager->getPublicKey($uid); $publicKeys[$uid] = $this->keyManager->getPublicKey($uid);
} }
@ -299,7 +299,7 @@ class Recovery {
if (!empty($fileKey)) { if (!empty($fileKey)) {
$accessList = $this->file->getAccessList($path); $accessList = $this->file->getAccessList($path);
$publicKeys = array(); $publicKeys = [];
foreach ($accessList['users'] as $user) { foreach ($accessList['users'] as $user) {
$publicKeys[$user] = $this->keyManager->getPublicKey($user); $publicKeys[$user] = $this->keyManager->getPublicKey($user);
} }

View File

@ -2,9 +2,9 @@
/** @var OC_Theme $theme */ /** @var OC_Theme $theme */
/** @var array $_ */ /** @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']) ) { 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"); print_unescaped("\n\n");
} }
// TRANSLATORS term at the end of a mail // TRANSLATORS term at the end of a mail

View File

@ -15,7 +15,7 @@
<td width="20px">&nbsp;</td> <td width="20px">&nbsp;</td>
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;"> <td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php <?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 // TRANSLATORS term at the end of a mail
p($l->t('Cheers!')); p($l->t('Cheers!'));
?> ?>

View File

@ -80,7 +80,7 @@ class CryptTest extends TestCase {
$this->config->expects($this->once()) $this->config->expects($this->once())
->method('getSystemValue') ->method('getSystemValue')
->with($this->equalTo('openssl'), $this->equalTo([])) ->with($this->equalTo('openssl'), $this->equalTo([]))
->willReturn(array()); ->willReturn([]);
$result = self::invokePrivate($this->crypt, 'getOpenSSLConfig'); $result = self::invokePrivate($this->crypt, 'getOpenSSLConfig');
$this->assertSame(1, count($result)); $this->assertSame(1, count($result));
@ -96,7 +96,7 @@ class CryptTest extends TestCase {
$this->config->expects($this->once()) $this->config->expects($this->once())
->method('getSystemValue') ->method('getSystemValue')
->with($this->equalTo('openssl'), $this->equalTo([])) ->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'); $result = self::invokePrivate($this->crypt, 'getOpenSSLConfig');
$this->assertSame(2, count($result)); $this->assertSame(2, count($result));
@ -185,14 +185,14 @@ class CryptTest extends TestCase {
* @return array * @return array
*/ */
public function dataProviderGetCipher() { public function dataProviderGetCipher() {
return array( return [
array('AES-128-CFB', 'AES-128-CFB'), ['AES-128-CFB', 'AES-128-CFB'],
array('AES-256-CFB', 'AES-256-CFB'), ['AES-256-CFB', 'AES-256-CFB'],
array('AES-128-CTR', 'AES-128-CTR'), ['AES-128-CTR', 'AES-128-CTR'],
array('AES-256-CTR', 'AES-256-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( $result = self::invokePrivate(
$this->crypt, $this->crypt,
'concatIV', 'concatIV',
array('content', 'my_iv')); ['content', 'my_iv']);
$this->assertSame('content00iv00my_iv', $this->assertSame('content00iv00my_iv',
$result $result
@ -214,7 +214,7 @@ class CryptTest extends TestCase {
* @dataProvider dataTestSplitMetaData * @dataProvider dataTestSplitMetaData
*/ */
public function testSplitMetaData($data, $expected) { 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->assertTrue(is_array($result));
$this->assertSame(3, count($result)); $this->assertSame(3, count($result));
$this->assertArrayHasKey('encrypted', $result); $this->assertArrayHasKey('encrypted', $result);
@ -239,7 +239,7 @@ class CryptTest extends TestCase {
*/ */
public function testHasSignature($data, $expected) { public function testHasSignature($data, $expected) {
$this->assertSame($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); $this->expectException(\OCP\Encryption\Exceptions\GenericEncryptionException::class);
$data = 'encryptedContent00iv001234567890123456xx'; $data = 'encryptedContent00iv001234567890123456xx';
$this->invokePrivate($this->crypt, 'hasSignature', array($data, $cipher)); $this->invokePrivate($this->crypt, 'hasSignature', [$data, $cipher]);
} }
public function dataTestHasSignatureFail() { public function dataTestHasSignatureFail() {
@ -273,7 +273,7 @@ class CryptTest extends TestCase {
* test addPadding() * test addPadding()
*/ */
public function testAddPadding() { public function testAddPadding() {
$result = self::invokePrivate($this->crypt, 'addPadding', array('data')); $result = self::invokePrivate($this->crypt, 'addPadding', ['data']);
$this->assertSame('dataxxx', $result); $this->assertSame('dataxxx', $result);
} }
@ -285,7 +285,7 @@ class CryptTest extends TestCase {
* @param $expected * @param $expected
*/ */
public function testRemovePadding($data, $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); $this->assertSame($expected, $result);
} }
@ -295,10 +295,10 @@ class CryptTest extends TestCase {
* @return array * @return array
*/ */
public function dataProviderRemovePadding() { public function dataProviderRemovePadding() {
return array( return [
array('dataxx', 'data'), ['dataxx', 'data'],
array('data', false) ['data', false]
); ];
} }
/** /**
@ -307,7 +307,7 @@ class CryptTest extends TestCase {
public function testParseHeader() { public function testParseHeader() {
$header= 'HBEGIN:foo:bar:cipher:AES-256-CFB:HEND'; $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->assertTrue(is_array($result));
$this->assertSame(2, count($result)); $this->assertSame(2, count($result));
@ -331,15 +331,15 @@ class CryptTest extends TestCase {
$this->assertTrue(is_string($iv)); $this->assertTrue(is_string($iv));
$this->assertSame(16, strlen($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)); $this->assertTrue(is_string($result));
return array( return [
'password' => $password, 'password' => $password,
'iv' => $iv, 'iv' => $iv,
'encrypted' => $result, 'encrypted' => $result,
'decrypted' => $decrypted); 'decrypted' => $decrypted];
} }
@ -353,7 +353,7 @@ class CryptTest extends TestCase {
$result = self::invokePrivate( $result = self::invokePrivate(
$this->crypt, $this->crypt,
'decrypt', 'decrypt',
array($data['encrypted'], $data['iv'], $data['password'])); [$data['encrypted'], $data['iv'], $data['password']]);
$this->assertSame($data['decrypted'], $result); $this->assertSame($data['decrypted'], $result);

View File

@ -124,7 +124,7 @@ class EncryptionTest extends TestCase {
* test if public key from one of the recipients is missing * test if public key from one of the recipients is missing
*/ */
public function testEndUser1() { 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(); $this->endTest();
} }
@ -135,7 +135,7 @@ class EncryptionTest extends TestCase {
public function testEndUser2() { public function testEndUser2() {
$this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class); $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(); $this->endTest();
} }
@ -182,17 +182,17 @@ class EncryptionTest extends TestCase {
*/ */
public function testGetPathToRealFile($path, $expected) { public function testGetPathToRealFile($path, $expected) {
$this->assertSame($expected, $this->assertSame($expected,
self::invokePrivate($this->instance, 'getPathToRealFile', array($path)) self::invokePrivate($this->instance, 'getPathToRealFile', [$path])
); );
} }
public function dataProviderForTestGetPathToRealFile() { public function dataProviderForTestGetPathToRealFile() {
return array( return [
array('/user/files/foo/bar.txt', '/user/files/foo/bar.txt'), ['/user/files/foo/bar.txt', '/user/files/foo/bar.txt'],
array('/user/files/foo.txt', '/user/files/foo.txt'), ['/user/files/foo.txt', '/user/files/foo.txt'],
array('/user/files_versions/foo.txt.v543534', '/user/files/foo.txt'), ['/user/files_versions/foo.txt.v543534', '/user/files/foo.txt'],
array('/user/files_versions/foo/bar.txt.v5454', '/user/files/foo/bar.txt'), ['/user/files_versions/foo/bar.txt.v5454', '/user/files/foo/bar.txt'],
); ];
} }
/** /**
@ -241,12 +241,12 @@ class EncryptionTest extends TestCase {
} }
public function dataTestBegin() { public function dataTestBegin() {
return array( return [
array('w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'defaultCipher'), ['w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'defaultCipher'],
array('r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'myCipher'), ['r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'myCipher'],
array('w', [], 'legacyCipher', 'defaultCipher', '', 'defaultCipher'), ['w', [], 'legacyCipher', 'defaultCipher', '', 'defaultCipher'],
array('r', [], 'legacyCipher', 'defaultCipher', 'file_key', 'legacyCipher'), ['r', [], 'legacyCipher', 'defaultCipher', 'file_key', 'legacyCipher'],
); ];
} }
@ -335,10 +335,10 @@ class EncryptionTest extends TestCase {
} }
public function dataTestUpdate() { public function dataTestUpdate() {
return array( return [
array('', false), ['', false],
array('fileKey', true) ['fileKey', true]
); ];
} }
public function testUpdateNoUsers() { public function testUpdateNoUsers() {
@ -417,19 +417,19 @@ class EncryptionTest extends TestCase {
} }
public function dataTestShouldEncrypt() { public function dataTestShouldEncrypt() {
return array( return [
array('/user1/files/foo.txt', true, true, true), ['/user1/files/foo.txt', true, true, true],
array('/user1/files_versions/foo.txt', true, true, true), ['/user1/files_versions/foo.txt', true, true, true],
array('/user1/files_trashbin/foo.txt', true, true, true), ['/user1/files_trashbin/foo.txt', true, true, true],
array('/user1/some_folder/foo.txt', true, true, false), ['/user1/some_folder/foo.txt', true, true, false],
array('/user1/foo.txt', true, true, false), ['/user1/foo.txt', true, true, false],
array('/user1/files', true, true, false), ['/user1/files', true, true, false],
array('/user1/files_trashbin', true, true, false), ['/user1/files_trashbin', true, true, false],
array('/user1/files_versions', true, true, false), ['/user1/files_versions', true, true, false],
// test if shouldEncryptHomeStorage is set to false // test if shouldEncryptHomeStorage is set to false
array('/user1/files/foo.txt', false, true, false), ['/user1/files/foo.txt', false, true, false],
array('/user1/files_versions/foo.txt', false, false, true), ['/user1/files_versions/foo.txt', false, false, true],
); ];
} }

View File

@ -322,7 +322,7 @@ class KeyManagerTest extends TestCase {
$this->assertTrue( $this->assertTrue(
$this->instance->setRecoveryKey('pass', $this->instance->setRecoveryKey('pass',
array('publicKey' => 'publicKey', 'privateKey' => 'privateKey')) ['publicKey' => 'publicKey', 'privateKey' => 'privateKey'])
); );
} }
@ -505,12 +505,12 @@ class KeyManagerTest extends TestCase {
* @return array * @return array
*/ */
public function dataTestAddSystemKeys() { public function dataTestAddSystemKeys() {
return array( return [
array(['public' => true],[], 'user1', ['publicShareKey', 'recoveryKey']), [['public' => true],[], 'user1', ['publicShareKey', 'recoveryKey']],
array(['public' => false], [], 'user1', ['recoveryKey']), [['public' => false], [], 'user1', ['recoveryKey']],
array(['public' => true],[], 'user2', ['publicShareKey']), [['public' => true],[], 'user2', ['publicShareKey']],
array(['public' => false], [], 'user2', []), [['public' => false], [], 'user2', []],
); ];
} }
public function testGetMasterKeyId() { public function testGetMasterKeyId() {

View File

@ -106,12 +106,12 @@ class AddressHandler {
\OCP\Util::emitHook( \OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server', '\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName', 'preLoginNameUsedAsUserName',
array('uid' => &$user1) ['uid' => &$user1]
); );
\OCP\Util::emitHook( \OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server', '\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName', 'preLoginNameUsedAsUserName',
array('uid' => &$user2) ['uid' => &$user2]
); );
if ($user1 === $user2) { if ($user1 === $user2) {

View File

@ -187,7 +187,7 @@ class FederatedShareProvider implements IShareProvider {
$alreadySharedGroup = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_REMOTE_GROUP, $share->getNode(), 1, 0); $alreadySharedGroup = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_REMOTE_GROUP, $share->getNode(), 1, 0);
if (!empty($alreadyShared) || !empty($alreadySharedGroup)) { if (!empty($alreadyShared) || !empty($alreadySharedGroup)) {
$message = 'Sharing %1$s failed, because this item is already shared with %2$s'; $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']); $this->logger->debug(sprintf($message, $share->getNode()->getName(), $shareWith), ['app' => 'Federated File Sharing']);
throw new \Exception($message_t); throw new \Exception($message_t);
} }

View File

@ -99,7 +99,7 @@ class Notifications {
if ($user && $remote) { if ($user && $remote) {
$local = $this->addressHandler->generateRemoteURL(); $local = $this->addressHandler->generateRemoteURL();
$fields = array( $fields = [
'shareWith' => $user, 'shareWith' => $user,
'token' => $token, 'token' => $token,
'name' => $name, 'name' => $name,
@ -110,7 +110,7 @@ class Notifications {
'sharedByFederatedId' => $sharedByFederatedId, 'sharedByFederatedId' => $sharedByFederatedId,
'remote' => $local, 'remote' => $local,
'shareType' => $shareType 'shareType' => $shareType
); ];
$result = $this->tryHttpPostToShareEndpoint($remote, '', $fields); $result = $this->tryHttpPostToShareEndpoint($remote, '', $fields);
$status = json_decode($result['result'], true); $status = json_decode($result['result'], true);
@ -144,12 +144,12 @@ class Notifications {
*/ */
public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) { public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) {
$fields = array( $fields = [
'shareWith' => $shareWith, 'shareWith' => $shareWith,
'token' => $token, 'token' => $token,
'permission' => $permission, 'permission' => $permission,
'remoteId' => $shareId, 'remoteId' => $shareId,
); ];
$ocmFields = $fields; $ocmFields = $fields;
$ocmFields['remoteId'] = $id; $ocmFields['remoteId'] = $id;

View File

@ -215,7 +215,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
Util::emitHook( Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server', '\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName', 'preLoginNameUsedAsUserName',
array('uid' => &$shareWith) ['uid' => &$shareWith]
); );
$this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']);
@ -774,7 +774,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
$file = null; $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); $link = Util::linkToAbsolute('files', 'index.php', $args);
return [$file, $link]; return [$file, $link];

View File

@ -104,21 +104,21 @@ class AddressHandlerTest extends \Test\TestCase {
} }
public function dataTestSplitUserRemoteError() { public function dataTestSplitUserRemoteError() {
return array( return [
// Invalid path // Invalid path
array('user@'), ['user@'],
// Invalid user // Invalid user
array('@server'), ['@server'],
array('us/er@server'), ['us/er@server'],
array('us:er@server'), ['us:er@server'],
// Invalid splitting // Invalid splitting
array('user'), ['user'],
array(''), [''],
array('us/erserver'), ['us/erserver'],
array('us:erserver'), ['us:erserver'],
); ];
} }
/** /**

View File

@ -38,7 +38,7 @@ $dir = isset($_GET['dir']) ? (string)$_GET['dir'] : '';
$files_list = json_decode($files); $files_list = json_decode($files);
// in case we get only a single file // in case we get only a single file
if (!is_array($files_list)) { 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, '/'); 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 * Http range requests support

View File

@ -43,7 +43,7 @@ try {
exit(); exit();
} }
$data = array(); $data = [];
$baseUrl = \OC::$server->getURLGenerator()->linkTo('files', 'index.php') . '?dir='; $baseUrl = \OC::$server->getURLGenerator()->linkTo('files', 'index.php') . '?dir=';
$permissions = $dirInfo->getPermissions(); $permissions = $dirInfo->getPermissions();
@ -80,7 +80,7 @@ try {
$data['files'] = \OCA\Files\Helper::formatFileInfos($files); $data['files'] = \OCA\Files\Helper::formatFileInfos($files);
$data['permissions'] = $permissions; $data['permissions'] = $permissions;
\OC_JSON::success(array('data' => $data)); \OC_JSON::success(['data' => $data]);
} catch (\OCP\Files\StorageNotAvailableException $e) { } catch (\OCP\Files\StorageNotAvailableException $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files']); \OC::$server->getLogger()->logException($e, ['app' => 'files']);
\OC_JSON::error([ \OC_JSON::error([
@ -91,18 +91,18 @@ try {
]); ]);
} catch (\OCP\Files\StorageInvalidException $e) { } catch (\OCP\Files\StorageInvalidException $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files']); \OC::$server->getLogger()->logException($e, ['app' => 'files']);
\OC_JSON::error(array( \OC_JSON::error([
'data' => array( 'data' => [
'exception' => StorageInvalidException::class, 'exception' => StorageInvalidException::class,
'message' => $l->t('Storage invalid') 'message' => $l->t('Storage invalid')
) ]
)); ]);
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files']); \OC::$server->getLogger()->logException($e, ['app' => 'files']);
\OC_JSON::error(array( \OC_JSON::error([
'data' => array( 'data' => [
'exception' => \Exception::class, 'exception' => \Exception::class,
'message' => $l->t('Unknown error') 'message' => $l->t('Unknown error')
) ]
)); ]);
} }

View File

@ -36,7 +36,7 @@ $app = \OC::$server->query(Application::class);
// t('Files') // t('Files')
$l = \OC::$server->getL10N('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 = \OC_Helper::getFileTemplateManager();
$templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp'); $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp');

View File

@ -50,7 +50,7 @@ class Application extends App {
public const APP_ID = 'files'; public const APP_ID = 'files';
public function __construct(array $urlParams=array()) { public function __construct(array $urlParams=[]) {
parent::__construct(self::APP_ID, $urlParams); parent::__construct(self::APP_ID, $urlParams);
$container = $this->getContainer(); $container = $this->getContainer();
$server = $container->getServer(); $server = $container->getServer();

View File

@ -174,7 +174,7 @@ class Scan extends Base {
if ($inputPath) { if ($inputPath) {
$inputPath = '/' . trim($inputPath, '/'); $inputPath = '/' . trim($inputPath, '/');
list (, $user,) = explode('/', $inputPath, 3); list (, $user,) = explode('/', $inputPath, 3);
$users = array($user); $users = [$user];
} else if ($input->getOption('all')) { } else if ($input->getOption('all')) {
$users = $this->userManager->search(''); $users = $this->userManager->search('');
} else { } else {

View File

@ -200,7 +200,7 @@ class ViewController extends Controller {
$collapseClasses = 'collapsible'; $collapseClasses = 'collapsible';
} }
$favoritesSublistArray = Array(); $favoritesSublistArray = [];
$navBarPositionPosition = 6; $navBarPositionPosition = 6;
$currentCount = 0; $currentCount = 0;

View File

@ -51,7 +51,7 @@ class Helper {
$l = \OC::$server->getL10N('files'); $l = \OC::$server->getL10N('files');
$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']); $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize); $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
$maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize)); $maxHumanFileSize = $l->t('Upload (max. %s)', [$maxHumanFileSize]);
return [ return [
'uploadMaxFilesize' => $maxUploadFileSize, 'uploadMaxFilesize' => $maxUploadFileSize,
@ -140,7 +140,7 @@ class Helper {
* @return array formatted file info * @return array formatted file info
*/ */
public static function formatFileInfo(FileInfo $i) { public static function formatFileInfo(FileInfo $i) {
$entry = array(); $entry = [];
$entry['id'] = $i['fileid']; $entry['id'] = $i['fileid'];
$entry['parentId'] = $i['parent']; $entry['parentId'] = $i['parent'];
@ -182,7 +182,7 @@ class Helper {
* @return array * @return array
*/ */
public static function formatFileInfos($fileInfos) { public static function formatFileInfos($fileInfos) {
$files = array(); $files = [];
foreach ($fileInfos as $i) { foreach ($fileInfos as $i) {
$files[] = self::formatFileInfo($i); $files[] = self::formatFileInfo($i);
} }
@ -262,7 +262,7 @@ class Helper {
} else if ($sortAttribute === 'size') { } else if ($sortAttribute === 'size') {
$sortFunc = 'compareSize'; $sortFunc = 'compareSize';
} }
usort($files, array(Helper::class, $sortFunc)); usort($files, [Helper::class, $sortFunc]);
if ($sortDescending) { if ($sortDescending) {
$files = array_reverse($files); $files = array_reverse($files);
} }

View File

@ -83,7 +83,7 @@ class TagService {
public function updateFileTags($path, $tags) { public function updateFileTags($path, $tags) {
$fileId = $this->homeFolder->get($path)->getId(); $fileId = $this->homeFolder->get($path)->getId();
$currentTags = $this->tagger->getTagsForObjects(array($fileId)); $currentTags = $this->tagger->getTagsForObjects([$fileId]);
if (!empty($currentTags)) { if (!empty($currentTags)) {
$currentTags = current($currentTags); $currentTags = current($currentTags);

View File

@ -47,7 +47,7 @@ script(\OCA\Files\AppInfo\Application::APP_ID, 'dist/files-app-settings');
<label for="webdavurl"><?php p($l->t('WebDAV')); ?></label> <label for="webdavurl"><?php p($l->t('WebDAV')); ?></label>
<input id="webdavurl" type="text" readonly="readonly" <input id="webdavurl" type="text" readonly="readonly"
value="<?php p($_['webdav_url']); ?>"/> 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>
</div> </div>

View File

@ -37,13 +37,13 @@ class HelperTest extends \Test\TestCase {
'/' . $name, '/' . $name,
null, null,
'/', '/',
array( [
'name' => $name, 'name' => $name,
'size' => $size, 'size' => $size,
'mtime' => $mtime, 'mtime' => $mtime,
'type' => $isDir ? 'dir' : 'file', 'type' => $isDir ? 'dir' : 'file',
'mimetype' => $isDir ? 'httpd/unix-directory' : 'application/octet-stream' 'mimetype' => $isDir ? 'httpd/unix-directory' : 'application/octet-stream'
), ],
null null
); );
} }
@ -52,49 +52,49 @@ class HelperTest extends \Test\TestCase {
* Returns a file list for testing * Returns a file list for testing
*/ */
private function getTestFileList() { private function getTestFileList() {
return array( return [
self::makeFileInfo('a.txt', 4, 2.3 * pow(10, 9)), self::makeFileInfo('a.txt', 4, 2.3 * pow(10, 9)),
self::makeFileInfo('q.txt', 5, 150), self::makeFileInfo('q.txt', 5, 150),
self::makeFileInfo('subdir2', 87, 128, true), self::makeFileInfo('subdir2', 87, 128, true),
self::makeFileInfo('b.txt', 2.2 * pow(10, 9), 800), self::makeFileInfo('b.txt', 2.2 * pow(10, 9), 800),
self::makeFileInfo('o.txt', 12, 100), self::makeFileInfo('o.txt', 12, 100),
self::makeFileInfo('subdir', 88, 125, true), self::makeFileInfo('subdir', 88, 125, true),
); ];
} }
function sortDataProvider() { function sortDataProvider() {
return array( return [
array( [
'name', 'name',
false, false,
array('subdir', 'subdir2', 'a.txt', 'b.txt', 'o.txt', 'q.txt'), ['subdir', 'subdir2', 'a.txt', 'b.txt', 'o.txt', 'q.txt'],
), ],
array( [
'name', 'name',
true, true,
array('q.txt', 'o.txt', 'b.txt', 'a.txt', 'subdir2', 'subdir'), ['q.txt', 'o.txt', 'b.txt', 'a.txt', 'subdir2', 'subdir'],
), ],
array( [
'size', 'size',
false, false,
array('a.txt', 'q.txt', 'o.txt', 'subdir2', 'subdir', 'b.txt'), ['a.txt', 'q.txt', 'o.txt', 'subdir2', 'subdir', 'b.txt'],
), ],
array( [
'size', 'size',
true, true,
array('b.txt', 'subdir', 'subdir2', 'o.txt', 'q.txt', 'a.txt'), ['b.txt', 'subdir', 'subdir2', 'o.txt', 'q.txt', 'a.txt'],
), ],
array( [
'mtime', 'mtime',
false, false,
array('o.txt', 'subdir', 'subdir2', 'q.txt', 'b.txt', 'a.txt'), ['o.txt', 'subdir', 'subdir2', 'q.txt', 'b.txt', 'a.txt'],
), ],
array( [
'mtime', 'mtime',
true, 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) { public function testSortByName($sort, $sortDescending, $expectedOrder) {
$files = self::getTestFileList(); $files = self::getTestFileList();
$files = \OCA\Files\Helper::sortFiles($files, $sort, $sortDescending); $files = \OCA\Files\Helper::sortFiles($files, $sort, $sortDescending);
$fileNames = array(); $fileNames = [];
foreach ($files as $fileInfo) { foreach ($files as $fileInfo) {
$fileNames[] = $fileInfo->getName(); $fileNames[] = $fileInfo->getName();
} }

View File

@ -132,25 +132,25 @@ class TagServiceTest extends \Test\TestCase {
$fileId = $testFile->getId(); $fileId = $testFile->getId();
// set tags // 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([$fileId], $this->tagger->getIdsForTag($tag1));
$this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag2)); $this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag2));
// remove tag // remove tag
$this->tagService->updateFileTags('subdir/test.txt', array($tag2)); $this->tagService->updateFileTags('subdir/test.txt', [$tag2]);
$this->assertEquals(array(), $this->tagger->getIdsForTag($tag1)); $this->assertEquals([], $this->tagger->getIdsForTag($tag1));
$this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag2)); $this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag2));
// clear tags // clear tags
$this->tagService->updateFileTags('subdir/test.txt', array()); $this->tagService->updateFileTags('subdir/test.txt', []);
$this->assertEquals(array(), $this->tagger->getIdsForTag($tag1)); $this->assertEquals([], $this->tagger->getIdsForTag($tag1));
$this->assertEquals(array(), $this->tagger->getIdsForTag($tag2)); $this->assertEquals([], $this->tagger->getIdsForTag($tag2));
// non-existing file // non-existing file
$caught = false; $caught = false;
try { try {
$this->tagService->updateFileTags('subdir/unexist.txt', array($tag1)); $this->tagService->updateFileTags('subdir/unexist.txt', [$tag1]);
} catch (\OCP\Files\NotFoundException $e) { } catch (\OCP\Files\NotFoundException $e) {
$caught = true; $caught = true;
} }

View File

@ -51,6 +51,6 @@ foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $of
$users[$user->getUID()] = $user->getDisplayName(); $users[$user->getUID()] = $user->getDisplayName();
} }
$results = array('groups' => $groups, 'users' => $users); $results = ['groups' => $groups, 'users' => $users];
\OC_JSON::success($results); \OC_JSON::success($results);

View File

@ -88,12 +88,12 @@ class AjaxController extends Controller {
public function getSshKeys($keyLength = 1024) { public function getSshKeys($keyLength = 1024) {
$key = $this->generateSshKeys($keyLength); $key = $this->generateSshKeys($keyLength);
return new JSONResponse( return new JSONResponse(
array('data' => array( ['data' => [
'private_key' => $key['privatekey'], 'private_key' => $key['privatekey'],
'public_key' => $key['publickey'] 'public_key' => $key['publickey']
), ],
'status' => 'success' 'status' => 'success'
)); ]);
} }
/** /**

View File

@ -74,7 +74,7 @@ class ApiController extends OCSController {
$permissions |= \OCP\Constants::PERMISSION_DELETE; $permissions |= \OCP\Constants::PERMISSION_DELETE;
} }
$entry = array( $entry = [
'name' => basename($mountPoint), 'name' => basename($mountPoint),
'path' => $path, 'path' => $path,
'type' => 'dir', 'type' => 'dir',
@ -83,7 +83,7 @@ class ApiController extends OCSController {
'permissions' => $permissions, 'permissions' => $permissions,
'id' => $mountConfig['id'], 'id' => $mountConfig['id'],
'class' => $mountConfig['class'] 'class' => $mountConfig['class']
); ];
return $entry; return $entry;
} }

View File

@ -171,7 +171,7 @@ class GlobalStoragesController extends StoragesController {
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
return new DataResponse( 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 Http::STATUS_NOT_FOUND
); );

View File

@ -124,7 +124,7 @@ class UserGlobalStoragesController extends StoragesController {
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
return new DataResponse( 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 Http::STATUS_NOT_FOUND
); );
@ -164,7 +164,7 @@ class UserGlobalStoragesController extends StoragesController {
} else { } else {
return new DataResponse( 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 Http::STATUS_FORBIDDEN
); );
@ -172,7 +172,7 @@ class UserGlobalStoragesController extends StoragesController {
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
return new DataResponse( 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 Http::STATUS_NOT_FOUND
); );

View File

@ -199,7 +199,7 @@ class UserStoragesController extends StoragesController {
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
return new DataResponse( 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 Http::STATUS_NOT_FOUND
); );

View File

@ -128,10 +128,10 @@ class AmazonS3 extends \OC\Files\Storage\Common {
private function headObject($key) { private function headObject($key) {
if (!isset($this->objectCache[$key])) { if (!isset($this->objectCache[$key])) {
try { try {
$this->objectCache[$key] = $this->getConnection()->headObject(array( $this->objectCache[$key] = $this->getConnection()->headObject([
'Bucket' => $this->bucket, 'Bucket' => $this->bucket,
'Key' => $key 'Key' => $key
)); ]);
} catch (S3Exception $e) { } catch (S3Exception $e) {
if ($e->getStatusCode() >= 500) { if ($e->getStatusCode() >= 500) {
throw $e; throw $e;
@ -191,7 +191,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$stmt = \OC::$server->getDatabaseConnection()->prepare( $stmt = \OC::$server->getDatabaseConnection()->prepare(
'SELECT `numeric_id`, `id` FROM `*PREFIX*storages` WHERE `id` IN (?, ?)' '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()) { while ($row = $stmt->fetch()) {
$storages[$row['id']] = $row['numeric_id']; $storages[$row['id']] = $row['numeric_id'];
} }
@ -204,7 +204,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$stmt = \OC::$server->getDatabaseConnection()->prepare( $stmt = \OC::$server->getDatabaseConnection()->prepare(
'UPDATE `*PREFIX*storages` SET `id` = ? WHERE `id` = ?' '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 // only the bucket based id may exist, do nothing
} }
@ -235,12 +235,12 @@ class AmazonS3 extends \OC\Files\Storage\Common {
} }
try { try {
$this->getConnection()->putObject(array( $this->getConnection()->putObject([
'Bucket' => $this->bucket, 'Bucket' => $this->bucket,
'Key' => $path . '/', 'Key' => $path . '/',
'Body' => '', 'Body' => '',
'ContentType' => 'httpd/unix-directory' 'ContentType' => 'httpd/unix-directory'
)); ]);
$this->testTimeout(); $this->testTimeout();
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files_external']); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
@ -284,9 +284,9 @@ class AmazonS3 extends \OC\Files\Storage\Common {
} }
private function batchDelete($path = null) { private function batchDelete($path = null) {
$params = array( $params = [
'Bucket' => $this->bucket 'Bucket' => $this->bucket
); ];
if ($path !== null) { if ($path !== null) {
$params['Prefix'] = $path . '/'; $params['Prefix'] = $path . '/';
} }
@ -326,7 +326,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
} }
try { try {
$files = array(); $files = [];
$results = $this->getConnection()->getPaginator('ListObjects', [ $results = $this->getConnection()->getPaginator('ListObjects', [
'Bucket' => $this->bucket, 'Bucket' => $this->bucket,
'Delimiter' => '/', 'Delimiter' => '/',
@ -550,7 +550,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
public function touch($path, $mtime = null) { public function touch($path, $mtime = null) {
$path = $this->normalizePath($path); $path = $this->normalizePath($path);
$metadata = array(); $metadata = [];
if (is_null($mtime)) { if (is_null($mtime)) {
$mtime = time(); $mtime = time();
} }
@ -599,11 +599,11 @@ class AmazonS3 extends \OC\Files\Storage\Common {
if ($this->is_file($path1)) { if ($this->is_file($path1)) {
try { try {
$this->getConnection()->copyObject(array( $this->getConnection()->copyObject([
'Bucket' => $this->bucket, 'Bucket' => $this->bucket,
'Key' => $this->cleanKey($path2), 'Key' => $this->cleanKey($path2),
'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1) 'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1)
)); ]);
$this->testTimeout(); $this->testTimeout();
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files_external']); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
@ -613,11 +613,11 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$this->remove($path2); $this->remove($path2);
try { try {
$this->getConnection()->copyObject(array( $this->getConnection()->copyObject([
'Bucket' => $this->bucket, 'Bucket' => $this->bucket,
'Key' => $path2 . '/', 'Key' => $path2 . '/',
'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1 . '/') 'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1 . '/')
)); ]);
$this->testTimeout(); $this->testTimeout();
} catch (S3Exception $e) { } catch (S3Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files_external']); \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);

View File

@ -109,7 +109,7 @@ class FTP extends StreamWrapper{
case 'a': case 'a':
case 'ab': case 'ab':
//these are supported by the wrapper //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); $handle = fopen($this->constructUrl($path), $mode, false, $context);
return RetryWrapper::wrap($handle); return RetryWrapper::wrap($handle);
case 'r+': case 'r+':
@ -150,7 +150,7 @@ class FTP extends StreamWrapper{
if (function_exists('ftp_login')) { if (function_exists('ftp_login')) {
return true; return true;
} else { } else {
return array('ftp'); return ['ftp'];
} }
} }

View File

@ -251,8 +251,8 @@ class SFTP extends \OC\Files\Storage\Common {
try { try {
$keyPath = $this->hostKeysPath(); $keyPath = $this->hostKeysPath();
if (file_exists($keyPath)) { if (file_exists($keyPath)) {
$hosts = array(); $hosts = [];
$keys = array(); $keys = [];
$lines = file($keyPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $lines = file($keyPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines) { if ($lines) {
foreach ($lines as $line) { foreach ($lines as $line) {
@ -267,7 +267,7 @@ class SFTP extends \OC\Files\Storage\Common {
} }
} catch (\Exception $e) { } catch (\Exception $e) {
} }
return array(); return [];
} }
/** /**
@ -307,7 +307,7 @@ class SFTP extends \OC\Files\Storage\Common {
} }
$id = md5('sftp:' . $path); $id = md5('sftp:' . $path);
$dirStream = array(); $dirStream = [];
foreach($list as $file) { foreach($list as $file) {
if ($file !== '.' && $file !== '..') { if ($file !== '.' && $file !== '..') {
$dirStream[] = $file; $dirStream[] = $file;
@ -391,7 +391,7 @@ class SFTP extends \OC\Files\Storage\Common {
case 'x+': case 'x+':
case 'c': case 'c':
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); $handle = fopen($this->constructUrl($path), $mode, false, $context);
return RetryWrapper::wrap($handle); return RetryWrapper::wrap($handle);
} }
@ -464,7 +464,7 @@ class SFTP extends \OC\Files\Storage\Common {
$mtime = $stat ? $stat['mtime'] : -1; $mtime = $stat ? $stat['mtime'] : -1;
$size = $stat ? $stat['size'] : 0; $size = $stat ? $stat['size'] : 0;
return array('mtime' => $mtime, 'size' => $size, 'ctime' => -1); return ['mtime' => $mtime, 'size' => $size, 'ctime' => -1];
} catch (\Exception $e) { } catch (\Exception $e) {
return false; return false;
} }

View File

@ -472,7 +472,7 @@ class SMB extends Common implements INotifyStorage {
} }
try { try {
$this->statCache = array(); $this->statCache = [];
$content = $this->share->dir($this->buildPath($path)); $content = $this->share->dir($this->buildPath($path));
foreach ($content as $file) { foreach ($content as $file) {
if ($file->isDirectory()) { if ($file->isDirectory()) {

View File

@ -351,7 +351,7 @@ class Swift extends \OC\Files\Storage\Common {
$mtime = floor($mtime); $mtime = floor($mtime);
} }
$stat = array(); $stat = [];
$stat['size'] = (int)$object->contentLength; $stat['size'] = (int)$object->contentLength;
$stat['mtime'] = $mtime; $stat['mtime'] = $mtime;
$stat['atime'] = time(); $stat['atime'] = time();
@ -602,7 +602,7 @@ class Swift extends \OC\Files\Storage\Common {
} }
$path = $this->normalizePath($path); $path = $this->normalizePath($path);
$dh = $this->opendir($path); $dh = $this->opendir($path);
$content = array(); $content = [];
while (($file = readdir($dh)) !== false) { while (($file = readdir($dh)) !== false) {
$content[] = $file; $content[] = $file;
} }

View File

@ -96,7 +96,7 @@ class OC_Mount_Config {
* @deprecated 8.2.0 use UserGlobalStoragesService::getStorages() and UserStoragesService::getStorages() * @deprecated 8.2.0 use UserGlobalStoragesService::getStorages() and UserStoragesService::getStorages()
*/ */
public static function getAbsoluteMountPoints($uid) { public static function getAbsoluteMountPoints($uid) {
$mountPoints = array(); $mountPoints = [];
$userGlobalStoragesService = self::$app->getContainer()->query(UserGlobalStoragesService::class); $userGlobalStoragesService = self::$app->getContainer()->query(UserGlobalStoragesService::class);
$userStoragesService = self::$app->getContainer()->query(UserStoragesService::class); $userStoragesService = self::$app->getContainer()->query(UserStoragesService::class);
@ -296,7 +296,7 @@ class OC_Mount_Config {
return $mountPoints; return $mountPoints;
} }
} }
return array(); return [];
} }
/** /**
@ -430,14 +430,14 @@ class OC_Mount_Config {
*/ */
public static function makeConfigHash($config) { public static function makeConfigHash($config) {
$data = json_encode( $data = json_encode(
array( [
'c' => $config['backend'], 'c' => $config['backend'],
'a' => $config['authMechanism'], 'a' => $config['authMechanism'],
'm' => $config['mountpoint'], 'm' => $config['mountpoint'],
'o' => $config['options'], 'o' => $config['options'],
'p' => isset($config['priority']) ? $config['priority'] : -1, 'p' => isset($config['priority']) ? $config['priority'] : -1,
'mo' => isset($config['mountOptions']) ? $config['mountOptions'] : [], 'mo' => isset($config['mountOptions']) ? $config['mountOptions'] : [],
) ]
); );
return hash('md5', $data); return hash('md5', $data);
} }

View File

@ -117,7 +117,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount', 'mount',
'\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism', '\OCA\Files_External\Lib\Auth\NullMechanism',
array(), [],
[], [],
[], [],
[], [],
@ -159,7 +159,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount', 'mount',
'\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism', '\OCA\Files_External\Lib\Auth\NullMechanism',
array(), [],
[], [],
[], [],
[], [],
@ -172,11 +172,11 @@ abstract class StoragesControllerTest extends \Test\TestCase {
} }
function mountPointNamesProvider() { function mountPointNamesProvider() {
return array( return [
array(''), [''],
array('/'), ['/'],
array('//'), ['//'],
); ];
} }
/** /**
@ -201,7 +201,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$mountPoint, $mountPoint,
'\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism', '\OCA\Files_External\Lib\Auth\NullMechanism',
array(), [],
[], [],
[], [],
[], [],
@ -215,7 +215,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$mountPoint, $mountPoint,
'\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism', '\OCA\Files_External\Lib\Auth\NullMechanism',
array(), [],
[], [],
[], [],
[], [],
@ -238,7 +238,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount', 'mount',
'\OC\Files\Storage\InvalidStorage', '\OC\Files\Storage\InvalidStorage',
'\OCA\Files_External\Lib\Auth\NullMechanism', '\OCA\Files_External\Lib\Auth\NullMechanism',
array(), [],
[], [],
[], [],
[], [],
@ -252,7 +252,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount', 'mount',
'\OC\Files\Storage\InvalidStorage', '\OC\Files\Storage\InvalidStorage',
'\OCA\Files_External\Lib\Auth\NullMechanism', '\OCA\Files_External\Lib\Auth\NullMechanism',
array(), [],
[], [],
[], [],
[], [],
@ -292,7 +292,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount', 'mount',
'\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism', '\OCA\Files_External\Lib\Auth\NullMechanism',
array(), [],
[], [],
[], [],
[], [],
@ -388,7 +388,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
'mount', 'mount',
'\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Storage\SMB',
'\OCA\Files_External\Lib\Auth\NullMechanism', '\OCA\Files_External\Lib\Auth\NullMechanism',
array(), [],
[], [],
[], [],
[], [],

View File

@ -86,7 +86,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
'mount', 'mount',
'\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Storage\SMB',
'\Auth\Mechanism', '\Auth\Mechanism',
array(), [],
[], [],
[], [],
[], [],
@ -100,7 +100,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
'mount', 'mount',
'\OCA\Files_External\Lib\Storage\SMB', '\OCA\Files_External\Lib\Storage\SMB',
'\Auth\Mechanism', '\Auth\Mechanism',
array(), [],
[], [],
[], [],
[], [],

View File

@ -36,72 +36,72 @@ namespace OCA\Files_External\Tests;
class OwnCloudFunctionsTest extends \Test\TestCase { class OwnCloudFunctionsTest extends \Test\TestCase {
function configUrlProvider() { function configUrlProvider() {
return array( return [
array( [
array( [
'host' => 'testhost', 'host' => 'testhost',
'root' => 'testroot', 'root' => 'testroot',
'secure' => false 'secure' => false
), ],
'http://testhost/remote.php/webdav/testroot/', 'http://testhost/remote.php/webdav/testroot/',
), ],
array( [
array( [
'host' => 'testhost', 'host' => 'testhost',
'root' => 'testroot', 'root' => 'testroot',
'secure' => true 'secure' => true
), ],
'https://testhost/remote.php/webdav/testroot/', 'https://testhost/remote.php/webdav/testroot/',
), ],
array( [
array( [
'host' => 'http://testhost', 'host' => 'http://testhost',
'root' => 'testroot', 'root' => 'testroot',
'secure' => false 'secure' => false
), ],
'http://testhost/remote.php/webdav/testroot/', 'http://testhost/remote.php/webdav/testroot/',
), ],
array( [
array( [
'host' => 'https://testhost', 'host' => 'https://testhost',
'root' => 'testroot', 'root' => 'testroot',
'secure' => false 'secure' => false
), ],
'https://testhost/remote.php/webdav/testroot/', 'https://testhost/remote.php/webdav/testroot/',
), ],
array( [
array( [
'host' => 'https://testhost/testroot', 'host' => 'https://testhost/testroot',
'root' => '', 'root' => '',
'secure' => false 'secure' => false
), ],
'https://testhost/testroot/remote.php/webdav/', 'https://testhost/testroot/remote.php/webdav/',
), ],
array( [
array( [
'host' => 'https://testhost/testroot', 'host' => 'https://testhost/testroot',
'root' => 'subdir', 'root' => 'subdir',
'secure' => false 'secure' => false
), ],
'https://testhost/testroot/remote.php/webdav/subdir/', 'https://testhost/testroot/remote.php/webdav/subdir/',
), ],
array( [
array( [
'host' => 'http://testhost/testroot', 'host' => 'http://testhost/testroot',
'root' => 'subdir', 'root' => 'subdir',
'secure' => true 'secure' => true
), ],
'http://testhost/testroot/remote.php/webdav/subdir/', 'http://testhost/testroot/remote.php/webdav/subdir/',
), ],
array( [
array( [
'host' => 'http://testhost/testroot/', 'host' => 'http://testhost/testroot/',
'root' => '/subdir', 'root' => '/subdir',
'secure' => false 'secure' => false
), ],
'http://testhost/testroot/remote.php/webdav/subdir/', 'http://testhost/testroot/remote.php/webdav/subdir/',
), ],
); ];
} }
/** /**

View File

@ -95,7 +95,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();
$this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto()); $this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto());
self::$hookCalls = array(); self::$hookCalls = [];
$config = \OC::$server->getConfig(); $config = \OC::$server->getConfig();
$this->dataDir = $config->getSystemValue( $this->dataDir = $config->getSystemValue(
'datadirectory', 'datadirectory',
@ -177,7 +177,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
protected function tearDown(): void { protected function tearDown(): void {
\OC_Mount_Config::$skipTest = false; \OC_Mount_Config::$skipTest = false;
self::$hookCalls = array(); self::$hookCalls = [];
if ($this->dbConfig) { if ($this->dbConfig) {
$this->dbConfig->clean(); $this->dbConfig->clean();
} }
@ -448,17 +448,17 @@ abstract class StoragesServiceTest extends \Test\TestCase {
} }
public static function createHookCallback($params) { public static function createHookCallback($params) {
self::$hookCalls[] = array( self::$hookCalls[] = [
'signal' => Filesystem::signal_create_mount, 'signal' => Filesystem::signal_create_mount,
'params' => $params 'params' => $params
); ];
} }
public static function deleteHookCallback($params) { public static function deleteHookCallback($params) {
self::$hookCalls[] = array( self::$hookCalls[] = [
'signal' => Filesystem::signal_delete_mount, 'signal' => Filesystem::signal_delete_mount,
'params' => $params 'params' => $params
); ];
} }
/** /**

View File

@ -63,11 +63,11 @@ class FtpTest extends \Test\Files\Storage\Storage {
} }
public function testConstructUrl(){ public function testConstructUrl(){
$config = array ( 'host' => 'localhost', $config = [ 'host' => 'localhost',
'user' => 'ftp', 'user' => 'ftp',
'password' => 'ftp', 'password' => 'ftp',
'root' => '/', 'root' => '/',
'secure' => false ); 'secure' => false ];
$instance = new FTP($config); $instance = new FTP($config);
$this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl('')); $this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));

View File

@ -73,7 +73,7 @@ class SmbTest extends \Test\Files\Storage\Storage {
public function directoryProvider() { public function directoryProvider() {
// doesn't support leading/trailing spaces // doesn't support leading/trailing spaces
return array(array('folder')); return [['folder']];
} }
public function testRenameWithSpaces() { public function testRenameWithSpaces() {

View File

@ -33,15 +33,15 @@ if (file_exists($privateConfigFile)) {
} }
// this is now more a template now for your private configurations // this is now more a template now for your private configurations
return array( return [
'ftp'=>array( 'ftp'=>[
'run'=>false, 'run'=>false,
'host'=>'localhost', 'host'=>'localhost',
'user'=>'test', 'user'=>'test',
'password'=>'test', 'password'=>'test',
'root'=>'/test', 'root'=>'/test',
), ],
'webdav'=>array( 'webdav'=>[
'run'=>false, 'run'=>false,
'host'=>'localhost', 'host'=>'localhost',
'user'=>'test', 'user'=>'test',
@ -51,15 +51,15 @@ return array(
// (only in tests) // (only in tests)
// set to higher value for lighttpd webdav // set to higher value for lighttpd webdav
'wait'=> 0 'wait'=> 0
), ],
'owncloud'=>array( 'owncloud'=>[
'run'=>false, 'run'=>false,
'host'=>'localhost/owncloud', 'host'=>'localhost/owncloud',
'user'=>'test', 'user'=>'test',
'password'=>'test', 'password'=>'test',
'root'=>'', 'root'=>'',
), ],
'swift' => array( 'swift' => [
'run' => false, 'run' => false,
'user' => 'test', 'user' => 'test',
'bucket' => '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) //'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 //'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 //'timeout' => 5 // timeout of HTTP requests in seconds
), ],
'smb'=>array( 'smb'=>[
'run'=>false, 'run'=>false,
'user'=>'test', 'user'=>'test',
'password'=>'test', 'password'=>'test',
'host'=>'localhost', 'host'=>'localhost',
'share'=>'/test', 'share'=>'/test',
'root'=>'/test/', 'root'=>'/test/',
), ],
'amazons3'=>array( 'amazons3'=>[
'run'=>false, 'run'=>false,
'key'=>'test', 'key'=>'test',
'secret'=>'test', 'secret'=>'test',
@ -90,20 +90,20 @@ return array(
//'region' => 'eu-west-1', //'region' => 'eu-west-1',
//'test'=>'true', //'test'=>'true',
//'timeout'=>20 //'timeout'=>20
), ],
'sftp' => array ( 'sftp' => [
'run'=>false, 'run'=>false,
'host'=>'localhost', 'host'=>'localhost',
'user'=>'test', 'user'=>'test',
'password'=>'test', 'password'=>'test',
'root'=>'/test' 'root'=>'/test'
), ],
'sftp_key' => array ( 'sftp_key' => [
'run'=>false, 'run'=>false,
'host'=>'localhost', 'host'=>'localhost',
'user'=>'test', 'user'=>'test',
'public_key'=>'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDJPTvz3OLonF2KSGEKP/nd4CPmRYvemG2T4rIiNYjDj0U5y+2sKEWbjiUlQl2bsqYuVoJ+/UNJlGQbbZ08kQirFeo1GoWBzqioaTjUJfbLN6TzVVKXxR9YIVmH7Ajg2iEeGCndGgbmnPfj+kF9TR9IH8vMVvtubQwf7uEwB0ALhw== phpseclib-generated-key', 'public_key'=>'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDJPTvz3OLonF2KSGEKP/nd4CPmRYvemG2T4rIiNYjDj0U5y+2sKEWbjiUlQl2bsqYuVoJ+/UNJlGQbbZ08kQirFeo1GoWBzqioaTjUJfbLN6TzVVKXxR9YIVmH7Ajg2iEeGCndGgbmnPfj+kF9TR9IH8vMVvtubQwf7uEwB0ALhw== phpseclib-generated-key',
'private_key'=>'test', 'private_key'=>'test',
'root'=>'/test' 'root'=>'/test'
), ],
); ];

View File

@ -615,7 +615,7 @@ class ShareController extends AuthPublicShareController {
$this->emitAccessShareHook($share); $this->emitAccessShareHook($share);
$server_params = array( 'head' => $this->request->getMethod() === 'HEAD' ); $server_params = [ 'head' => $this->request->getMethod() === 'HEAD' ];
/** /**
* Http range requests support * Http range requests support

View File

@ -193,13 +193,13 @@ class Manager {
$this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType); $this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType);
$options = array( $options = [
'remote' => $remote, 'remote' => $remote,
'token' => $token, 'token' => $token,
'password' => $password, 'password' => $password,
'mountpoint' => $mountPoint, 'mountpoint' => $mountPoint,
'owner' => $owner 'owner' => $owner
); ];
return $this->mountShare($options); 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`) (`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`, `accepted`, `remote_id`, `parent`, `share_type`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 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` SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`, `parent`, `share_type`, `password`, `mountpoint_hash`
FROM `*PREFIX*share_external` FROM `*PREFIX*share_external`
WHERE `id` = ?'); WHERE `id` = ?');
$result = $getShare->execute(array($id)); $result = $getShare->execute([$id]);
$share = $result ? $getShare->fetch() : []; $share = $result ? $getShare->fetch() : [];
@ -286,7 +286,7 @@ class Manager {
`mountpoint` = ?, `mountpoint` = ?,
`mountpoint_hash` = ? `mountpoint_hash` = ?
WHERE `id` = ? AND `user` = ?'); WHERE `id` = ? AND `user` = ?');
$userShareAccepted = $acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid)); $userShareAccepted = $acceptShare->execute([1, $mountPoint, $hash, $id, $this->uid]);
} else { } else {
$result = $this->writeShareToDb( $result = $this->writeShareToDb(
$share['remote'], $share['remote'],
@ -327,7 +327,7 @@ class Manager {
if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) { if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) {
$removeShare = $this->connection->prepare(' $removeShare = $this->connection->prepare('
DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?'); 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->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
$this->processNotification($id); $this->processNotification($id);
@ -384,7 +384,7 @@ class Manager {
$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
$url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT; $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT;
$fields = array('token' => $token); $fields = ['token' => $token];
$client = $this->clientService->newClient(); $client = $this->clientService->newClient();
@ -502,7 +502,7 @@ class Manager {
WHERE `mountpoint_hash` = ? WHERE `mountpoint_hash` = ?
AND `user` = ? AND `user` = ?
'); ');
$result = (bool)$query->execute(array($target, $targetHash, $sourceHash, $this->uid)); $result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]);
return $result; return $result;
} }
@ -519,7 +519,7 @@ class Manager {
SELECT `remote`, `share_token`, `remote_id`, `share_type`, `id` SELECT `remote`, `share_token`, `remote_id`, `share_type`, `id`
FROM `*PREFIX*share_external` FROM `*PREFIX*share_external`
WHERE `mountpoint_hash` = ? AND `user` = ?'); WHERE `mountpoint_hash` = ? AND `user` = ?');
$result = $getShare->execute(array($hash, $this->uid)); $result = $getShare->execute([$hash, $this->uid]);
$share = $getShare->fetch(); $share = $getShare->fetch();
$getShare->closeCursor(); $getShare->closeCursor();
@ -535,13 +535,13 @@ class Manager {
DELETE FROM `*PREFIX*share_external` DELETE FROM `*PREFIX*share_external`
WHERE `id` = ? 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) { } else if ($result && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) {
$query = $this->connection->prepare(' $query = $this->connection->prepare('
UPDATE `*PREFIX*share_external` UPDATE `*PREFIX*share_external`
SET `accepted` = ? SET `accepted` = ?
WHERE `id` = ?'); WHERE `id` = ?');
$result = (bool)$query->execute(array(0, (int)$share['id'])); $result = (bool)$query->execute([0, (int)$share['id']]);
} }
if($result) { if($result) {
@ -585,7 +585,7 @@ class Manager {
SELECT `remote`, `share_token`, `remote_id` SELECT `remote`, `share_token`, `remote_id`
FROM `*PREFIX*share_external` FROM `*PREFIX*share_external`
WHERE `user` = ?'); WHERE `user` = ?');
$result = $getShare->execute(array($uid)); $result = $getShare->execute([$uid]);
if ($result) { if ($result) {
$shares = $getShare->fetchAll(); $shares = $getShare->fetchAll();
@ -598,7 +598,7 @@ class Manager {
DELETE FROM `*PREFIX*share_external` DELETE FROM `*PREFIX*share_external`
WHERE `user` = ? WHERE `user` = ?
'); ');
return (bool)$query->execute(array($uid)); return (bool)$query->execute([$uid]);
} }
/** /**

View File

@ -85,13 +85,13 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage {
$this->mountPoint = $options['mountpoint']; $this->mountPoint = $options['mountpoint'];
$this->token = $options['token']; $this->token = $options['token'];
parent::__construct(array( parent::__construct([
'secure' => $secure, 'secure' => $secure,
'host' => $host, 'host' => $host,
'root' => $root, 'root' => $root,
'user' => $options['token'], 'user' => $options['token'],
'password' => (string)$options['password'] 'password' => (string)$options['password']
)); ]);
} }
public function getWatcher($path = '', $storage = null) { public function getWatcher($path = '', $storage = null) {

View File

@ -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); 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) { if ($format === self::FORMAT_SHARED_STORAGE) {
// Only 1 item should come through for this format call // Only 1 item should come through for this format call
$item = array_shift($items); $item = array_shift($items);
return array( return [
'parent' => $item['parent'], 'parent' => $item['parent'],
'path' => $item['path'], 'path' => $item['path'],
'storage' => $item['storage'], 'storage' => $item['storage'],
'permissions' => $item['permissions'], 'permissions' => $item['permissions'],
'uid_owner' => $item['uid_owner'], 'uid_owner' => $item['uid_owner'],
); ];
} else if ($format === self::FORMAT_GET_FOLDER_CONTENTS) { } else if ($format === self::FORMAT_GET_FOLDER_CONTENTS) {
$files = array(); $files = [];
foreach ($items as $item) { foreach ($items as $item) {
$file = array(); $file = [];
$file['fileid'] = $item['file_source']; $file['fileid'] = $item['file_source'];
$file['storage'] = $item['storage']; $file['storage'] = $item['storage'];
$file['path'] = $item['file_target']; $file['path'] = $item['file_target'];
@ -157,31 +157,31 @@ class File implements \OCP\Share_Backend_File_Dependent {
} }
return $files; return $files;
} else if ($format === self::FORMAT_OPENDIR) { } else if ($format === self::FORMAT_OPENDIR) {
$files = array(); $files = [];
foreach ($items as $item) { foreach ($items as $item) {
$files[] = basename($item['file_target']); $files[] = basename($item['file_target']);
} }
return $files; return $files;
} else if ($format === self::FORMAT_GET_ALL) { } else if ($format === self::FORMAT_GET_ALL) {
$ids = array(); $ids = [];
foreach ($items as $item) { foreach ($items as $item) {
$ids[] = $item['file_source']; $ids[] = $item['file_source'];
} }
return $ids; return $ids;
} else if ($format === self::FORMAT_PERMISSIONS) { } else if ($format === self::FORMAT_PERMISSIONS) {
$filePermissions = array(); $filePermissions = [];
foreach ($items as $item) { foreach ($items as $item) {
$filePermissions[$item['file_source']] = $item['permissions']; $filePermissions[$item['file_source']] = $item['permissions'];
} }
return $filePermissions; return $filePermissions;
} else if ($format === self::FORMAT_TARGET_NAMES) { } else if ($format === self::FORMAT_TARGET_NAMES) {
$targets = array(); $targets = [];
foreach ($items as $item) { foreach ($items as $item) {
$targets[] = $item['file_target']; $targets[] = $item['file_target'];
} }
return $targets; return $targets;
} }
return array(); return [];
} }
/** /**

View File

@ -39,7 +39,7 @@ class Folder extends File implements \OCP\Share_Backend_Collection {
* @return array with shares * @return array with shares
*/ */
public function getParents($itemSource, $shareWith = null, $owner = null) { public function getParents($itemSource, $shareWith = null, $owner = null) {
$result = array(); $result = [];
$parent = $this->getParentId($itemSource); $parent = $this->getParentId($itemSource);
$userManager = \OC::$server->getUserManager(); $userManager = \OC::$server->getUserManager();
@ -89,8 +89,8 @@ class Folder extends File implements \OCP\Share_Backend_Collection {
} }
public function getChildren($itemSource) { public function getChildren($itemSource) {
$children = array(); $children = [];
$parents = array($itemSource); $parents = [$itemSource];
$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$qb->select('id') $qb->select('id')
@ -123,9 +123,9 @@ class Folder extends File implements \OCP\Share_Backend_Collection {
$result = $qb->execute(); $result = $qb->execute();
$parents = array(); $parents = [];
while ($file = $result->fetch()) { 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 a child folder is found look inside it
if ((int) $file['mimetype'] === $mimetype) { if ((int) $file['mimetype'] === $mimetype) {
$parents[] = $file['fileid']; $parents[] = $file['fileid'];

View File

@ -285,11 +285,11 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
} }
} }
} }
$info = array( $info = [
'target' => $this->getMountPoint() . $path, 'target' => $this->getMountPoint() . $path,
'source' => $source, 'source' => $source,
'mode' => $mode, 'mode' => $mode,
); ];
\OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info); \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info);
return $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode); return $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode);
} }

View File

@ -34,7 +34,7 @@ if ($token !== '') {
} else { } else {
http_response_code(307); http_response_code(307);
} }
header('Location: ' . $urlGenerator->linkToRoute($route, array('token' => $token))); header('Location: ' . $urlGenerator->linkToRoute($route, ['token' => $token]));
} else { } else {
http_response_code(404); http_response_code(404);
$tmpl = new OCP\Template('', '404', 'guest'); $tmpl = new OCP\Template('', '404', 'guest');

View File

@ -75,7 +75,7 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
<div class="directDownload"> <div class="directDownload">
<a href="<?php p($_['downloadURL']); ?>" id="downloadFile" class="button"> <a href="<?php p($_['downloadURL']); ?>" id="downloadFile" class="button">
<span class="icon icon-download"></span> <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> </a>
</div> </div>
<?php endif; ?> <?php endif; ?>

View File

@ -648,12 +648,12 @@ class ApiTest extends TestCase {
$share3->setStatus(IShare::STATUS_ACCEPTED); $share3->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share3); $this->shareManager->updateShare($share3);
$testValues=array( $testValues=[
array('query' => $this->folder, ['query' => $this->folder,
'expectedResult' => $this->folder . $this->filename), 'expectedResult' => $this->folder . $this->filename],
array('query' => $this->folder . $this->subfolder, ['query' => $this->folder . $this->subfolder,
'expectedResult' => $this->folder . $this->subfolder . $this->filename), 'expectedResult' => $this->folder . $this->subfolder . $this->filename],
); ];
foreach ($testValues as $value) { foreach ($testValues as $value) {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2);
@ -1214,7 +1214,7 @@ class ApiTest extends TestCase {
*/ */
public static function initTestMountPointsHook($data) { public static function initTestMountPointsHook($data) {
if ($data['user'] === self::TEST_FILES_SHARING_API_USER1) { 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. * Tests mounting a folder that is an external storage mount point.
*/ */
public function testShareStorageMountPoint() { public function testShareStorageMountPoint() {
$tempStorage = new \OC\Files\Storage\Temporary(array()); $tempStorage = new \OC\Files\Storage\Temporary([]);
$tempStorage->file_put_contents('test.txt', 'abcdef'); $tempStorage->file_put_contents('test.txt', 'abcdef');
$tempStorage->getScanner()->scan(''); $tempStorage->getScanner()->scan('');

View File

@ -148,63 +148,63 @@ class CacheTest extends TestCase {
} }
function searchDataProvider() { function searchDataProvider() {
return array( return [
array('%another%', ['%another%',
array( [
array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
array('name' => 'another.txt', 'path' => 'subdir/another.txt'), ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
) ]
), ],
array('%Another%', ['%Another%',
array( [
array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
array('name' => 'another.txt', 'path' => 'subdir/another.txt'), ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
) ]
), ],
array('%dir%', ['%dir%',
array( [
array('name' => 'emptydir', 'path' => 'emptydir'), ['name' => 'emptydir', 'path' => 'emptydir'],
array('name' => 'subdir', 'path' => 'subdir'), ['name' => 'subdir', 'path' => 'subdir'],
array('name' => 'shareddir', 'path' => ''), ['name' => 'shareddir', 'path' => ''],
) ]
), ],
array('%Dir%', ['%Dir%',
array( [
array('name' => 'emptydir', 'path' => 'emptydir'), ['name' => 'emptydir', 'path' => 'emptydir'],
array('name' => 'subdir', 'path' => 'subdir'), ['name' => 'subdir', 'path' => 'subdir'],
array('name' => 'shareddir', 'path' => ''), ['name' => 'shareddir', 'path' => ''],
) ]
), ],
array('%txt%', ['%txt%',
array( [
array('name' => 'bar.txt', 'path' => 'bar.txt'), ['name' => 'bar.txt', 'path' => 'bar.txt'],
array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
array('name' => 'another.txt', 'path' => 'subdir/another.txt'), ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
) ]
), ],
array('%Txt%', ['%Txt%',
array( [
array('name' => 'bar.txt', 'path' => 'bar.txt'), ['name' => 'bar.txt', 'path' => 'bar.txt'],
array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
array('name' => 'another.txt', 'path' => 'subdir/another.txt'), ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
) ]
), ],
array('%', ['%',
array( [
array('name' => 'bar.txt', 'path' => 'bar.txt'), ['name' => 'bar.txt', 'path' => 'bar.txt'],
array('name' => 'emptydir', 'path' => 'emptydir'), ['name' => 'emptydir', 'path' => 'emptydir'],
array('name' => 'subdir', 'path' => 'subdir'), ['name' => 'subdir', 'path' => 'subdir'],
array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
array('name' => 'another.txt', 'path' => 'subdir/another.txt'), ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
array('name' => 'not a text file.xml', 'path' => 'subdir/not a text file.xml'), ['name' => 'not a text file.xml', 'path' => 'subdir/not a text file.xml'],
array('name' => 'shareddir', 'path' => ''), ['name' => 'shareddir', 'path' => ''],
) ]
), ],
array('%nonexistent%', ['%nonexistent%',
array( [
) ]
), ],
); ];
} }
/** /**
@ -226,20 +226,20 @@ class CacheTest extends TestCase {
*/ */
function testSearchByMime() { function testSearchByMime() {
$results = $this->sharedStorage->getCache()->searchByMime('text'); $results = $this->sharedStorage->getCache()->searchByMime('text');
$check = array( $check = [
array( [
'name' => 'bar.txt', 'name' => 'bar.txt',
'path' => 'bar.txt' 'path' => 'bar.txt'
), ],
array( [
'name' => 'another too.txt', 'name' => 'another too.txt',
'path' => 'subdir/another too.txt' 'path' => 'subdir/another too.txt'
), ],
array( [
'name' => 'another.txt', 'name' => 'another.txt',
'path' => 'subdir/another.txt' 'path' => 'subdir/another.txt'
), ],
); ];
$this->verifyFiles($check, $results); $this->verifyFiles($check, $results);
} }
@ -250,27 +250,27 @@ class CacheTest extends TestCase {
// additional root will always contain the example file "welcome.txt", // additional root will always contain the example file "welcome.txt",
// so this will be part of the result // so this will be part of the result
$this->verifyFiles( $this->verifyFiles(
array( [
array( [
'name' => 'welcome.txt', 'name' => 'welcome.txt',
'path' => 'files/welcome.txt', 'path' => 'files/welcome.txt',
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
), ],
array( [
'name' => 'shareddir', 'name' => 'shareddir',
'path' => 'files/shareddir', 'path' => 'files/shareddir',
'mimetype' => 'httpd/unix-directory', 'mimetype' => 'httpd/unix-directory',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One', 'displayname_owner' => 'User One',
), ],
array( [
'name' => 'shared single file.txt', 'name' => 'shared single file.txt',
'path' => 'files/shared single file.txt', 'path' => 'files/shared single file.txt',
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One', 'displayname_owner' => 'User One',
), ],
), ],
$results $results
); );
} }
@ -279,29 +279,29 @@ class CacheTest extends TestCase {
$results = $this->user2View->getDirectoryContent('/shareddir'); $results = $this->user2View->getDirectoryContent('/shareddir');
$this->verifyFiles( $this->verifyFiles(
array( [
array( [
'name' => 'bar.txt', 'name' => 'bar.txt',
'path' => 'bar.txt', 'path' => 'bar.txt',
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One', 'displayname_owner' => 'User One',
), ],
array( [
'name' => 'emptydir', 'name' => 'emptydir',
'path' => 'emptydir', 'path' => 'emptydir',
'mimetype' => 'httpd/unix-directory', 'mimetype' => 'httpd/unix-directory',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One', 'displayname_owner' => 'User One',
), ],
array( [
'name' => 'subdir', 'name' => 'subdir',
'path' => 'subdir', 'path' => 'subdir',
'mimetype' => 'httpd/unix-directory', 'mimetype' => 'httpd/unix-directory',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One', 'displayname_owner' => 'User One',
), ],
), ],
$results $results
); );
} }
@ -327,29 +327,29 @@ class CacheTest extends TestCase {
$results = $thirdView->getDirectoryContent('/subdir'); $results = $thirdView->getDirectoryContent('/subdir');
$this->verifyFiles( $this->verifyFiles(
array( [
array( [
'name' => 'another too.txt', 'name' => 'another too.txt',
'path' => 'another too.txt', 'path' => 'another too.txt',
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One', 'displayname_owner' => 'User One',
), ],
array( [
'name' => 'another.txt', 'name' => 'another.txt',
'path' => 'another.txt', 'path' => 'another.txt',
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One', 'displayname_owner' => 'User One',
), ],
array( [
'name' => 'not a text file.xml', 'name' => 'not a text file.xml',
'path' => 'not a text file.xml', 'path' => 'not a text file.xml',
'mimetype' => 'application/xml', 'mimetype' => 'application/xml',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One', 'displayname_owner' => 'User One',
), ],
), ],
$results $results
); );
@ -376,7 +376,7 @@ class CacheTest extends TestCase {
} }
} }
} }
$this->assertEquals(array(), $results); $this->assertEquals([], $results);
} }
/** /**

View File

@ -1525,7 +1525,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn(true); ->willReturn(true);
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController') $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
->setMethods(array('canAccessShare')) ->setMethods(['canAccessShare'])
->getMock(); ->getMock();
$helper->method('canAccessShare') $helper->method('canAccessShare')
->with($share, $this->currentUser) ->with($share, $this->currentUser)
@ -2170,7 +2170,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn(true); ->willReturn(true);
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController') $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
->setMethods(array('createShare')) ->setMethods(['createShare'])
->getMock(); ->getMock();
$helper->method('createShare') $helper->method('createShare')
->with( ->with(
@ -2293,7 +2293,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn(true); ->willReturn(true);
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController') $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
->setMethods(array('createShare')) ->setMethods(['createShare'])
->getMock(); ->getMock();
$helper->method('createShare') $helper->method('createShare')
->with( ->with(
@ -4291,7 +4291,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn(true); ->willReturn(true);
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController') $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
->setMethods(array('formatShare')) ->setMethods(['formatShare'])
->getMock(); ->getMock();
$helper->method('formatShare') $helper->method('formatShare')
->with($share) ->with($share)

View File

@ -287,7 +287,7 @@ class ShareControllerTest extends \Test\TestCase {
}); });
$response = $this->shareController->showShare(); $response = $this->shareController->showShare();
$sharedTmplParams = array( $sharedTmplParams = [
'displayName' => 'ownerDisplay', 'displayName' => 'ownerDisplay',
'owner' => 'ownerUID', 'owner' => 'ownerUID',
'filename' => 'file1.txt', 'filename' => 'file1.txt',
@ -315,7 +315,7 @@ class ShareControllerTest extends \Test\TestCase {
'note' => $note, 'note' => $note,
'hideDownload' => false, 'hideDownload' => false,
'showgridview' => false 'showgridview' => false
); ];
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\''); $csp->addAllowedFrameDomain('\'self\'');
@ -427,7 +427,7 @@ class ShareControllerTest extends \Test\TestCase {
}); });
$response = $this->shareController->showShare(); $response = $this->shareController->showShare();
$sharedTmplParams = array( $sharedTmplParams = [
'displayName' => 'ownerDisplay', 'displayName' => 'ownerDisplay',
'owner' => 'ownerUID', 'owner' => 'ownerUID',
'filename' => 'file1.txt', 'filename' => 'file1.txt',
@ -455,7 +455,7 @@ class ShareControllerTest extends \Test\TestCase {
'note' => $note, 'note' => $note,
'hideDownload' => true, 'hideDownload' => true,
'showgridview' => false 'showgridview' => false
); ];
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\''); $csp->addAllowedFrameDomain('\'self\'');
@ -541,7 +541,7 @@ class ShareControllerTest extends \Test\TestCase {
unset($responseParams['folder']); unset($responseParams['folder']);
$response->setParams($responseParams); $response->setParams($responseParams);
$sharedTmplParams = array( $sharedTmplParams = [
'displayName' => 'ownerDisplay', 'displayName' => 'ownerDisplay',
'owner' => 'ownerUID', 'owner' => 'ownerUID',
'filename' => '/fileDrop', 'filename' => '/fileDrop',
@ -569,7 +569,7 @@ class ShareControllerTest extends \Test\TestCase {
'note' => '', 'note' => '',
'hideDownload' => false, 'hideDownload' => false,
'showgridview' => false 'showgridview' => false
); ];
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\''); $csp->addAllowedFrameDomain('\'self\'');

View File

@ -76,11 +76,11 @@ class CacheTest extends TestCase {
); );
$this->cache->put( $this->cache->put(
'test.txt', 'test.txt',
array( [
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
'size' => 5, 'size' => 5,
'mtime' => 123, 'mtime' => 123,
) ]
); );
} }
@ -107,19 +107,19 @@ class CacheTest extends TestCase {
public function testGetFolderPopulatesOwner() { public function testGetFolderPopulatesOwner() {
$dirId = $this->cache->put( $dirId = $this->cache->put(
'subdir', 'subdir',
array( [
'mimetype' => 'httpd/unix-directory', 'mimetype' => 'httpd/unix-directory',
'size' => 5, 'size' => 5,
'mtime' => 123, 'mtime' => 123,
) ]
); );
$this->cache->put( $this->cache->put(
'subdir/contents.txt', 'subdir/contents.txt',
array( [
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
'size' => 5, 'size' => 5,
'mtime' => 123, 'mtime' => 123,
) ]
); );
$results = $this->cache->getFolderContentsById($dirId); $results = $this->cache->getFolderContentsById($dirId);

View File

@ -39,37 +39,37 @@ use OCP\Http\Client\IResponse;
class ExternalStorageTest extends \Test\TestCase { class ExternalStorageTest extends \Test\TestCase {
function optionsProvider() { function optionsProvider() {
return array( return [
array( [
'http://remoteserver:8080/owncloud', 'http://remoteserver:8080/owncloud',
'http://remoteserver:8080/owncloud/public.php/webdav/', 'http://remoteserver:8080/owncloud/public.php/webdav/',
), ],
// extra slash // extra slash
array( [
'http://remoteserver:8080/owncloud/', 'http://remoteserver:8080/owncloud/',
'http://remoteserver:8080/owncloud/public.php/webdav/', 'http://remoteserver:8080/owncloud/public.php/webdav/',
), ],
// extra path // extra path
array( [
'http://remoteserver:8080/myservices/owncloud/', 'http://remoteserver:8080/myservices/owncloud/',
'http://remoteserver:8080/myservices/owncloud/public.php/webdav/', 'http://remoteserver:8080/myservices/owncloud/public.php/webdav/',
), ],
// root path // root path
array( [
'http://remoteserver:8080/', 'http://remoteserver:8080/',
'http://remoteserver:8080/public.php/webdav/', 'http://remoteserver:8080/public.php/webdav/',
), ],
// without port // without port
array( [
'http://remoteserver/oc.test', 'http://remoteserver/oc.test',
'http://remoteserver/oc.test/public.php/webdav/', 'http://remoteserver/oc.test/public.php/webdav/',
), ],
// https // https
array( [
'https://remoteserver/', 'https://remoteserver/',
'https://remoteserver/public.php/webdav/', 'https://remoteserver/public.php/webdav/',
), ],
); ];
} }
private function getTestStorage($uri) { private function getTestStorage($uri) {
@ -91,7 +91,7 @@ class ExternalStorageTest extends \Test\TestCase {
->willReturn($client); ->willReturn($client);
return new TestSharingExternalStorage( return new TestSharingExternalStorage(
array( [
'cloudId' => new CloudId('testOwner@' . $uri, 'testOwner', $uri), 'cloudId' => new CloudId('testOwner@' . $uri, 'testOwner', $uri),
'remote' => $uri, 'remote' => $uri,
'owner' => 'testOwner', 'owner' => 'testOwner',
@ -101,7 +101,7 @@ class ExternalStorageTest extends \Test\TestCase {
'manager' => null, 'manager' => null,
'certificateManager' => $certificateManager, 'certificateManager' => $certificateManager,
'HttpClientService' => $httpClientService, 'HttpClientService' => $httpClientService,
) ]
); );
} }

View File

@ -226,13 +226,13 @@ class ShareTest extends TestCase {
$permission5 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE; $permission5 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE;
$permission6 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE; $permission6 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE;
return array( return [
array($permission1, false), [$permission1, false],
array($permission3, true), [$permission3, true],
array($permission4, true), [$permission4, true],
array($permission5, false), [$permission5, false],
array($permission6, false), [$permission6, false],
); ];
} }
public function testFileOwner() { public function testFileOwner() {

View File

@ -251,14 +251,14 @@ class SharedMountTest extends TestCase {
} }
public function dataProviderTestStripUserFilesPath() { public function dataProviderTestStripUserFilesPath() {
return array( return [
array('/user/files/foo.txt', '/foo.txt', false), ['/user/files/foo.txt', '/foo.txt', false],
array('/user/files/folder/foo.txt', '/folder/foo.txt', false), ['/user/files/folder/foo.txt', '/folder/foo.txt', false],
array('/data/user/files/foo.txt', null, true), ['/data/user/files/foo.txt', null, true],
array('/data/user/files/', null, true), ['/data/user/files/', null, true],
array('/files/foo.txt', null, true), ['/files/foo.txt', null, true],
array('/foo.txt', null, true), ['/foo.txt', null, true],
); ];
} }
public function dataPermissionMovedGroupShare() { public function dataPermissionMovedGroupShare() {

View File

@ -406,7 +406,7 @@ class SharedStorageTest extends TestCase {
$mountConfigManager = \OC::$server->getMountProviderCollection(); $mountConfigManager = \OC::$server->getMountProviderCollection();
$mounts = $mountConfigManager->getMountsForUser(\OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3)); $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)); $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); list($sharedStorage,) = $view->resolvePath($this->folder);
$this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')); $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'); $sourceStorage->file_put_contents('foo.txt', 'asd');
$sharedStorage->copyFromStorage($sourceStorage, 'foo.txt', 'bar.txt'); $sharedStorage->copyFromStorage($sourceStorage, 'foo.txt', 'bar.txt');
@ -476,7 +476,7 @@ class SharedStorageTest extends TestCase {
list($sharedStorage,) = $view->resolvePath($this->folder); list($sharedStorage,) = $view->resolvePath($this->folder);
$this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')); $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'); $sourceStorage->file_put_contents('foo.txt', 'asd');
$sharedStorage->moveFromStorage($sourceStorage, 'foo.txt', 'bar.txt'); $sharedStorage->moveFromStorage($sourceStorage, 'foo.txt', 'bar.txt');

View File

@ -115,9 +115,9 @@ class WatcherTest extends TestCase {
$textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$dataLen = strlen($textData); $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->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 // run the propagation code
$this->sharedStorage->getWatcher()->checkUpdate(''); $this->sharedStorage->getWatcher()->checkUpdate('');
@ -145,9 +145,9 @@ class WatcherTest extends TestCase {
$textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$dataLen = strlen($textData); $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->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 // run the propagation code
$this->sharedStorage->getWatcher()->checkUpdate('subdir'); $this->sharedStorage->getWatcher()->checkUpdate('subdir');
@ -173,7 +173,7 @@ class WatcherTest extends TestCase {
* @param string $path * @param string $path
*/ */
function getOwnerDirSizes($path) { function getOwnerDirSizes($path) {
$result = array(); $result = [];
while ($path != '' && $path != '' && $path != '.') { while ($path != '' && $path != '' && $path != '.') {
$cachedData = $this->ownerCache->get($path); $cachedData = $this->ownerCache->get($path);

View File

@ -46,7 +46,7 @@ class Helper {
* @return \OCP\Files\FileInfo[] * @return \OCP\Files\FileInfo[]
*/ */
public static function getTrashFiles($dir, $user, $sortAttribute = '', $sortDescending = false) { public static function getTrashFiles($dir, $user, $sortAttribute = '', $sortDescending = false) {
$result = array(); $result = [];
$timestamp = null; $timestamp = null;
$view = new \OC\Files\View('/' . $user . '/files_trashbin/files'); $view = new \OC\Files\View('/' . $user . '/files_trashbin/files');
@ -84,7 +84,7 @@ class Helper {
} }
} }
$type = $entry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE ? 'dir' : 'file'; $type = $entry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE ? 'dir' : 'file';
$i = array( $i = [
'name' => $name, 'name' => $name,
'mtime' => $timestamp, 'mtime' => $timestamp,
'mimetype' => $type === 'dir' ? 'httpd/unix-directory' : \OC::$server->getMimeTypeDetector()->detectPath($name), 'mimetype' => $type === 'dir' ? 'httpd/unix-directory' : \OC::$server->getMimeTypeDetector()->detectPath($name),
@ -94,7 +94,7 @@ class Helper {
'etag' => '', 'etag' => '',
'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE, 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE,
'fileid' => $entry->getId(), 'fileid' => $entry->getId(),
); ];
if ($originalPath) { if ($originalPath) {
if ($originalPath !== '.') { if ($originalPath !== '.') {
$i['extraData'] = $originalPath . '/' . $originalName; $i['extraData'] = $originalPath . '/' . $originalName;
@ -117,7 +117,7 @@ class Helper {
* @param \OCP\Files\FileInfo[] $fileInfos file infos * @param \OCP\Files\FileInfo[] $fileInfos file infos
*/ */
public static function formatFileInfos($fileInfos) { public static function formatFileInfos($fileInfos) {
$files = array(); $files = [];
foreach ($fileInfos as $i) { foreach ($fileInfos as $i) {
$entry = \OCA\Files\Helper::formatFileInfo($i); $entry = \OCA\Files\Helper::formatFileInfo($i);
$entry['id'] = $i->getId(); $entry['id'] = $i->getId();

Some files were not shown because too many files have changed in this diff Show More