@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Balloon |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param object|array $config |
| 54 | 54 | * @return bool |
| 55 | 55 | */ |
| 56 | - public function registerPlugin($name, $config=null): bool |
|
| 56 | + public function registerPlugin($name, $config = null): bool |
|
| 57 | 57 | { |
| 58 | 58 | if ($name instanceof Config) { |
| 59 | 59 | foreach ($name as $id => $config) { |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @param array $context |
| 113 | 113 | * @return bool |
| 114 | 114 | */ |
| 115 | - public function run(string $method, array $context=[]): bool |
|
| 115 | + public function run(string $method, array $context = []): bool |
|
| 116 | 116 | { |
| 117 | 117 | $this->logger->debug('execute plugins hooks for ['.$method.']', [ |
| 118 | 118 | 'category' => get_class($this), |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | } else { |
| 225 | 225 | $this->logger->debug('requested path ['.$this->path.'] does not match route ['.$route->getPath().']', [ |
| 226 | - 'category' => get_class($this), |
|
| 226 | + 'category' => get_class($this), |
|
| 227 | 227 | ]); |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -267,22 +267,22 @@ discard block |
||
| 267 | 267 | ]; |
| 268 | 268 | |
| 269 | 269 | switch (get_class($exception)) { |
| 270 | - case 'Balloon\\Exception\\InvalidArgument': |
|
| 270 | + case 'Balloon\\Exception\\InvalidArgument': |
|
| 271 | 271 | case 'Balloon\\Exception\\Conflict': |
| 272 | 272 | $code = 400; |
| 273 | - break; |
|
| 274 | - case 'Balloon\\Exception\\NotFound': |
|
| 273 | + break; |
|
| 274 | + case 'Balloon\\Exception\\NotFound': |
|
| 275 | 275 | $code = 404; |
| 276 | - break; |
|
| 277 | - case 'Balloon\\Exception\\Forbidden': |
|
| 276 | + break; |
|
| 277 | + case 'Balloon\\Exception\\Forbidden': |
|
| 278 | 278 | $code = 403; |
| 279 | - break; |
|
| 280 | - case 'Balloon\\Exception\\InsufficientStorage': |
|
| 279 | + break; |
|
| 280 | + case 'Balloon\\Exception\\InsufficientStorage': |
|
| 281 | 281 | $code = 507; |
| 282 | - break; |
|
| 283 | - default: |
|
| 282 | + break; |
|
| 283 | + default: |
|
| 284 | 284 | $code = 500; |
| 285 | - break; |
|
| 285 | + break; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $this->logger->error('uncaught exception '.$message.']', [ |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Balloon |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param array $constructor |
| 197 | 197 | * @return bool |
| 198 | 198 | */ |
| 199 | - public function run(array $constructor=[]): bool |
|
| 199 | + public function run(array $constructor = []): bool |
|
| 200 | 200 | { |
| 201 | 201 | $this->logger->info('execute requested route ['.$this->path.']', [ |
| 202 | 202 | 'category' => get_class($this), |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | if (!empty($body)) { |
| 320 | 320 | $json_params = json_decode($body, true); |
| 321 | 321 | } else { |
| 322 | - $parts = explode('&', $_SERVER['QUERY_STRING']); |
|
| 322 | + $parts = explode('&', $_SERVER['QUERY_STRING']); |
|
| 323 | 323 | if (!empty($parts)) { |
| 324 | 324 | $json_params = json_decode(urldecode($parts[0]), true); |
| 325 | 325 | } |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Balloon |
@@ -282,13 +282,13 @@ |
||
| 282 | 282 | |
| 283 | 283 | |
| 284 | 284 | /** |
| 285 | - * Converts mixed data to XML |
|
| 286 | - * |
|
| 287 | - * @param mixed $data |
|
| 288 | - * @param SimpleXMLElement $xml |
|
| 289 | - * @param string|int $child_name |
|
| 290 | - * @return string |
|
| 291 | - */ |
|
| 285 | + * Converts mixed data to XML |
|
| 286 | + * |
|
| 287 | + * @param mixed $data |
|
| 288 | + * @param SimpleXMLElement $xml |
|
| 289 | + * @param string|int $child_name |
|
| 290 | + * @return string |
|
| 291 | + */ |
|
| 292 | 292 | public function toXML($data, SimpleXMLElement $xml, $child_name): string |
| 293 | 293 | { |
| 294 | 294 | if (is_object($data)) { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Balloon |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param bool $body_only |
| 159 | 159 | * @return Response |
| 160 | 160 | */ |
| 161 | - public function setBody($body, bool $body_only=false): Response |
|
| 161 | + public function setBody($body, bool $body_only = false): Response |
|
| 162 | 162 | { |
| 163 | 163 | $this->body = $body; |
| 164 | 164 | $this->body_only = $body_only; |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | $this->sendHeaders(); |
| 188 | 188 | $status = Http::STATUS_CODES[$this->code]; |
| 189 | - header('HTTP/1.0 ' . $this->code . ' ' . $status, true, $this->code); |
|
| 189 | + header('HTTP/1.0 '.$this->code.' '.$status, true, $this->code); |
|
| 190 | 190 | |
| 191 | 191 | if ($this->body === null && $this->code == 204) { |
| 192 | 192 | $this->terminate(); |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @return Delta |
| 206 | 206 | */ |
| 207 | - public function getDelta(): Delta |
|
| 208 | - { |
|
| 209 | - if ($this->delta instanceof Delta) { |
|
| 210 | - return $this->delta; |
|
| 211 | - } |
|
| 207 | + public function getDelta(): Delta |
|
| 208 | + { |
|
| 209 | + if ($this->delta instanceof Delta) { |
|
| 210 | + return $this->delta; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - return $this->delta = new Delta($this); |
|
| 214 | - } |
|
| 213 | + return $this->delta = new Delta($this); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -579,8 +579,8 @@ discard block |
||
| 579 | 579 | protected function _searchElastic(array $query, array $shares): array |
| 580 | 580 | { |
| 581 | 581 | $client = \Elasticsearch\ClientBuilder::create() |
| 582 | - ->setHosts((array)$this->config->search->hosts->server) |
|
| 583 | - ->build(); |
|
| 582 | + ->setHosts((array)$this->config->search->hosts->server) |
|
| 583 | + ->build(); |
|
| 584 | 584 | |
| 585 | 585 | $bool = $query['body']['query']; |
| 586 | 586 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Balloon |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @param int $deleted |
| 296 | 296 | * @return INode |
| 297 | 297 | */ |
| 298 | - public function findNodeWithId($id, ?string $class=null, int $deleted=INode::DELETED_INCLUDE): INode |
|
| 298 | + public function findNodeWithId($id, ?string $class = null, int $deleted = INode::DELETED_INCLUDE) : INode |
|
| 299 | 299 | { |
| 300 | 300 | if (!is_string($id) && !($id instanceof ObjectID)) { |
| 301 | 301 | throw new Exception\InvalidArgument($id.' node id has to be a string or instance of \MongoDB\BSON\ObjectID'); |
@@ -353,13 +353,13 @@ discard block |
||
| 353 | 353 | * @param string $class Fore check node type |
| 354 | 354 | * @return INode |
| 355 | 355 | */ |
| 356 | - public function findNodeWithPath(string $path='', ?string $class=null): INode |
|
| 356 | + public function findNodeWithPath(string $path = '', ?string $class = null) : INode |
|
| 357 | 357 | { |
| 358 | 358 | if (empty($path) || $path[0] != '/') { |
| 359 | 359 | $path = '/'.$path; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $last = strlen($path)-1; |
|
| 362 | + $last = strlen($path) - 1; |
|
| 363 | 363 | if ($path[$last] == '/') { |
| 364 | 364 | $path = substr($path, 0, -1); |
| 365 | 365 | } |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * @param string $class Fore check node type |
| 391 | 391 | * @return INode |
| 392 | 392 | */ |
| 393 | - public function findNodeWithShareToken(string $token, ?string $class=null): INode |
|
| 393 | + public function findNodeWithShareToken(string $token, ?string $class = null) : INode |
|
| 394 | 394 | { |
| 395 | 395 | $node = $this->db->storage->findOne([ |
| 396 | 396 | 'sharelink.token' => $token, |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @param bool $deleted |
| 435 | 435 | * @return Generator |
| 436 | 436 | */ |
| 437 | - public function findNodes(array $id=[], ?string $class=null, int $deleted=INode::DELETED_INCLUDE): Generator |
|
| 437 | + public function findNodes(array $id = [], ?string $class = null, int $deleted = INode::DELETED_INCLUDE) : Generator |
|
| 438 | 438 | { |
| 439 | 439 | $id = (array)$id; |
| 440 | 440 | |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | * @param int $deleted |
| 489 | 489 | * @return array |
| 490 | 490 | */ |
| 491 | - public function search(array $query, int $deleted=INode::DELETED_INCLUDE): array |
|
| 491 | + public function search(array $query, int $deleted = INode::DELETED_INCLUDE): array |
|
| 492 | 492 | { |
| 493 | 493 | if ($this->user instanceof User) { |
| 494 | 494 | $this->user->findNewShares(); |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | ->setHosts((array)$this->config->search->hosts->server) |
| 583 | 583 | ->build(); |
| 584 | 584 | |
| 585 | - $bool = $query['body']['query']; |
|
| 585 | + $bool = $query['body']['query']; |
|
| 586 | 586 | |
| 587 | 587 | $filter1 = []; |
| 588 | 588 | $filter1['bool']['should'][]['term']['owner'] = (string)$this->user->getId(); |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | * @param bool $deleted How to handle deleted node |
| 651 | 651 | * @return INode |
| 652 | 652 | */ |
| 653 | - public function getNode($id=null, $path=null, $class=null, $multiple=false, $allow_root=false, $deleted=null) |
|
| 653 | + public function getNode($id = null, $path = null, $class = null, $multiple = false, $allow_root = false, $deleted = null) |
|
| 654 | 654 | { |
| 655 | 655 | if (empty($id) && empty($path)) { |
| 656 | 656 | if ($allow_root === true) { |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | * @return array |
| 767 | 767 | */ |
| 768 | 768 | public function findNodeAttributesWithCustomFilter( |
| 769 | - ?array $filter = null, |
|
| 769 | + ? array $filter = null, |
|
| 770 | 770 | array $attributes = ['_id'], |
| 771 | 771 | ?int $limit = null, |
| 772 | 772 | ?int &$cursor = null, |
@@ -783,13 +783,13 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | $search_attributes = array_merge($default, array_fill_keys($attributes, 1)); |
| 785 | 785 | $list = []; |
| 786 | - $result =$this->db->storage->find($filter, [ |
|
| 786 | + $result = $this->db->storage->find($filter, [ |
|
| 787 | 787 | 'skip' => $cursor, |
| 788 | 788 | 'limit' => $limit, |
| 789 | 789 | 'projection'=> $search_attributes |
| 790 | 790 | ]); |
| 791 | 791 | |
| 792 | - $left =$this->db->storage->count($filter, [ |
|
| 792 | + $left = $this->db->storage->count($filter, [ |
|
| 793 | 793 | 'skip' => $cursor, |
| 794 | 794 | ]); |
| 795 | 795 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $this->logger->warning("all authentication adapter have failed", [ |
| 125 | - 'category' => get_class($this) |
|
| 125 | + 'category' => get_class($this) |
|
| 126 | 126 | ]); |
| 127 | 127 | |
| 128 | 128 | $this->plugin->run('invalidAuthentication', [$adapters]); |
@@ -251,8 +251,8 @@ discard block |
||
| 251 | 251 | switch ($value['type']) { |
| 252 | 252 | case 'array': |
| 253 | 253 | $arr = (array)$data[$value['attr']]; |
| 254 | - unset($arr['count']); |
|
| 255 | - $attrs[$attr] = $arr; |
|
| 254 | + unset($arr['count']); |
|
| 255 | + $attrs[$attr] = $arr; |
|
| 256 | 256 | break; |
| 257 | 257 | |
| 258 | 258 | case 'string': |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Balloon |
@@ -250,25 +250,25 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | switch ($value['type']) { |
| 252 | 252 | case 'array': |
| 253 | - $arr = (array)$data[$value['attr']]; |
|
| 253 | + $arr = (array)$data[$value['attr']]; |
|
| 254 | 254 | unset($arr['count']); |
| 255 | 255 | $attrs[$attr] = $arr; |
| 256 | 256 | break; |
| 257 | 257 | |
| 258 | 258 | case 'string': |
| 259 | - $attrs[$attr] = (string)$store; |
|
| 259 | + $attrs[$attr] = (string)$store; |
|
| 260 | 260 | break; |
| 261 | 261 | |
| 262 | 262 | case 'int': |
| 263 | - $attrs[$attr] = (int)$store; |
|
| 263 | + $attrs[$attr] = (int)$store; |
|
| 264 | 264 | break; |
| 265 | 265 | |
| 266 | 266 | case 'bool': |
| 267 | - $attrs[$attr] = (bool)$store; |
|
| 267 | + $attrs[$attr] = (bool)$store; |
|
| 268 | 268 | break; |
| 269 | 269 | |
| 270 | 270 | case 'binary': |
| 271 | - $attrs[$attr] = new Binary($store, Binary::TYPE_GENERIC); |
|
| 271 | + $attrs[$attr] = new Binary($store, Binary::TYPE_GENERIC); |
|
| 272 | 272 | break; |
| 273 | 273 | |
| 274 | 274 | default: |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | protected $resource; |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /** |
|
| 45 | + /** |
|
| 46 | 46 | * Logger |
| 47 | 47 | * |
| 48 | 48 | * @var Logger |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Balloon |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param Iterable |
| 111 | 111 | * @return Oauth2 |
| 112 | 112 | */ |
| 113 | - public function setOptions(?Iterable $config): Oauth2 |
|
| 113 | + public function setOptions(?Iterable $config) : Oauth2 |
|
| 114 | 114 | { |
| 115 | 115 | if ($config === null) { |
| 116 | 116 | return $this; |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | $jre = json_decode($re); |
| 267 | 267 | |
| 268 | 268 | if ($jre->status == "success") { |
| 269 | - return (array) $jre->data; |
|
| 269 | + return (array)$jre->data; |
|
| 270 | 270 | } elseif ($jre->status == "fail") { |
| 271 | - throw new Exception('Error while validating the acces token. Auth server responded: ' . $jre->message); |
|
| 271 | + throw new Exception('Error while validating the acces token. Auth server responded: '.$jre->message); |
|
| 272 | 272 | } else { |
| 273 | 273 | throw new Exception('could not decode response: '.$re); |
| 274 | 274 | } |
@@ -893,7 +893,7 @@ |
||
| 893 | 893 | case 'shareowner': |
| 894 | 894 | if ($this->isSpecial() && $sharenode !== null) { |
| 895 | 895 | $build['shareowner'] = (new User($this->_fs->findRawNode($this->getShareId())['owner'], |
| 896 | - $this->_logger, $this->_fs) |
|
| 896 | + $this->_logger, $this->_fs) |
|
| 897 | 897 | )->getUsername(); |
| 898 | 898 | } |
| 899 | 899 | break; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Balloon |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * @param bool $force |
| 223 | 223 | * @return void |
| 224 | 224 | */ |
| 225 | - public function __construct(?BSONDocument $node, Filesystem $fs, bool $force=false) |
|
| 225 | + public function __construct(?BSONDocument $node, Filesystem $fs, bool $force = false) |
|
| 226 | 226 | { |
| 227 | 227 | $this->_fs = $fs; |
| 228 | 228 | $this->_db = $fs->getDatabase(); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * @return mixed |
| 272 | 272 | */ |
| 273 | - public function __call(string $attribute, array $params=[]) |
|
| 273 | + public function __call(string $attribute, array $params = []) |
|
| 274 | 274 | { |
| 275 | 275 | $prefix = 'get'; |
| 276 | 276 | $attr = strtolower(substr($attribute, 3)); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @param int $conflict |
| 316 | 316 | * @return INode |
| 317 | 317 | */ |
| 318 | - public function setParent(Collection $parent, int $conflict=INode::CONFLICT_NOACTION): INode |
|
| 318 | + public function setParent(Collection $parent, int $conflict = INode::CONFLICT_NOACTION): INode |
|
| 319 | 319 | { |
| 320 | 320 | if ($this->parent === $parent->getId()) { |
| 321 | 321 | throw new Exception\Conflict('source node '.$this->name.' is already in the requested parent folder', |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * @param bool $recursion_first |
| 391 | 391 | * @return INode |
| 392 | 392 | */ |
| 393 | - abstract public function copyTo(Collection $parent, int $conflict=INode::CONFLICT_NOACTION, ?string $recursion=null, bool $recursion_first=true): INode; |
|
| 393 | + abstract public function copyTo(Collection $parent, int $conflict = INode::CONFLICT_NOACTION, ?string $recursion = null, bool $recursion_first = true) : INode; |
|
| 394 | 394 | |
| 395 | 395 | |
| 396 | 396 | /** |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | * @param bool $reference |
| 400 | 400 | * @return ObjectId |
| 401 | 401 | */ |
| 402 | - public function getShareId(bool $reference=false): ?ObjectId |
|
| 402 | + public function getShareId(bool $reference = false): ?ObjectId |
|
| 403 | 403 | { |
| 404 | 404 | if ($this->isReference() && $reference === true) { |
| 405 | 405 | return $this->_id; |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | * @param string $privilege |
| 596 | 596 | * @return bool |
| 597 | 597 | */ |
| 598 | - public function isAllowed(string $privilege='r'): bool |
|
| 598 | + public function isAllowed(string $privilege = 'r'): bool |
|
| 599 | 599 | { |
| 600 | 600 | $acl = null; |
| 601 | 601 | $share = null; |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | $clean[] = 'meta'; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - $attribute = $clean; |
|
| 792 | + $attribute = $clean; |
|
| 793 | 793 | |
| 794 | 794 | try { |
| 795 | 795 | $sharenode = $this->getShareNode(); |
@@ -919,7 +919,7 @@ discard block |
||
| 919 | 919 | * @param string $name |
| 920 | 920 | * @return string |
| 921 | 921 | */ |
| 922 | - protected function _getDuplicateName(?string $name=null): string |
|
| 922 | + protected function _getDuplicateName(?string $name = null) : string |
|
| 923 | 923 | { |
| 924 | 924 | if ($name === null) { |
| 925 | 925 | $name = $this->name; |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | if ($this instanceof Collection) { |
| 929 | 929 | return $name.' ('.substr(uniqid('', true), -4).')'; |
| 930 | 930 | } else { |
| 931 | - $ext = substr(strrchr($name, '.'), 1); |
|
| 931 | + $ext = substr(strrchr($name, '.'), 1); |
|
| 932 | 932 | |
| 933 | 933 | if ($ext === false) { |
| 934 | 934 | return $name.' ('.substr(uniqid('', true), -4).')'; |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | * @param bool $recursion_first |
| 949 | 949 | * @return bool |
| 950 | 950 | */ |
| 951 | - public function undelete(int $conflict=INode::CONFLICT_NOACTION, ?string $recursion=null, bool $recursion_first=true): bool |
|
| 951 | + public function undelete(int $conflict = INode::CONFLICT_NOACTION, ?string $recursion = null, bool $recursion_first = true) : bool |
|
| 952 | 952 | { |
| 953 | 953 | if (!$this->isAllowed('w')) { |
| 954 | 954 | throw new Exception\Forbidden('not allowed to restore node '.$this->name, |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | $recursion_first = false; |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | - $this->deleted = false; |
|
| 991 | + $this->deleted = false; |
|
| 992 | 992 | |
| 993 | 993 | if ($this instanceof File) { |
| 994 | 994 | $current = $this->version; |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | * |
| 1143 | 1143 | * @return ObjectId|string |
| 1144 | 1144 | */ |
| 1145 | - public function getId(bool $string=false) |
|
| 1145 | + public function getId(bool $string = false) |
|
| 1146 | 1146 | { |
| 1147 | 1147 | if ($string === true) { |
| 1148 | 1148 | return (string)$this->_id; |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | * @param array $parents |
| 1193 | 1193 | * @return array |
| 1194 | 1194 | */ |
| 1195 | - public function getParents(?INode $node=null, array $parents=[]): array |
|
| 1195 | + public function getParents(?INode $node = null, array $parents = []) : array |
|
| 1196 | 1196 | { |
| 1197 | 1197 | if ($node === null) { |
| 1198 | 1198 | $node = $this; |
@@ -1259,7 +1259,7 @@ discard block |
||
| 1259 | 1259 | * @param int $depth |
| 1260 | 1260 | * @return bool |
| 1261 | 1261 | */ |
| 1262 | - public function zip(ZipStream $archive, bool $self=true, ?INode $parent=null, string $path='', int $depth=0): bool |
|
| 1262 | + public function zip(ZipStream $archive, bool $self = true, ?INode $parent = null, string $path = '', int $depth = 0) : bool |
|
| 1263 | 1263 | { |
| 1264 | 1264 | if ($parent === null) { |
| 1265 | 1265 | $parent = $this; |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | * @param mixed $value |
| 1322 | 1322 | * @return INode |
| 1323 | 1323 | */ |
| 1324 | - public function setMetaAttribute($attributes, $value=null): INode |
|
| 1324 | + public function setMetaAttribute($attributes, $value = null): INode |
|
| 1325 | 1325 | { |
| 1326 | 1326 | $this->meta = self::validateMetaAttribute($attributes, $value, $this->meta); |
| 1327 | 1327 | $this->save('meta'); |
@@ -1337,7 +1337,7 @@ discard block |
||
| 1337 | 1337 | * @param array $set |
| 1338 | 1338 | * @return array |
| 1339 | 1339 | */ |
| 1340 | - public static function validateMetaAttribute($attributes, $value=null, array $set=[]): array |
|
| 1340 | + public static function validateMetaAttribute($attributes, $value = null, array $set = []): array |
|
| 1341 | 1341 | { |
| 1342 | 1342 | if (is_string($attributes)) { |
| 1343 | 1343 | $attributes = [ |
@@ -1368,7 +1368,7 @@ discard block |
||
| 1368 | 1368 | * @param string|array $attribute Specify attributes to return |
| 1369 | 1369 | * @return string|array |
| 1370 | 1370 | */ |
| 1371 | - public function getMetaAttribute($attribute=[]) |
|
| 1371 | + public function getMetaAttribute($attribute = []) |
|
| 1372 | 1372 | { |
| 1373 | 1373 | if (is_string($attribute)) { |
| 1374 | 1374 | if (isset($this->meta[$attribute])) { |
@@ -1388,7 +1388,7 @@ discard block |
||
| 1388 | 1388 | * @param bool $readonly |
| 1389 | 1389 | * @return bool |
| 1390 | 1390 | */ |
| 1391 | - public function setReadonly(bool $readonly=true): bool |
|
| 1391 | + public function setReadonly(bool $readonly = true): bool |
|
| 1392 | 1392 | { |
| 1393 | 1393 | $this->readonly = $readonly; |
| 1394 | 1394 | return $this->save('readonly'); |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | * @param UTCDateTime $ts |
| 1402 | 1402 | * @return bool |
| 1403 | 1403 | */ |
| 1404 | - public function setDestroyable(?UTCDateTime $ts): bool |
|
| 1404 | + public function setDestroyable(?UTCDateTime $ts) : bool |
|
| 1405 | 1405 | { |
| 1406 | 1406 | $this->destroy = $ts; |
| 1407 | 1407 | |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | * @param string $recursion |
| 1425 | 1425 | * @return bool |
| 1426 | 1426 | */ |
| 1427 | - abstract public function delete(bool $force=false, ?string $recursion=null, bool $recursion_first=true): bool; |
|
| 1427 | + abstract public function delete(bool $force = false, ?string $recursion = null, bool $recursion_first = true) : bool; |
|
| 1428 | 1428 | |
| 1429 | 1429 | |
| 1430 | 1430 | /** |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | * @param bool $recursion_first |
| 1495 | 1495 | * @return bool |
| 1496 | 1496 | */ |
| 1497 | - public function save($attributes=[], $remove=[], ?string $recursion=null, bool $recursion_first=true): bool |
|
| 1497 | + public function save($attributes = [], $remove = [], ?string $recursion = null, bool $recursion_first = true) : bool |
|
| 1498 | 1498 | { |
| 1499 | 1499 | if (!$this->isAllowed('w') && !$this->isReference()) { |
| 1500 | 1500 | throw new Exception\Forbidden('not allowed to modify node '.$this->name, |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | if (empty($update)) { |
| 1528 | 1528 | return false; |
| 1529 | 1529 | } else { |
| 1530 | - $result =$this->_db->storage->updateOne([ |
|
| 1530 | + $result = $this->_db->storage->updateOne([ |
|
| 1531 | 1531 | '_id' => $this->_id, |
| 1532 | 1532 | ], $update); |
| 1533 | 1533 | } |
@@ -1563,7 +1563,7 @@ discard block |
||
| 1563 | 1563 | * @return array |
| 1564 | 1564 | */ |
| 1565 | 1565 | public static function loadNodeAttributesWithCustomFilter( |
| 1566 | - ?array $filter = null, |
|
| 1566 | + ? array $filter = null, |
|
| 1567 | 1567 | array $attributes = ['_id'], |
| 1568 | 1568 | ?int $limit = null, |
| 1569 | 1569 | ?int &$cursor = null, |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | |
| 1580 | 1580 | $search_attributes = array_merge($default, array_fill_keys($attributes, 1)); |
| 1581 | 1581 | $list = []; |
| 1582 | - $result =$this->_db->storage->find($filter, [ |
|
| 1582 | + $result = $this->_db->storage->find($filter, [ |
|
| 1583 | 1583 | 'skip' => $cursor, |
| 1584 | 1584 | 'limit' => $limit, |
| 1585 | 1585 | 'projection'=> $search_attributes |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $v = (array)$version; |
| 206 | 206 | |
| 207 | 207 | $v['user'] = (new User($version['user'], $this->_logger, $this->_fs)) |
| 208 | - ->getUsername(); |
|
| 208 | + ->getUsername(); |
|
| 209 | 209 | $v['changed'] = Helper::DateTimeToUnix($version['changed']); |
| 210 | 210 | $filtered[] = $v; |
| 211 | 211 | } |
@@ -597,15 +597,15 @@ discard block |
||
| 597 | 597 | $build = []; |
| 598 | 598 | foreach ($requested as $key => $attr) { |
| 599 | 599 | switch ($attr) { |
| 600 | - case 'hash': |
|
| 600 | + case 'hash': |
|
| 601 | 601 | case 'version': |
| 602 | 602 | case 'thumbnail': |
| 603 | 603 | $build[$attr] = $this->{$attr}; |
| 604 | - break; |
|
| 604 | + break; |
|
| 605 | 605 | |
| 606 | - case 'history': |
|
| 606 | + case 'history': |
|
| 607 | 607 | $build['history'] = $this->getHistory(); |
| 608 | - break; |
|
| 608 | + break; |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | //somehow mongo-connector does not catch metadata when set during uploadFromStream() |
| 871 | 871 | $stream = $bucket->uploadFromStream($id, $contents, ['_id' => $id/*, 'metadata' => $file*/]); |
| 872 | 872 | $this->_db->{'fs.files'}->updateOne(['_id' => $id], [ |
| 873 | - '$set' => ['metadata'=> $file] |
|
| 873 | + '$set' => ['metadata'=> $file] |
|
| 874 | 874 | ]); |
| 875 | 875 | |
| 876 | 876 | $this->_logger->info('added new gridfs content node ['.$id.'] for file ['.$this->_id.']', [ |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Balloon |
@@ -47,14 +47,14 @@ discard block |
||
| 47 | 47 | * @param array |
| 48 | 48 | **/ |
| 49 | 49 | protected $temp_files = [ |
| 50 | - '/^\._(.*)$/', // OS/X resource forks |
|
| 51 | - '/^.DS_Store$/', // OS/X custom folder settings |
|
| 50 | + '/^\._(.*)$/', // OS/X resource forks |
|
| 51 | + '/^.DS_Store$/', // OS/X custom folder settings |
|
| 52 | 52 | '/^desktop.ini$/', // Windows custom folder settings |
| 53 | - '/^Thumbs.db$/', // Windows thumbnail cache |
|
| 54 | - '/^.(.*).swpx$/', // ViM temporary files |
|
| 55 | - '/^.(.*).swx$/', // ViM temporary files |
|
| 56 | - '/^.(.*).swp$/', // ViM temporary files |
|
| 57 | - '/^\.dat(.*)$/', // Smultron seems to create these |
|
| 53 | + '/^Thumbs.db$/', // Windows thumbnail cache |
|
| 54 | + '/^.(.*).swpx$/', // ViM temporary files |
|
| 55 | + '/^.(.*).swx$/', // ViM temporary files |
|
| 56 | + '/^.(.*).swp$/', // ViM temporary files |
|
| 57 | + '/^\.dat(.*)$/', // Smultron seems to create these |
|
| 58 | 58 | '/^~lock.(.*)#$/', // Windows 7 lockfiles |
| 59 | 59 | ]; |
| 60 | 60 | |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | * @param bool $force |
| 124 | 124 | * @return void |
| 125 | 125 | */ |
| 126 | - public function __construct(BSONDocument $node, Filesystem $fs, bool $force=false) |
|
| 126 | + public function __construct(BSONDocument $node, Filesystem $fs, bool $force = false) |
|
| 127 | 127 | { |
| 128 | 128 | parent::__construct($node, $fs); |
| 129 | 129 | |
| 130 | - if($force === false) { |
|
| 130 | + if ($force === false) { |
|
| 131 | 131 | $this->_verifyAccess(); |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param bool $recursion_first |
| 164 | 164 | * @return INode |
| 165 | 165 | */ |
| 166 | - public function copyTo(Collection $parent, int $conflict=INode::CONFLICT_NOACTION, ?string $recursion=null, bool $recursion_first=true): INode |
|
| 166 | + public function copyTo(Collection $parent, int $conflict = INode::CONFLICT_NOACTION, ?string $recursion = null, bool $recursion_first = true) : INode |
|
| 167 | 167 | { |
| 168 | 168 | $this->_pluginmgr->run('preCopyFile', |
| 169 | 169 | [$this, $parent, &$conflict, &$recursion, &$recursion_first] |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * @param bool $recursion_first |
| 321 | 321 | * @return bool |
| 322 | 322 | */ |
| 323 | - public function delete(bool $force=false, ?string $recursion=null, bool $recursion_first=true): bool |
|
| 323 | + public function delete(bool $force = false, ?string $recursion = null, bool $recursion_first = true) : bool |
|
| 324 | 324 | { |
| 325 | 325 | if (!$this->isAllowed('w')) { |
| 326 | 326 | throw new Exception\Forbidden('not allowed to delete node '.$this->name, |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | $ts = new UTCDateTime(); |
| 346 | - $this->deleted = $ts; |
|
| 346 | + $this->deleted = $ts; |
|
| 347 | 347 | $this->increaseVersion(); |
| 348 | 348 | |
| 349 | 349 | $this->history[] = [ |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | return true; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - $ref = $file['metadata']['ref']; |
|
| 441 | + $ref = $file['metadata']['ref']; |
|
| 442 | 442 | |
| 443 | 443 | $found = false; |
| 444 | 444 | foreach ($ref as $key => $node) { |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | * @param string|array $attribute |
| 578 | 578 | * @return array|string |
| 579 | 579 | */ |
| 580 | - public function getAttribute($attribute=[]) |
|
| 580 | + public function getAttribute($attribute = []) |
|
| 581 | 581 | { |
| 582 | 582 | if (empty($attribute)) { |
| 583 | 583 | $attribute = [ |
@@ -896,8 +896,8 @@ discard block |
||
| 896 | 896 | { |
| 897 | 897 | assert(strlen($data) == 16); |
| 898 | 898 | |
| 899 | - $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 |
|
| 900 | - $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 |
|
| 899 | + $data[6] = chr(ord($data[6])&0x0f|0x40); // set version to 0100 |
|
| 900 | + $data[8] = chr(ord($data[8])&0x3f|0x80); // set bits 6-7 to 10 |
|
| 901 | 901 | |
| 902 | 902 | return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); |
| 903 | 903 | } |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * @param array $attributes |
| 922 | 922 | * @return int |
| 923 | 923 | */ |
| 924 | - public function put($file, bool $new=false, array $attributes=[]): int |
|
| 924 | + public function put($file, bool $new = false, array $attributes = []): int |
|
| 925 | 925 | { |
| 926 | 926 | $this->_logger->debug('PUT new content data for ['.$this->_id.']', [ |
| 927 | 927 | 'category' => get_class($this), |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | ); |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | - $file = $tmp_file; |
|
| 975 | + $file = $tmp_file; |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | |
@@ -1040,10 +1040,10 @@ discard block |
||
| 1040 | 1040 | $this->mime = $attributes['mime']; |
| 1041 | 1041 | } elseif ($file !== null) { |
| 1042 | 1042 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 1043 | - $this->mime = finfo_file($finfo, $file); |
|
| 1043 | + $this->mime = finfo_file($finfo, $file); |
|
| 1044 | 1044 | if ($this->mime == 'application/zip' || $this->mime == 'application/vnd.ms-office') { |
| 1045 | 1045 | $mime = $this->getMimeTypeFromExtension($this->name); |
| 1046 | - if($mime !== null) { |
|
| 1046 | + if ($mime !== null) { |
|
| 1047 | 1047 | $this->mime = $mime; |
| 1048 | 1048 | } |
| 1049 | 1049 | } |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | * @param string $db mimetypes |
| 1137 | 1137 | * @return string |
| 1138 | 1138 | */ |
| 1139 | - public function getMimeTypeFromExtension(string $filename, string $db='/etc/mime.types'): ?string |
|
| 1139 | + public function getMimeTypeFromExtension(string $filename, string $db = '/etc/mime.types'): ?string |
|
| 1140 | 1140 | { |
| 1141 | 1141 | if (!is_readable($db)) { |
| 1142 | 1142 | throw new Exception('mime database '.$db.' was not found or is not readable'); |
@@ -1153,7 +1153,7 @@ discard block |
||
| 1153 | 1153 | if (substr($line, 0, 1) == '#') { |
| 1154 | 1154 | continue; |
| 1155 | 1155 | } // skip comments |
| 1156 | - $line = rtrim($line) . " "; |
|
| 1156 | + $line = rtrim($line)." "; |
|
| 1157 | 1157 | if (!preg_match($regex, $line, $matches)) { |
| 1158 | 1158 | continue; |
| 1159 | 1159 | } // no match to the extension |