Unverified Commit 9c1147b6 authored by Thomas Müller's avatar Thomas Müller
Browse files

Use short array syntax

parent 97abaddc
......@@ -79,12 +79,12 @@ class Extension implements IExtension {
public function getNotificationTypes($languageCode) {
$l = $this->getL10N($languageCode);
return array(
return [
self::APP_NAME => [
'desc' => (string) $l->t('<strong>Comments</strong> for files <em>(always listed in stream)</em>'),
'methods' => [self::METHOD_MAIL], // self::METHOD_STREAM is forced true by the default value
],
);
];
}
/**
......
......@@ -57,10 +57,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);
......
......@@ -57,10 +57,10 @@ $principalCollection->disableListing = !$debugging; // Disable listing
$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend);
$addressBookRoot->disableListing = !$debugging; // Disable listing
$nodes = array(
$nodes = [
$principalCollection,
$addressBookRoot,
);
];
// Fire up server
$server = new \Sabre\DAV\Server($nodes);
......
......@@ -69,7 +69,7 @@ $server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, func
$fileId = $share->getNodeId();
\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_Util::setupFS($owner);
......
......@@ -38,7 +38,7 @@ class Application extends App {
*
* @param array $urlParams
*/
public function __construct (array $urlParams=array()) {
public function __construct (array $urlParams= []) {
parent::__construct('dav', $urlParams);
}
......
......@@ -136,7 +136,7 @@ class BirthdayService {
return null;
}
$title = str_replace('{name}',
strtr((string)$doc->FN, array('\,' => ',', '\;' => ';')),
strtr((string)$doc->FN, ['\,' => ',', '\;' => ';']),
'{name}'
);
try {
......
......@@ -1221,7 +1221,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
}
}
$valuesToInsert = array();
$valuesToInsert = [];
$query = $this->db->getQueryBuilder();
......
......@@ -60,9 +60,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 EventDispatcherInterface */
private $dispatcher;
......
......@@ -73,7 +73,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);
}
/**
......
......@@ -59,7 +59,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']);
}
/**
......
......@@ -39,7 +39,7 @@ class CustomPropertiesBackend implements BackendInterface {
*
* @var array
*/
private $ignoredProperties = array(
private $ignoredProperties = [
'{DAV:}getcontentlength',
'{DAV:}getcontenttype',
'{DAV:}getetag',
......@@ -50,7 +50,7 @@ class CustomPropertiesBackend implements BackendInterface {
'{http://owncloud.org/ns}downloadURL',
'{http://owncloud.org/ns}dDC',
'{http://owncloud.org/ns}size',
);
];
/**
* @var Tree
......@@ -113,7 +113,7 @@ class CustomPropertiesBackend implements BackendInterface {
// (soft fail)
\OC::$server->getLogger()->warning(
'Could not get node for path: \"' . $path . '\" : ' . $e->getMessage(),
array('app' => 'files')
['app' => 'files']
);
return;
}
......@@ -171,7 +171,7 @@ class CustomPropertiesBackend implements BackendInterface {
$statement = $this->connection->prepare(
'DELETE FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?'
);
$statement->execute(array($this->user, '/' . $path));
$statement->execute([$this->user, '/' . $path]);
$statement->closeCursor();
unset($this->cache[$path]);
......@@ -190,7 +190,7 @@ class CustomPropertiesBackend implements BackendInterface {
'UPDATE `*PREFIX*properties` SET `propertypath` = ?' .
' WHERE `userid` = ? AND `propertypath` = ?'
);
$statement->execute(array('/' . $destination, $this->user, '/' . $source));
$statement->execute(['/' . $destination, $this->user, '/' . $source]);
$statement->closeCursor();
}
......@@ -213,8 +213,8 @@ class CustomPropertiesBackend implements BackendInterface {
// TODO: chunking if more than 1000 properties
$sql = 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?';
$whereValues = array($this->user, $path);
$whereTypes = array(null, null);
$whereValues = [$this->user, $path];
$whereTypes = [null, null];
if (!empty($requestedProperties)) {
// request only a subset
......@@ -261,38 +261,38 @@ class CustomPropertiesBackend implements BackendInterface {
' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?';
// TODO: use "insert or update" strategy ?
$existing = $this->getProperties($node, array());
$existing = $this->getProperties($node, []);
$this->connection->beginTransaction();
foreach ($properties as $propertyName => $propertyValue) {
// If it was null, we need to delete the property
if (is_null($propertyValue)) {
if (array_key_exists($propertyName, $existing)) {
$this->connection->executeUpdate($deleteStatement,
array(
[
$this->user,
$path,
$propertyName
)
]
);
}
} else {
if (!array_key_exists($propertyName, $existing)) {
$this->connection->executeUpdate($insertStatement,
array(
[
$this->user,
$path,
$propertyName,
$propertyValue
)
]
);
} else {
$this->connection->executeUpdate($updateStatement,
array(
[
$propertyValue,
$this->user,
$path,
$propertyName
)
]
);
}
}
......@@ -330,8 +330,8 @@ class CustomPropertiesBackend implements BackendInterface {
$result = $this->connection->executeQuery(
$sql,
array($this->user, $this->connection->escapeLikeParameter(rtrim($path, '/')) . '/%', $requestedProperties),
array(null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
[$this->user, $this->connection->escapeLikeParameter(rtrim($path, '/')) . '/%', $requestedProperties],
[null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY]
);
$oldPath = null;
......
......@@ -142,7 +142,7 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node
$path = $this->fileView->getAbsolutePath($this->path) . '/' . $name;
// using a dummy FileInfo is acceptable here since it will be refreshed after the put is complete
$info = new \OC\Files\FileInfo($path, null, null, array(), null);
$info = new \OC\Files\FileInfo($path, null, null, [], null);
$node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info);
$node->acquireLock(ILockingProvider::LOCK_SHARED);
return $node->put($data);
......@@ -254,7 +254,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;
......@@ -323,13 +323,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];
}
}
......
......@@ -31,7 +31,7 @@ use Sabre\DAV\Exception;
use Sabre\HTTP\Response;
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
protected $nonFatalExceptions = array(
protected $nonFatalExceptions = [
'Sabre\DAV\Exception\NotAuthenticated' => true,
// the sync client uses this to find out whether files exist,
// so it is not always an error, log it as debug
......@@ -45,7 +45,7 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
'Sabre\DAV\Exception\Forbidden' => true,
// Custom exception similar to NotAuthenticated
'OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden' => true,
);
];
/** @var string */
private $appName;
......@@ -75,7 +75,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);
}
/**
......
......@@ -252,20 +252,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;
}
......@@ -278,17 +278,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
));
]);
}
/**
......
......@@ -155,12 +155,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)) {
......
......@@ -141,7 +141,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']);
}
/**
......
......@@ -66,7 +66,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);
}
/**
......
......@@ -189,7 +189,7 @@ 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]);
}
/**
......
......@@ -68,8 +68,8 @@ class QuotaPlugin extends \Sabre\DAV\ServerPlugin {
$this->server = $server;
$server->on('beforeWriteContent', array($this, 'checkQuota'), 10);
$server->on('beforeCreateFile', array($this, 'checkQuota'), 10);
$server->on('beforeWriteContent', [$this, 'checkQuota'], 10);
$server->on('beforeCreateFile', [$this, 'checkQuota'], 10);
}
/**
......
......@@ -99,7 +99,7 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
$server->protectedProperties[] = self::SHARETYPES_PROPERTYNAME;
$this->server = $server;
$this->server->on('propFind', array($this, 'handleGetProperties'));
$this->server->on('propFind', [$this, 'handleGetProperties']);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment