@@ -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 |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param bool $force |
| 74 | 74 | * @return void |
| 75 | 75 | */ |
| 76 | - public function __construct(?BSONDocument $node, Filesystem $fs, bool $force=false) |
|
| 76 | + public function __construct(?BSONDocument $node, Filesystem $fs, bool $force = false) |
|
| 77 | 77 | { |
| 78 | 78 | parent::__construct($node, $fs); |
| 79 | 79 | |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | $this->_id = null; |
| 82 | 82 | |
| 83 | 83 | if ($this->_user instanceof User) { |
| 84 | - $this->owner = $this->_user->getId(); |
|
| 84 | + $this->owner = $this->_user->getId(); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if($force === false) { |
|
| 88 | + if ($force === false) { |
|
| 89 | 89 | $this->_verifyAccess(); |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param bool $recursion_first |
| 101 | 101 | * @return INode |
| 102 | 102 | */ |
| 103 | - public function copyTo(Collection $parent, int $conflict=INode::CONFLICT_NOACTION, ?string $recursion=null, bool $recursion_first=true): INode |
|
| 103 | + public function copyTo(Collection $parent, int $conflict = INode::CONFLICT_NOACTION, ?string $recursion = null, bool $recursion_first = true) : INode |
|
| 104 | 104 | { |
| 105 | 105 | if ($recursion === null) { |
| 106 | 106 | $recursion_first = true; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @param array|string $attribute |
| 200 | 200 | * @return array|string |
| 201 | 201 | */ |
| 202 | - public function getAttribute($attribute=[]) |
|
| 202 | + public function getAttribute($attribute = []) |
|
| 203 | 203 | { |
| 204 | 204 | if (empty($attribute)) { |
| 205 | 205 | $attribute = [ |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @param array $filter |
| 246 | 246 | * @return Generator |
| 247 | 247 | */ |
| 248 | - public function getChildNodes(int $deleted=INode::DELETED_EXCLUDE, array $filter=[]): Generator |
|
| 248 | + public function getChildNodes(int $deleted = INode::DELETED_EXCLUDE, array $filter = []): Generator |
|
| 249 | 249 | { |
| 250 | 250 | if ($this->_user instanceof User) { |
| 251 | 251 | $this->_user->findNewShares(); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @param array $filter |
| 317 | 317 | * @return Generator |
| 318 | 318 | */ |
| 319 | - public function getChildren(int $deleted=INode::DELETED_EXCLUDE, array $filter=[]): array |
|
| 319 | + public function getChildren(int $deleted = INode::DELETED_EXCLUDE, array $filter = []): array |
|
| 320 | 320 | { |
| 321 | 321 | return iterator_to_array($this->getChildNodes($deleted, $filter)); |
| 322 | 322 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | * @param array $filter |
| 388 | 388 | * @return INode |
| 389 | 389 | */ |
| 390 | - public function getChild($node, int $deleted=INode::DELETED_EXCLUDE, array $filter=[]): INode |
|
| 390 | + public function getChild($node, int $deleted = INode::DELETED_EXCLUDE, array $filter = []): INode |
|
| 391 | 391 | { |
| 392 | 392 | //if $node is string load the object from the backend based on the current parent (the name |
| 393 | 393 | //is unique per depth, so we can load the object) |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | * @param int $deleted |
| 457 | 457 | * @return bool |
| 458 | 458 | */ |
| 459 | - protected function doRecursiveAction(string $method, array $params=[], int $deleted=INode::DELETED_EXCLUDE): bool |
|
| 459 | + protected function doRecursiveAction(string $method, array $params = [], int $deleted = INode::DELETED_EXCLUDE): bool |
|
| 460 | 460 | { |
| 461 | 461 | if (!is_callable([$this, $method])) { |
| 462 | 462 | throw new Exception("method $method is not callable in ".__CLASS__); |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * @param bool $recursion_first |
| 484 | 484 | * @return bool |
| 485 | 485 | */ |
| 486 | - public function delete(bool $force=false, ?string $recursion=null, bool $recursion_first=true): bool |
|
| 486 | + public function delete(bool $force = false, ?string $recursion = null, bool $recursion_first = true) : bool |
|
| 487 | 487 | { |
| 488 | 488 | if (!$this->isAllowed('w') && !$this->isReference()) { |
| 489 | 489 | throw new Exception\Forbidden('not allowed to delete node '.$this->name, |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | * @param bool $recursion_first |
| 547 | 547 | * @return bool |
| 548 | 548 | */ |
| 549 | - protected function _forceDelete(?string $recursion=null, bool $recursion_first=true): bool |
|
| 549 | + protected function _forceDelete(?string $recursion = null, bool $recursion_first = true) : bool |
|
| 550 | 550 | { |
| 551 | 551 | if (!$this->isReference()) { |
| 552 | 552 | $this->doRecursiveAction('delete', [ |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | * @param array $filter |
| 599 | 599 | * @return bool |
| 600 | 600 | */ |
| 601 | - public function childExists($name, $deleted=INode::DELETED_EXCLUDE, array $filter=[]): bool |
|
| 601 | + public function childExists($name, $deleted = INode::DELETED_EXCLUDE, array $filter = []): bool |
|
| 602 | 602 | { |
| 603 | 603 | $find = [ |
| 604 | 604 | 'parent' => $this->getRealId(), |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | $this->shared = false; |
| 735 | - $this->acl = null; |
|
| 735 | + $this->acl = null; |
|
| 736 | 736 | $action = [ |
| 737 | 737 | '$unset' => [ |
| 738 | 738 | 'shared' => $this->_id |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | * @param arary $files |
| 793 | 793 | * @return array |
| 794 | 794 | */ |
| 795 | - public function getChildrenRecursive(?ObjectId $id=null, ?array &$shares=[], ?array &$files=[]): array |
|
| 795 | + public function getChildrenRecursive(?ObjectId $id = null, ? array &$shares = [], ? array &$files = []) : array |
|
| 796 | 796 | { |
| 797 | 797 | $list = []; |
| 798 | 798 | $result = $this->_db->storage->find([ |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | * @param bool $clone |
| 837 | 837 | * @return Collection |
| 838 | 838 | */ |
| 839 | - public function addDirectory($name, array $attributes=[], int $conflict=INode::CONFLICT_NOACTION, bool $clone=false): Collection |
|
| 839 | + public function addDirectory($name, array $attributes = [], int $conflict = INode::CONFLICT_NOACTION, bool $clone = false): Collection |
|
| 840 | 840 | { |
| 841 | 841 | if (!$this->isAllowed('w')) { |
| 842 | 842 | throw new Exception\Forbidden('not allowed to create new node here', |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | 'shared' => ($this->shared === true ? $this->getRealId() : $this->shared) |
| 884 | 884 | ]; |
| 885 | 885 | |
| 886 | - $save = array_merge($meta, $attributes); |
|
| 886 | + $save = array_merge($meta, $attributes); |
|
| 887 | 887 | |
| 888 | 888 | $result = $this->_db->storage->insertOne($save); |
| 889 | 889 | $save['_id'] = $result->getInsertedId(); |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | * @param bool $clone |
| 917 | 917 | * @return File |
| 918 | 918 | */ |
| 919 | - public function addFile($name, $data=null, array $attributes=[], int $conflict=INode::CONFLICT_NOACTION, bool $clone=false): File |
|
| 919 | + public function addFile($name, $data = null, array $attributes = [], int $conflict = INode::CONFLICT_NOACTION, bool $clone = false): File |
|
| 920 | 920 | { |
| 921 | 921 | if (!$this->isAllowed('w')) { |
| 922 | 922 | throw new Exception\Forbidden('not allowed to create new node here', |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | 'shared' => ($this->shared === true ? $this->getRealId() : $this->shared), |
| 967 | 967 | ]; |
| 968 | 968 | |
| 969 | - $save = array_merge($meta, $attributes); |
|
| 969 | + $save = array_merge($meta, $attributes); |
|
| 970 | 970 | |
| 971 | 971 | $result = $this->_db->storage->insertOne($save); |
| 972 | 972 | $save['_id'] = $result->getInsertedId(); |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | * @param string $data |
| 1017 | 1017 | * @return File |
| 1018 | 1018 | */ |
| 1019 | - public function createFile($name, $data=null): String |
|
| 1019 | + public function createFile($name, $data = null): String |
|
| 1020 | 1020 | { |
| 1021 | 1021 | return $this->addFile($name, $data)->getETag(); |
| 1022 | 1022 | } |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @param string $encode |
| 56 | 56 | * @return void |
| 57 | 57 | */ |
| 58 | - public function getPreview(?string $id=null, ?string $p=null, ?string $encode=null): void |
|
| 58 | + public function getPreview(?string $id = null, ?string $p = null, ?string $encode = null) : void |
|
| 59 | 59 | { |
| 60 | 60 | $node = $this->_getNode($id, $p); |
| 61 | 61 | $data = $node->getPreview(); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $p |
| 129 | 129 | * @return Response |
| 130 | 130 | */ |
| 131 | - public function getHistory(?string $id=null, ?string $p=null): Response |
|
| 131 | + public function getHistory(?string $id = null, ?string $p = null) : Response |
|
| 132 | 132 | { |
| 133 | 133 | $result = Helper::escape( |
| 134 | 134 | $this->_getNode($id, $p)->getHistory() |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @param string $version |
| 162 | 162 | * @return Response |
| 163 | 163 | */ |
| 164 | - public function postRestore(int $version, ?string $id=null, ?string $p=null): Response |
|
| 164 | + public function postRestore(int $version, ?string $id = null, ?string $p = null) : Response |
|
| 165 | 165 | { |
| 166 | 166 | $result = $this->_getNode($id, $p)->restore($version); |
| 167 | 167 | return (new Response())->setCode(204); |
@@ -297,15 +297,15 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | public function putChunk( |
| 299 | 299 | string $chunkgroup, |
| 300 | - ?string $id=null, |
|
| 301 | - ?string $p=null, |
|
| 302 | - ?string $collection=null, |
|
| 303 | - ?string $name=null, |
|
| 304 | - int $index=1, |
|
| 305 | - int $chunks=0, |
|
| 306 | - int $size=0, |
|
| 307 | - array $attributes=[], |
|
| 308 | - int $conflict=0) |
|
| 300 | + ?string $id = null, |
|
| 301 | + ?string $p = null, |
|
| 302 | + ?string $collection = null, |
|
| 303 | + ?string $name = null, |
|
| 304 | + int $index = 1, |
|
| 305 | + int $chunks = 0, |
|
| 306 | + int $size = 0, |
|
| 307 | + array $attributes = [], |
|
| 308 | + int $conflict = 0) |
|
| 309 | 309 | { |
| 310 | 310 | ini_set('auto_detect_line_endings', '1'); |
| 311 | 311 | $input_handler = fopen('php://input', 'rb'); |
@@ -464,12 +464,12 @@ discard block |
||
| 464 | 464 | * @return Response |
| 465 | 465 | */ |
| 466 | 466 | public function put( |
| 467 | - ?string $id=null, |
|
| 468 | - ?string $p=null, |
|
| 469 | - ?string $collection=null, |
|
| 470 | - ?string $name=null, |
|
| 471 | - array $attributes=[], |
|
| 472 | - int $conflict=0): Response |
|
| 467 | + ?string $id = null, |
|
| 468 | + ?string $p = null, |
|
| 469 | + ?string $collection = null, |
|
| 470 | + ?string $name = null, |
|
| 471 | + array $attributes = [], |
|
| 472 | + int $conflict = 0) : Response |
|
| 473 | 473 | { |
| 474 | 474 | $attributes = $this->_verifyAttributes($attributes); |
| 475 | 475 | |
@@ -493,12 +493,12 @@ discard block |
||
| 493 | 493 | */ |
| 494 | 494 | protected function _put( |
| 495 | 495 | $content, |
| 496 | - ?string $id=null, |
|
| 497 | - ?string $p=null, |
|
| 498 | - ?string $collection=null, |
|
| 499 | - ?string $name=null, |
|
| 500 | - array $attributes=[], |
|
| 501 | - int $conflict=0): Response |
|
| 496 | + ?string $id = null, |
|
| 497 | + ?string $p = null, |
|
| 498 | + ?string $collection = null, |
|
| 499 | + ?string $name = null, |
|
| 500 | + array $attributes = [], |
|
| 501 | + int $conflict = 0) : Response |
|
| 502 | 502 | { |
| 503 | 503 | if ($id === null && $p === null && $name === null) { |
| 504 | 504 | throw new Exception\InvalidArgument('neither id, p nor name was set'); |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | $result = $node->put($content, false, $attributes); |
| 519 | 519 | return (new Response())->setCode(200)->setBody($result); |
| 520 | 520 | } elseif ($p === null && $id === null && $name !== null) { |
| 521 | - $collection = $this->_getNode($collection, null, 'Collection', false, true); |
|
| 521 | + $collection = $this->_getNode($collection, null, 'Collection', false, true); |
|
| 522 | 522 | |
| 523 | 523 | if ($collection->childExists($name)) { |
| 524 | 524 | $child = $collection->getChild($name); |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | return (new Response())->setCode(201)->setBody($result); |
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | - } catch(Exception\Forbidden $e) { |
|
| 537 | + } catch (Exception\Forbidden $e) { |
|
| 538 | 538 | throw new Exception\Conflict('a node called '.$name.' does already exists in this collection', |
| 539 | 539 | Exception\Conflict::NODE_WITH_SAME_NAME_ALREADY_EXISTS |
| 540 | 540 | ); |