@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param string $id |
119 | 119 | * @param string $p |
120 | - * @param string $version |
|
120 | + * @param integer $version |
|
121 | 121 | */ |
122 | 122 | public function postRestore(int $version, ?string $id = null, ?string $p = null): Response |
123 | 123 | { |
@@ -406,6 +406,9 @@ discard block |
||
406 | 406 | |
407 | 407 | /** |
408 | 408 | * Get storage. |
409 | + * @param string|null $id |
|
410 | + * @param string|null $p |
|
411 | + * @param string|null $collection |
|
409 | 412 | */ |
410 | 413 | protected function getStorage($id, $p, $collection): StorageAdapterInterface |
411 | 414 | { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | 'message' => (string) $message['body'], |
99 | 99 | 'subject' => (string) $message['subject'], |
100 | 100 | 'locale' => (string) $message['locale'], |
101 | - 'sender' => function ($message) use ($server, $role_decorator) { |
|
101 | + 'sender' => function($message) use ($server, $role_decorator) { |
|
102 | 102 | if (!isset($message['sender'])) { |
103 | 103 | return null; |
104 | 104 | } |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | return null; |
110 | 110 | } |
111 | 111 | }, |
112 | - 'created' => function ($message) { |
|
112 | + 'created' => function($message) { |
|
113 | 113 | return (new DateTime())->setTimestamp($message['_id']->getTimestamp())->format('c'); |
114 | 114 | }, |
115 | - 'node' => function ($message) use ($node_decorator, $fs) { |
|
115 | + 'node' => function($message) use ($node_decorator, $fs) { |
|
116 | 116 | if (isset($message['node'])) { |
117 | 117 | try { |
118 | 118 | return $node_decorator->decorate($fs->findNodeById($message['node']), ['id', 'name', '_links']); |
@@ -54,7 +54,7 @@ |
||
54 | 54 | */ |
55 | 55 | protected function setErrorHandler(LoggerInterface $logger): self |
56 | 56 | { |
57 | - set_error_handler(function ($severity, $message, $file, $line) use ($logger) { |
|
57 | + set_error_handler(function($severity, $message, $file, $line) use ($logger) { |
|
58 | 58 | $log = $message.' in '.$file.':'.$line; |
59 | 59 | |
60 | 60 | switch ($severity) { |
@@ -144,7 +144,7 @@ |
||
144 | 144 | protected function deleteNode(NodeInterface $node, Blackhole $dummy): bool |
145 | 145 | { |
146 | 146 | if ($node instanceof Collection) { |
147 | - $node->doRecursiveAction(function (NodeInterface $node) use ($dummy) { |
|
147 | + $node->doRecursiveAction(function(NodeInterface $node) use ($dummy) { |
|
148 | 148 | if ($node instanceof Collection) { |
149 | 149 | $node->setStorage($dummy); |
150 | 150 | } |
@@ -246,7 +246,7 @@ |
||
246 | 246 | $delta[$share_member->getPath()] = $share_member; |
247 | 247 | } |
248 | 248 | } elseif ('undeleteCollection' === $log['operation'] || 'undeleteCollectionShare' === $log['operation']) { |
249 | - $log_node->doRecursiveAction(function ($sub_node) use (&$delta) { |
|
249 | + $log_node->doRecursiveAction(function($sub_node) use (&$delta) { |
|
250 | 250 | $delta[$sub_node->getPath()] = $sub_node; |
251 | 251 | }); |
252 | 252 | } |
@@ -98,6 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Build a single dimension array with all nodes. |
101 | + * @param integer[] $cursor |
|
101 | 102 | */ |
102 | 103 | public function buildFeedFromCurrentState(?array $cursor = null, int $limit = 100, ?NodeInterface $node = null): array |
103 | 104 | { |
@@ -220,6 +221,7 @@ discard block |
||
220 | 221 | |
221 | 222 | /** |
222 | 223 | * Get delta feed with changes and cursor. |
224 | + * @param NodeInterface $node |
|
223 | 225 | */ |
224 | 226 | public function getDeltaFeed(?string $cursor = null, int $limit = 250, ?NodeInterface $node = null): array |
225 | 227 | { |
@@ -327,6 +329,7 @@ discard block |
||
327 | 329 | |
328 | 330 | /** |
329 | 331 | * Get event log. |
332 | + * @param NodeInterface $node |
|
330 | 333 | */ |
331 | 334 | public function getEventLog(array $query = [], int $limit = 100, int $skip = 0, ?NodeInterface $node = null, ?int &$total = null): iterable |
332 | 335 | { |
@@ -584,6 +587,7 @@ discard block |
||
584 | 587 | |
585 | 588 | /** |
586 | 589 | * Get children with custom filter. |
590 | + * @param integer $limit |
|
587 | 591 | */ |
588 | 592 | protected function findNodeAttributesWithCustomFilter( |
589 | 593 | ?array $filter = null, |
@@ -958,9 +958,9 @@ |
||
958 | 958 | $node->zip($archive); |
959 | 959 | } catch (\Exception $e) { |
960 | 960 | $this->logger->debug('failed zip node in multi node request ['.$node->getId().']', [ |
961 | - 'category' => get_class($this), |
|
962 | - 'exception' => $e, |
|
963 | - ]); |
|
961 | + 'category' => get_class($this), |
|
962 | + 'exception' => $e, |
|
963 | + ]); |
|
964 | 964 | } |
965 | 965 | } |
966 | 966 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - return $this->bulk($id, function ($node) use ($parent, $conflict, $move) { |
|
105 | + return $this->bulk($id, function($node) use ($parent, $conflict, $move) { |
|
106 | 106 | if (true === $move) { |
107 | 107 | $node = $node->setParent($parent, $conflict); |
108 | 108 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | return (new Response())->setCode(200)->setBody($result); |
170 | 170 | } |
171 | 171 | |
172 | - return $this->bulk($id, function ($node) use ($attributes) { |
|
172 | + return $this->bulk($id, function($node) use ($attributes) { |
|
173 | 173 | return [ |
174 | 174 | 'code' => 200, |
175 | 175 | 'data' => $this->node_decorator->decorate($node, $attributes), |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | public function patch(string $id, ?string $name = null, ?array $meta = null, ?bool $readonly = null, ?array $filter = null, ?array $acl = null, $lock = null): Response |
206 | 206 | { |
207 | 207 | $attributes = compact('name', 'meta', 'readonly', 'filter', 'acl', 'lock'); |
208 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
208 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
209 | 209 | |
210 | 210 | $lock = $_SERVER['HTTP_LOCK_TOKEN'] ?? null; |
211 | 211 | |
212 | - return $this->bulk($id, function ($node) use ($attributes, $lock) { |
|
212 | + return $this->bulk($id, function($node) use ($attributes, $lock) { |
|
213 | 213 | foreach ($attributes as $attribute => $value) { |
214 | 214 | switch ($attribute) { |
215 | 215 | case 'name': |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | ); |
270 | 270 | } |
271 | 271 | |
272 | - return $this->bulk($id, function ($node) use ($parent, $conflict) { |
|
272 | + return $this->bulk($id, function($node) use ($parent, $conflict) { |
|
273 | 273 | $result = $node->copyTo($parent, $conflict); |
274 | 274 | |
275 | 275 | return [ |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | ); |
297 | 297 | } |
298 | 298 | |
299 | - return $this->bulk($id, function ($node) use ($parent, $conflict) { |
|
299 | + return $this->bulk($id, function($node) use ($parent, $conflict) { |
|
300 | 300 | $result = $node->setParent($parent, $conflict); |
301 | 301 | |
302 | 302 | return [ |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $at = $this->_verifyAttributes(['destroy' => $at])['destroy']; |
322 | 322 | } |
323 | 323 | |
324 | - return $this->bulk($id, function ($node) use ($force, $ignore_flag, $at) { |
|
324 | + return $this->bulk($id, function($node) use ($force, $ignore_flag, $at) { |
|
325 | 325 | if (null === $at) { |
326 | 326 | $node->delete($force && $node->isDeleted() || $force && $ignore_flag); |
327 | 327 | } else { |
@@ -34,68 +34,68 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | return $response |
37 | - ->setOutputFormat(null) |
|
38 | - ->setBody(function () use ($file) { |
|
39 | - $stream = $file->get(); |
|
40 | - $name = $file->getName(); |
|
41 | - |
|
42 | - if (null === $stream) { |
|
43 | - return; |
|
44 | - } |
|
45 | - |
|
46 | - $size = $file->getSize(); |
|
47 | - $length = $size; |
|
48 | - $start = 0; |
|
49 | - $end = $size - 1; |
|
50 | - |
|
51 | - if (isset($_SERVER['HTTP_RANGE'])) { |
|
52 | - header('Accept-Ranges: bytes'); |
|
53 | - $c_start = $start; |
|
54 | - $c_end = $end; |
|
55 | - list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
56 | - |
|
57 | - if (strpos($range, ',') !== false) { |
|
58 | - header("Content-Range: bytes $start-$end/$size"); |
|
59 | - |
|
60 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
61 | - } |
|
62 | - |
|
63 | - if ($range == '-') { |
|
64 | - $c_start = $size - substr($range, 1); |
|
65 | - } else { |
|
66 | - $range = explode('-', $range); |
|
67 | - $c_start = $range[0]; |
|
68 | - $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
69 | - } |
|
70 | - |
|
71 | - $c_end = ($c_end > $end) ? $end : $c_end; |
|
72 | - if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
73 | - header("Content-Range: bytes $start-$end/$size"); |
|
74 | - |
|
75 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
76 | - } |
|
77 | - |
|
78 | - $start = (int) $c_start; |
|
79 | - $end = (int) $c_end; |
|
80 | - $length = (int) $end - $start + 1; |
|
81 | - fseek($stream, $start); |
|
82 | - header('HTTP/1.1 206 Partial Content'); |
|
83 | - header("Content-Range: bytes $start-$end/$size"); |
|
84 | - } |
|
85 | - |
|
86 | - header('Content-Length: '.$length); |
|
87 | - $buffer = 1024 * 8; |
|
88 | - |
|
89 | - while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
90 | - if ($p + $buffer > $end) { |
|
91 | - $buffer = $end - $p + 1; |
|
92 | - } |
|
93 | - |
|
94 | - echo fread($stream, $buffer); |
|
95 | - flush(); |
|
96 | - } |
|
97 | - |
|
98 | - fclose($stream); |
|
99 | - }); |
|
37 | + ->setOutputFormat(null) |
|
38 | + ->setBody(function () use ($file) { |
|
39 | + $stream = $file->get(); |
|
40 | + $name = $file->getName(); |
|
41 | + |
|
42 | + if (null === $stream) { |
|
43 | + return; |
|
44 | + } |
|
45 | + |
|
46 | + $size = $file->getSize(); |
|
47 | + $length = $size; |
|
48 | + $start = 0; |
|
49 | + $end = $size - 1; |
|
50 | + |
|
51 | + if (isset($_SERVER['HTTP_RANGE'])) { |
|
52 | + header('Accept-Ranges: bytes'); |
|
53 | + $c_start = $start; |
|
54 | + $c_end = $end; |
|
55 | + list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
56 | + |
|
57 | + if (strpos($range, ',') !== false) { |
|
58 | + header("Content-Range: bytes $start-$end/$size"); |
|
59 | + |
|
60 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
61 | + } |
|
62 | + |
|
63 | + if ($range == '-') { |
|
64 | + $c_start = $size - substr($range, 1); |
|
65 | + } else { |
|
66 | + $range = explode('-', $range); |
|
67 | + $c_start = $range[0]; |
|
68 | + $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
69 | + } |
|
70 | + |
|
71 | + $c_end = ($c_end > $end) ? $end : $c_end; |
|
72 | + if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
73 | + header("Content-Range: bytes $start-$end/$size"); |
|
74 | + |
|
75 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
76 | + } |
|
77 | + |
|
78 | + $start = (int) $c_start; |
|
79 | + $end = (int) $c_end; |
|
80 | + $length = (int) $end - $start + 1; |
|
81 | + fseek($stream, $start); |
|
82 | + header('HTTP/1.1 206 Partial Content'); |
|
83 | + header("Content-Range: bytes $start-$end/$size"); |
|
84 | + } |
|
85 | + |
|
86 | + header('Content-Length: '.$length); |
|
87 | + $buffer = 1024 * 8; |
|
88 | + |
|
89 | + while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
90 | + if ($p + $buffer > $end) { |
|
91 | + $buffer = $end - $p + 1; |
|
92 | + } |
|
93 | + |
|
94 | + echo fread($stream, $buffer); |
|
95 | + flush(); |
|
96 | + } |
|
97 | + |
|
98 | + fclose($stream); |
|
99 | + }); |
|
100 | 100 | } |
101 | 101 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | return $response |
37 | 37 | ->setOutputFormat(null) |
38 | - ->setBody(function () use ($file) { |
|
38 | + ->setBody(function() use ($file) { |
|
39 | 39 | $stream = $file->get(); |
40 | 40 | $name = $file->getName(); |
41 | 41 |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $this->db->storage->updateOne( |
50 | 50 | ['_id' => $object['_id']], |
51 | 51 | [ |
52 | - '$set' => ['pointer' => $pointer], |
|
52 | + '$set' => ['pointer' => $pointer], |
|
53 | 53 | ] |
54 | 54 | ); |
55 | 55 | } |
@@ -17,7 +17,6 @@ |
||
17 | 17 | use Balloon\Filesystem\Exception; |
18 | 18 | use Balloon\Filesystem\Storage\Adapter\AdapterInterface as StorageAdapterInterface; |
19 | 19 | use Balloon\Hook; |
20 | -use Balloon\Server\User; |
|
21 | 20 | use Generator; |
22 | 21 | use MimeType\MimeType; |
23 | 22 | use function MongoDB\BSON\fromJSON; |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $this->storage = $this->_parent->getStorage()->deleteCollection($this); |
363 | 363 | |
364 | 364 | if (!$this->isReference() && !$this->isMounted() && !$this->isFiltered()) { |
365 | - $this->doRecursiveAction(function ($node) use ($recursion) { |
|
365 | + $this->doRecursiveAction(function($node) use ($recursion) { |
|
366 | 366 | $node->delete(false, $recursion, false); |
367 | 367 | }, NodeInterface::DELETED_EXCLUDE); |
368 | 368 | } |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | protected function _forceDelete(?string $recursion = null, bool $recursion_first = true): bool |
918 | 918 | { |
919 | 919 | if (!$this->isReference() && !$this->isMounted() && !$this->isFiltered()) { |
920 | - $this->doRecursiveAction(function ($node) use ($recursion) { |
|
920 | + $this->doRecursiveAction(function($node) use ($recursion) { |
|
921 | 921 | $node->delete(true, $recursion, false); |
922 | 922 | }, NodeInterface::DELETED_INCLUDE); |
923 | 923 | } |