Merge pull request #20168 from nextcloud/techdebt/short-array-syntax

Use the short array syntax, everywhere
This commit is contained in:
Joas Schilling 2020-03-26 16:35:30 +01:00 committed by GitHub
commit 0c3e2fac54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
454 changed files with 4214 additions and 4214 deletions

View File

@ -57,7 +57,7 @@ class AccessibilityProvider {
}
public function getThemes() {
return array(
return [
[
'id' => 'dark',
'img' => $this->urlGenerator->imagePath($this->appName, 'theme-dark.jpg'),
@ -65,7 +65,7 @@ class AccessibilityProvider {
'enableLabel' => $this->l->t('Enable dark theme'),
'text' => $this->l->t('A dark theme to ease your eyes by reducing the overall luminosity and brightness. It is still under development, so please report any issues you may find.')
]
);
];
}
public function getHighContrast() {
@ -79,7 +79,7 @@ class AccessibilityProvider {
}
public function getFonts() {
return array(
return [
[
'id' => 'fontdyslexic',
'img' => $this->urlGenerator->imagePath($this->appName, 'font-opendyslexic.jpg'),
@ -87,7 +87,7 @@ class AccessibilityProvider {
'enableLabel' => $this->l->t('Enable dyslexia font'),
'text' => $this->l->t('OpenDyslexic is a free typeface/font designed to mitigate some of the common reading errors caused by dyslexia.')
]
);
];
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

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
$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE));
return new \OC\Files\Storage\Wrapper\PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]);
});
\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);

View File

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

View File

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

View File

@ -74,9 +74,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
private $sharingBackend;
/** @var array properties to index */
public static $indexProperties = array(
public static $indexProperties = [
'BDAY', 'UID', 'N', 'FN', 'TITLE', 'ROLE', 'NOTE', 'NICKNAME',
'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO', 'CLOUD');
'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO', 'CLOUD'];
/**
* @var string[] Map of uid => display name
@ -909,7 +909,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped, otherwise they are
* @return array an array of contacts which are arrays of key-value-pairs
*/
public function search($addressBookId, $pattern, $searchProperties, $options = array()) {
public function search($addressBookId, $pattern, $searchProperties, $options = []) {
$query = $this->db->getQueryBuilder();
$query2 = $this->db->getQueryBuilder();

View File

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

View File

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

View File

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

View File

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

View File

@ -359,20 +359,20 @@ class File extends Node implements IFile {
$run = true;
if (!$exists) {
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create, array(
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create, [
\OC\Files\Filesystem::signal_param_path => $hookPath,
\OC\Files\Filesystem::signal_param_run => &$run,
));
]);
} else {
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_update, array(
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_update, [
\OC\Files\Filesystem::signal_param_path => $hookPath,
\OC\Files\Filesystem::signal_param_run => &$run,
));
]);
}
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_write, array(
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_write, [
\OC\Files\Filesystem::signal_param_path => $hookPath,
\OC\Files\Filesystem::signal_param_run => &$run,
));
]);
return $run;
}
@ -385,17 +385,17 @@ class File extends Node implements IFile {
}
$hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
if (!$exists) {
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, array(
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, [
\OC\Files\Filesystem::signal_param_path => $hookPath
));
]);
} else {
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_update, array(
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_update, [
\OC\Files\Filesystem::signal_param_path => $hookPath
));
]);
}
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_write, array(
\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_write, [
\OC\Files\Filesystem::signal_param_path => $hookPath
));
]);
}
/**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -410,7 +410,7 @@ class PrincipalTest extends TestCase {
}
public function testUpdatePrincipal() {
$this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch(array())));
$this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch([])));
}
public function testSearchPrincipalsWithEmptySearchProperties() {

View File

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

View File

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

View File

@ -184,7 +184,7 @@ class GroupPrincipalTest extends \Test\TestCase {
}
public function testUpdatePrincipal() {
$this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch(array())));
$this->assertSame(0, $this->connector->updatePrincipal('foo', new PropPatch([])));
}
public function testSearchPrincipalsWithEmptySearchProperties() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,9 +2,9 @@
/** @var OC_Theme $theme */
/** @var array $_ */
print_unescaped($l->t("Hey there,\n\nthe admin enabled server-side-encryption. Your files were encrypted using the password '%s'.\n\nPlease login to the web interface, go to the section 'basic encryption module' of your personal settings and update your encryption password by entering this password into the 'old log-in password' field and your current login-password.\n\n", array($_['password'])));
print_unescaped($l->t("Hey there,\n\nthe admin enabled server-side-encryption. Your files were encrypted using the password '%s'.\n\nPlease login to the web interface, go to the section 'basic encryption module' of your personal settings and update your encryption password by entering this password into the 'old log-in password' field and your current login-password.\n\n", [$_['password']]));
if ( isset($_['expiration']) ) {
print_unescaped($l->t("The share will expire on %s.", array($_['expiration'])));
print_unescaped($l->t("The share will expire on %s.", [$_['expiration']]));
print_unescaped("\n\n");
}
// TRANSLATORS term at the end of a mail

View File

@ -15,7 +15,7 @@
<td width="20px">&nbsp;</td>
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php
print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', array($_['password'])));
print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', [$_['password']]));
// TRANSLATORS term at the end of a mail
p($l->t('Cheers!'));
?>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -38,7 +38,7 @@ $dir = isset($_GET['dir']) ? (string)$_GET['dir'] : '';
$files_list = json_decode($files);
// in case we get only a single file
if (!is_array($files_list)) {
$files_list = array($files);
$files_list = [$files];
}
/**
@ -52,7 +52,7 @@ if(isset($_GET['downloadStartSecret'])
setcookie('ocDownloadStarted', $_GET['downloadStartSecret'], time() + 20, '/');
}
$server_params = array( 'head' => \OC::$server->getRequest()->getMethod() === 'HEAD' );
$server_params = [ 'head' => \OC::$server->getRequest()->getMethod() === 'HEAD' ];
/**
* Http range requests support

View File

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

View File

@ -36,7 +36,7 @@ $app = \OC::$server->query(Application::class);
// t('Files')
$l = \OC::$server->getL10N('files');
\OC::$server->getSearch()->registerProvider(File::class, array('apps' => array('files')));
\OC::$server->getSearch()->registerProvider(File::class, ['apps' => ['files']]);
$templateManager = \OC_Helper::getFileTemplateManager();
$templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp');

View File

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

View File

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

View File

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

View File

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

View File

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

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>
<input id="webdavurl" type="text" readonly="readonly"
value="<?php p($_['webdav_url']); ?>"/>
<em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer noopener">access your Files via WebDAV</a>', array(link_to_docs('user-webdav')))); ?></em>
<em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer noopener">access your Files via WebDAV</a>', [link_to_docs('user-webdav')])); ?></em>
</div>
</div>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -171,7 +171,7 @@ class GlobalStoragesController extends StoragesController {
} catch (NotFoundException $e) {
return new DataResponse(
[
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
],
Http::STATUS_NOT_FOUND
);

View File

@ -124,7 +124,7 @@ class UserGlobalStoragesController extends StoragesController {
} catch (NotFoundException $e) {
return new DataResponse(
[
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
],
Http::STATUS_NOT_FOUND
);
@ -164,7 +164,7 @@ class UserGlobalStoragesController extends StoragesController {
} else {
return new DataResponse(
[
'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', array($id))
'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id])
],
Http::STATUS_FORBIDDEN
);
@ -172,7 +172,7 @@ class UserGlobalStoragesController extends StoragesController {
} catch (NotFoundException $e) {
return new DataResponse(
[
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
],
Http::STATUS_NOT_FOUND
);

View File

@ -199,7 +199,7 @@ class UserStoragesController extends StoragesController {
} catch (NotFoundException $e) {
return new DataResponse(
[
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
],
Http::STATUS_NOT_FOUND
);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,15 +33,15 @@ if (file_exists($privateConfigFile)) {
}
// this is now more a template now for your private configurations
return array(
'ftp'=>array(
return [
'ftp'=>[
'run'=>false,
'host'=>'localhost',
'user'=>'test',
'password'=>'test',
'root'=>'/test',
),
'webdav'=>array(
],
'webdav'=>[
'run'=>false,
'host'=>'localhost',
'user'=>'test',
@ -51,15 +51,15 @@ return array(
// (only in tests)
// set to higher value for lighttpd webdav
'wait'=> 0
),
'owncloud'=>array(
],
'owncloud'=>[
'run'=>false,
'host'=>'localhost/owncloud',
'user'=>'test',
'password'=>'test',
'root'=>'',
),
'swift' => array(
],
'swift' => [
'run' => false,
'user' => 'test',
'bucket' => 'test',
@ -70,16 +70,16 @@ return array(
//'service_name' => 'swift', //should be 'swift' for OpenStack Object Storage and 'cloudFiles' for Rackspace Cloud Files (default value)
//'url' => 'https://identity.api.rackspacecloud.com/v2.0/', //to be used with Rackspace Cloud Files and OpenStack Object Storage
//'timeout' => 5 // timeout of HTTP requests in seconds
),
'smb'=>array(
],
'smb'=>[
'run'=>false,
'user'=>'test',
'password'=>'test',
'host'=>'localhost',
'share'=>'/test',
'root'=>'/test/',
),
'amazons3'=>array(
],
'amazons3'=>[
'run'=>false,
'key'=>'test',
'secret'=>'test',
@ -90,20 +90,20 @@ return array(
//'region' => 'eu-west-1',
//'test'=>'true',
//'timeout'=>20
),
'sftp' => array (
],
'sftp' => [
'run'=>false,
'host'=>'localhost',
'user'=>'test',
'password'=>'test',
'root'=>'/test'
),
'sftp_key' => array (
],
'sftp_key' => [
'run'=>false,
'host'=>'localhost',
'user'=>'test',
'public_key'=>'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDJPTvz3OLonF2KSGEKP/nd4CPmRYvemG2T4rIiNYjDj0U5y+2sKEWbjiUlQl2bsqYuVoJ+/UNJlGQbbZ08kQirFeo1GoWBzqioaTjUJfbLN6TzVVKXxR9YIVmH7Ajg2iEeGCndGgbmnPfj+kF9TR9IH8vMVvtubQwf7uEwB0ALhw== phpseclib-generated-key',
'private_key'=>'test',
'root'=>'/test'
),
);
],
];

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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

View File

@ -75,7 +75,7 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
<div class="directDownload">
<a href="<?php p($_['downloadURL']); ?>" id="downloadFile" class="button">
<span class="icon icon-download"></span>
<?php p($l->t('Download %s', array($_['filename'])))?> (<?php p($_['fileSize']) ?>)
<?php p($l->t('Download %s', [$_['filename']]))?> (<?php p($_['fileSize']) ?>)
</a>
</div>
<?php endif; ?>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -406,7 +406,7 @@ class SharedStorageTest extends TestCase {
$mountConfigManager = \OC::$server->getMountProviderCollection();
$mounts = $mountConfigManager->getMountsForUser(\OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3));
array_walk($mounts, array(\OC\Files\Filesystem::getMountManager(), 'addMount'));
array_walk($mounts, [\OC\Files\Filesystem::getMountManager(), 'addMount']);
$this->assertTrue($rootView->file_exists('/' . self::TEST_FILES_SHARING_API_USER3 . '/files/' . $this->filename));
@ -443,7 +443,7 @@ class SharedStorageTest extends TestCase {
list($sharedStorage,) = $view->resolvePath($this->folder);
$this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage'));
$sourceStorage = new \OC\Files\Storage\Temporary(array());
$sourceStorage = new \OC\Files\Storage\Temporary([]);
$sourceStorage->file_put_contents('foo.txt', 'asd');
$sharedStorage->copyFromStorage($sourceStorage, 'foo.txt', 'bar.txt');
@ -476,7 +476,7 @@ class SharedStorageTest extends TestCase {
list($sharedStorage,) = $view->resolvePath($this->folder);
$this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage'));
$sourceStorage = new \OC\Files\Storage\Temporary(array());
$sourceStorage = new \OC\Files\Storage\Temporary([]);
$sourceStorage->file_put_contents('foo.txt', 'asd');
$sharedStorage->moveFromStorage($sourceStorage, 'foo.txt', 'bar.txt');

View File

@ -115,9 +115,9 @@ class WatcherTest extends TestCase {
$textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$dataLen = strlen($textData);
$this->sharedCache->put('bar.txt', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
$this->sharedCache->put('bar.txt', ['mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain']);
$this->sharedStorage->file_put_contents('bar.txt', $textData);
$this->sharedCache->put('', array('mtime' => 10, 'storage_mtime' => 10, 'size' => '-1', 'mimetype' => 'httpd/unix-directory'));
$this->sharedCache->put('', ['mtime' => 10, 'storage_mtime' => 10, 'size' => '-1', 'mimetype' => 'httpd/unix-directory']);
// run the propagation code
$this->sharedStorage->getWatcher()->checkUpdate('');
@ -145,9 +145,9 @@ class WatcherTest extends TestCase {
$textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$dataLen = strlen($textData);
$this->sharedCache->put('subdir/bar.txt', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
$this->sharedCache->put('subdir/bar.txt', ['mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain']);
$this->sharedStorage->file_put_contents('subdir/bar.txt', $textData);
$this->sharedCache->put('subdir', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
$this->sharedCache->put('subdir', ['mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain']);
// run the propagation code
$this->sharedStorage->getWatcher()->checkUpdate('subdir');
@ -173,7 +173,7 @@ class WatcherTest extends TestCase {
* @param string $path
*/
function getOwnerDirSizes($path) {
$result = array();
$result = [];
while ($path != '' && $path != '' && $path != '.') {
$cachedData = $this->ownerCache->get($path);

View File

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

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