@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | foreach ($config as $option => $value) { |
95 | 95 | switch ($option) { |
96 | 96 | case 'preview_max_size': |
97 | - $this->preview_max_size = (int) $value; |
|
97 | + $this->preview_max_size = (int)$value; |
|
98 | 98 | |
99 | 99 | break; |
100 | 100 | default: |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function match(File $file): bool |
112 | 112 | { |
113 | - return (bool) preg_match($this->match_convert, $file->getContentType()); |
|
113 | + return (bool)preg_match($this->match_convert, $file->getContentType()); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function setExceptionHandler(): self |
82 | 82 | { |
83 | - set_exception_handler(function ($e) { |
|
83 | + set_exception_handler(function($e) { |
|
84 | 84 | $this->container->get(LoggerInterface::class)->emergency('uncaught exception: '.$e->getMessage(), [ |
85 | 85 | 'category' => get_class($this), |
86 | 86 | 'exception' => $e, |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected function setExceptionHandler(): self |
43 | 43 | { |
44 | - set_exception_handler(function ($e) { |
|
44 | + set_exception_handler(function($e) { |
|
45 | 45 | echo $e; |
46 | 46 | $logger = $this->container->get(LoggerInterface::class); |
47 | 47 | $logger->emergency('uncaught exception: '.$e->getMessage(), [ |
@@ -107,7 +107,7 @@ |
||
107 | 107 | * |
108 | 108 | * @param string $id |
109 | 109 | * @param string $p |
110 | - * @param string $version |
|
110 | + * @param integer $version |
|
111 | 111 | * |
112 | 112 | * @return Response |
113 | 113 | */ |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $body = []; |
84 | 84 | |
85 | 85 | foreach ($result as $version) { |
86 | - $v = (array) $version; |
|
86 | + $v = (array)$version; |
|
87 | 87 | |
88 | 88 | $v['user'] = $this->server->getUserById($version['user'])->getUsername(); |
89 | 89 | $v['changed'] = Helper::DateTimeToUnix($version['changed']); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $wrote = fwrite($chunkgroup_handler, $data); |
307 | 307 | $tmp_size += $wrote; |
308 | 308 | |
309 | - if ($tmp_size > (int) $this->server->getMaxFileSize()) { |
|
309 | + if ($tmp_size > (int)$this->server->getMaxFileSize()) { |
|
310 | 310 | fclose($input_handler); |
311 | 311 | fclose($chunkgroup_handler); |
312 | 312 | unlink($file); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | |
524 | 524 | return (new Response())->setCode(201)->setBody([ |
525 | 525 | 'code' => 201, |
526 | - 'data' => (string) $result, |
|
526 | + 'data' => (string)$result, |
|
527 | 527 | ]); |
528 | 528 | } |
529 | 529 | } catch (ForbiddenException $e) { |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | |
552 | 552 | return (new Response())->setCode(201)->setBody([ |
553 | 553 | 'code' => 201, |
554 | - 'data' => (string) $result, |
|
554 | + 'data' => (string)$result, |
|
555 | 555 | ]); |
556 | 556 | } catch (Exception\NotFound $e) { |
557 | 557 | throw new Exception('parent collection '.$parent_path.' was not found'); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param array|string $id |
283 | 283 | * @param array|string $p |
284 | 284 | * @param int $offset |
285 | - * @param int $legnth |
|
285 | + * @param int $length |
|
286 | 286 | * @param string $encode |
287 | 287 | * @param bool $download |
288 | 288 | * @param string $name |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | * @param string $class Force set node type |
1421 | 1421 | * @param bool $multiple Allow $id to be an array |
1422 | 1422 | * @param bool $allow_root Allow instance of root collection |
1423 | - * @param bool $deleted How to handle deleted node |
|
1423 | + * @param integer $deleted How to handle deleted node |
|
1424 | 1424 | * |
1425 | 1425 | * @return NodeInterface |
1426 | 1426 | */ |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | * @param string $id |
1455 | 1455 | * @param string $path |
1456 | 1456 | * @param string $class Force set node type |
1457 | - * @param bool $deleted How to handle deleted node |
|
1457 | + * @param integer $deleted How to handle deleted node |
|
1458 | 1458 | * |
1459 | 1459 | * @return Generator |
1460 | 1460 | */ |
@@ -320,50 +320,50 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | return (new Response()) |
323 | - ->setOutputFormat(null) |
|
324 | - ->setBody(function () use ($node, $encode, $offset, $length) { |
|
325 | - $mime = $node->getContentType(); |
|
326 | - $stream = $node->get(); |
|
327 | - $name = $node->getName(); |
|
328 | - |
|
329 | - if (null === $stream) { |
|
330 | - return; |
|
331 | - } |
|
332 | - |
|
333 | - if (0 !== $offset) { |
|
334 | - if (fseek($stream, $offset) === -1) { |
|
335 | - throw new Exception\Conflict( |
|
323 | + ->setOutputFormat(null) |
|
324 | + ->setBody(function () use ($node, $encode, $offset, $length) { |
|
325 | + $mime = $node->getContentType(); |
|
326 | + $stream = $node->get(); |
|
327 | + $name = $node->getName(); |
|
328 | + |
|
329 | + if (null === $stream) { |
|
330 | + return; |
|
331 | + } |
|
332 | + |
|
333 | + if (0 !== $offset) { |
|
334 | + if (fseek($stream, $offset) === -1) { |
|
335 | + throw new Exception\Conflict( |
|
336 | 336 | 'invalid offset requested', |
337 | 337 | Exception\Conflict::INVALID_OFFSET |
338 | 338 | ); |
339 | - } |
|
340 | - } |
|
341 | - |
|
342 | - $read = 0; |
|
343 | - header('Content-Type: '.$mime.''); |
|
344 | - if ('base64' === $encode) { |
|
345 | - header('Content-Encoding: base64'); |
|
346 | - while (!feof($stream)) { |
|
347 | - if (0 !== $length && $read + 8192 > $length) { |
|
348 | - echo base64_encode(fread($stream, $length - $read)); |
|
349 | - exit(); |
|
350 | - } |
|
351 | - |
|
352 | - echo base64_encode(fread($stream, 8192)); |
|
353 | - $read += 8192; |
|
354 | - } |
|
355 | - } else { |
|
356 | - while (!feof($stream)) { |
|
357 | - if (0 !== $length && $read + 8192 > $length) { |
|
358 | - echo fread($stream, $length - $read); |
|
359 | - exit(); |
|
360 | - } |
|
361 | - |
|
362 | - echo fread($stream, 8192); |
|
363 | - $read += 8192; |
|
364 | - } |
|
365 | - } |
|
366 | - }); |
|
339 | + } |
|
340 | + } |
|
341 | + |
|
342 | + $read = 0; |
|
343 | + header('Content-Type: '.$mime.''); |
|
344 | + if ('base64' === $encode) { |
|
345 | + header('Content-Encoding: base64'); |
|
346 | + while (!feof($stream)) { |
|
347 | + if (0 !== $length && $read + 8192 > $length) { |
|
348 | + echo base64_encode(fread($stream, $length - $read)); |
|
349 | + exit(); |
|
350 | + } |
|
351 | + |
|
352 | + echo base64_encode(fread($stream, 8192)); |
|
353 | + $read += 8192; |
|
354 | + } |
|
355 | + } else { |
|
356 | + while (!feof($stream)) { |
|
357 | + if (0 !== $length && $read + 8192 > $length) { |
|
358 | + echo fread($stream, $length - $read); |
|
359 | + exit(); |
|
360 | + } |
|
361 | + |
|
362 | + echo fread($stream, 8192); |
|
363 | + $read += 8192; |
|
364 | + } |
|
365 | + } |
|
366 | + }); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -1502,9 +1502,9 @@ discard block |
||
1502 | 1502 | $node->zip($archive); |
1503 | 1503 | } catch (\Exception $e) { |
1504 | 1504 | $this->logger->debug('failed zip node in multi node request ['.$node->getId().']', [ |
1505 | - 'category' => get_class($this), |
|
1506 | - 'exception' => $e, |
|
1507 | - ]); |
|
1505 | + 'category' => get_class($this), |
|
1506 | + 'exception' => $e, |
|
1507 | + ]); |
|
1508 | 1508 | } |
1509 | 1509 | } |
1510 | 1510 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $result = $this->_getNode($id, $p, null, false, false, $deleted); |
141 | 141 | |
142 | 142 | $response = (new Response()) |
143 | - ->setHeader('Content-Length', (string) $result->getSize()) |
|
143 | + ->setHeader('Content-Length', (string)$result->getSize()) |
|
144 | 144 | ->setHeader('Content-Type', $result->getContentType()) |
145 | 145 | ->setCode(200); |
146 | 146 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict, $move) { |
|
212 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict, $move) { |
|
213 | 213 | if (true === $move) { |
214 | 214 | $node = $node->setParent($parent, $conflict); |
215 | 215 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | |
291 | 291 | $node = $this->_getNode($id, $p); |
292 | 292 | if ($node instanceof Collection) { |
293 | - return (new Response())->setBody(function () use ($node) { |
|
293 | + return (new Response())->setBody(function() use ($node) { |
|
294 | 294 | $node->getZip(); |
295 | 295 | }); |
296 | 296 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $response->setHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\''.rawurlencode($name)); |
302 | 302 | $response->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); |
303 | 303 | $response->setHeader('Content-Type', 'application/octet-stream'); |
304 | - $response->setHeader('Content-Length', (string) $node->getSize()); |
|
304 | + $response->setHeader('Content-Length', (string)$node->getSize()); |
|
305 | 305 | $response->setHeader('Content-Transfer-Encoding', 'binary'); |
306 | 306 | } else { |
307 | 307 | $response->setHeader('Content-Disposition', 'inline; filename*=UTF-8\'\''.rawurlencode($name)); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | return (new Response()) |
311 | 311 | ->setOutputFormat(null) |
312 | - ->setBody(function () use ($node, $encode, $offset, $length) { |
|
312 | + ->setBody(function() use ($node, $encode, $offset, $length) { |
|
313 | 313 | $mime = $node->getContentType(); |
314 | 314 | $stream = $node->get(); |
315 | 315 | $name = $node->getName(); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function postReadonly($id = null, $p = null, bool $readonly = true): Response |
384 | 384 | { |
385 | - return $this->bulk($id, $p, function ($node) use ($readonly) { |
|
385 | + return $this->bulk($id, $p, function($node) use ($readonly) { |
|
386 | 386 | $node->setReadonly($readonly); |
387 | 387 | |
388 | 388 | return ['code' => 204]; |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | */ |
636 | 636 | public function postMetaAttributes(array $attributes, ?string $id = null, ?string $p = null): Response |
637 | 637 | { |
638 | - return $this->bulk($id, $p, function ($node) use ($attributes) { |
|
638 | + return $this->bulk($id, $p, function($node) use ($attributes) { |
|
639 | 639 | $node->setMetaAttributes($attributes); |
640 | 640 | |
641 | 641 | return ['code' => 204]; |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | ); |
724 | 724 | } |
725 | 725 | |
726 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
726 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
727 | 727 | $result = $node->copyTo($parent, $conflict); |
728 | 728 | |
729 | 729 | return [ |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | ); |
788 | 788 | } |
789 | 789 | |
790 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
790 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
791 | 791 | $result = $node->setParent($parent, $conflict); |
792 | 792 | if (NodeInterface::CONFLICT_RENAME === $conflict) { |
793 | 793 | return [ |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | $at = $this->_verifyAttributes(['destroy' => $at])['destroy']; |
847 | 847 | } |
848 | 848 | |
849 | - return $this->bulk($id, $p, function ($node) use ($force, $ignore_flag, $at) { |
|
849 | + return $this->bulk($id, $p, function($node) use ($force, $ignore_flag, $at) { |
|
850 | 850 | if (null === $at) { |
851 | 851 | $node->delete($force && $node->isDeleted() || $force && $ignore_flag); |
852 | 852 | } else { |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | $node = null; |
1190 | 1190 | } |
1191 | 1191 | |
1192 | - $this->event_decorator->addDecorator('timestamp', function (array $event) { |
|
1192 | + $this->event_decorator->addDecorator('timestamp', function(array $event) { |
|
1193 | 1193 | return Helper::DateTimeToUnix($event['timestamp']); |
1194 | 1194 | }); |
1195 | 1195 | |
@@ -1317,17 +1317,17 @@ discard block |
||
1317 | 1317 | $server = $this->server; |
1318 | 1318 | $fs = $this->fs; |
1319 | 1319 | |
1320 | - $this->decorator->addDecorator('parent', function ($node) { |
|
1320 | + $this->decorator->addDecorator('parent', function($node) { |
|
1321 | 1321 | $id = $node->getAttributes()['parent']; |
1322 | 1322 | |
1323 | 1323 | if (null === $id) { |
1324 | 1324 | return null; |
1325 | 1325 | } |
1326 | 1326 | |
1327 | - return (string) $id; |
|
1327 | + return (string)$id; |
|
1328 | 1328 | }); |
1329 | 1329 | |
1330 | - $this->decorator->addDecorator('shareowner', function ($node) use ($server, $fs) { |
|
1330 | + $this->decorator->addDecorator('shareowner', function($node) use ($server, $fs) { |
|
1331 | 1331 | if (!$node->isSpecial()) { |
1332 | 1332 | return null; |
1333 | 1333 | } |
@@ -1339,7 +1339,7 @@ discard block |
||
1339 | 1339 | } |
1340 | 1340 | }); |
1341 | 1341 | |
1342 | - $this->decorator->addDecorator('history', function ($node) { |
|
1342 | + $this->decorator->addDecorator('history', function($node) { |
|
1343 | 1343 | if ($node instanceof File) { |
1344 | 1344 | return $node->getHistory(); |
1345 | 1345 | } |
@@ -1347,59 +1347,59 @@ discard block |
||
1347 | 1347 | return null; |
1348 | 1348 | }); |
1349 | 1349 | |
1350 | - $this->decorator->addDecorator('filter', function ($node) { |
|
1350 | + $this->decorator->addDecorator('filter', function($node) { |
|
1351 | 1351 | return null; |
1352 | 1352 | }); |
1353 | 1353 | |
1354 | - $this->decorator->addDecorator('owner', function ($node) { |
|
1354 | + $this->decorator->addDecorator('owner', function($node) { |
|
1355 | 1355 | return null; |
1356 | 1356 | }); |
1357 | 1357 | |
1358 | - $this->decorator->addDecorator('shared', function ($node) { |
|
1358 | + $this->decorator->addDecorator('shared', function($node) { |
|
1359 | 1359 | return null; |
1360 | 1360 | }); |
1361 | 1361 | |
1362 | - $this->decorator->addDecorator('sharename', function ($node) { |
|
1362 | + $this->decorator->addDecorator('sharename', function($node) { |
|
1363 | 1363 | return null; |
1364 | 1364 | }); |
1365 | 1365 | |
1366 | - $this->decorator->addDecorator('malware_quarantine', function ($node) { |
|
1366 | + $this->decorator->addDecorator('malware_quarantine', function($node) { |
|
1367 | 1367 | return null; |
1368 | 1368 | }); |
1369 | 1369 | |
1370 | - $this->decorator->addDecorator('subscription', function ($node) { |
|
1370 | + $this->decorator->addDecorator('subscription', function($node) { |
|
1371 | 1371 | return null; |
1372 | 1372 | }); |
1373 | 1373 | |
1374 | - $this->decorator->addDecorator('subscription_exclude_me', function ($node) { |
|
1374 | + $this->decorator->addDecorator('subscription_exclude_me', function($node) { |
|
1375 | 1375 | return null; |
1376 | 1376 | }); |
1377 | 1377 | |
1378 | - $this->decorator->addDecorator('subscription_recursive', function ($node) { |
|
1378 | + $this->decorator->addDecorator('subscription_recursive', function($node) { |
|
1379 | 1379 | return null; |
1380 | 1380 | }); |
1381 | 1381 | |
1382 | - $this->decorator->addDecorator('share', function ($node) { |
|
1382 | + $this->decorator->addDecorator('share', function($node) { |
|
1383 | 1383 | return $node->isShare(); |
1384 | 1384 | }); |
1385 | 1385 | |
1386 | - $this->decorator->addDecorator('created', function ($node) { |
|
1386 | + $this->decorator->addDecorator('created', function($node) { |
|
1387 | 1387 | return Helper::DateTimeToUnix($node->getAttributes()['created']); |
1388 | 1388 | }); |
1389 | 1389 | |
1390 | - $this->decorator->addDecorator('changed', function ($node) { |
|
1390 | + $this->decorator->addDecorator('changed', function($node) { |
|
1391 | 1391 | return Helper::DateTimeToUnix($node->getAttributes()['changed']); |
1392 | 1392 | }); |
1393 | 1393 | |
1394 | - $this->decorator->addDecorator('deleted', function ($node) { |
|
1394 | + $this->decorator->addDecorator('deleted', function($node) { |
|
1395 | 1395 | return Helper::DateTimeToUnix($node->getAttributes()['deleted']); |
1396 | 1396 | }); |
1397 | 1397 | |
1398 | - $this->decorator->addDecorator('destroy', function ($node) { |
|
1398 | + $this->decorator->addDecorator('destroy', function($node) { |
|
1399 | 1399 | return Helper::DateTimeToUnix($node->getAttributes()['destroy']); |
1400 | 1400 | }); |
1401 | 1401 | |
1402 | - $this->decorator->addDecorator('filtered', function ($node) { |
|
1402 | + $this->decorator->addDecorator('filtered', function($node) { |
|
1403 | 1403 | if (!($node instanceof Collection)) { |
1404 | 1404 | return null; |
1405 | 1405 | } |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | return $node->getAttributes()['filter']; |
1408 | 1408 | }); |
1409 | 1409 | |
1410 | - $this->role_decorator->addDecorator('username', function ($user) { |
|
1410 | + $this->role_decorator->addDecorator('username', function($user) { |
|
1411 | 1411 | return $user->getAttributes()['username']; |
1412 | 1412 | }); |
1413 | 1413 | } |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | foreach ($attributes as $attribute => $value) { |
1545 | 1545 | switch ($attribute) { |
1546 | 1546 | case 'filter': |
1547 | - $attributes['filter'] = json_encode((array) $attributes['filter']); |
|
1547 | + $attributes['filter'] = json_encode((array)$attributes['filter']); |
|
1548 | 1548 | |
1549 | 1549 | break; |
1550 | 1550 | case 'destroy': |
@@ -1559,14 +1559,14 @@ discard block |
||
1559 | 1559 | if (!Helper::isValidTimestamp($value)) { |
1560 | 1560 | throw new Exception\InvalidArgument($attribute.' Changed timestamp must be valid unix timestamp'); |
1561 | 1561 | } |
1562 | - if ((int) $value > time()) { |
|
1562 | + if ((int)$value > time()) { |
|
1563 | 1563 | throw new Exception\InvalidArgument($attribute.' timestamp can not be set greater than the server time'); |
1564 | 1564 | } |
1565 | 1565 | $attributes[$attribute] = new UTCDateTime($value.'000'); |
1566 | 1566 | |
1567 | 1567 | break; |
1568 | 1568 | case 'readonly': |
1569 | - $attributes['readonly'] = (bool) $attributes['readonly']; |
|
1569 | + $attributes['readonly'] = (bool)$attributes['readonly']; |
|
1570 | 1570 | |
1571 | 1571 | break; |
1572 | 1572 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * Constructor. |
57 | 57 | * |
58 | - * @param Notification $notifier |
|
58 | + * @param Notifier $notifier |
|
59 | 59 | * @param Server $server |
60 | 60 | */ |
61 | 61 | public function __construct(Notifier $notifier, Server $server, LoggerInterface $logger, TemplateHandler $template) |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param NodeInterface $node |
130 | 130 | * @param User $user |
131 | 131 | * |
132 | - * @return string |
|
132 | + * @return boolean |
|
133 | 133 | */ |
134 | 134 | protected function checkNotify(NodeInterface $node, User $user): bool |
135 | 135 | { |
@@ -14,7 +14,6 @@ |
||
14 | 14 | use Balloon\App\Notification\NodeMessage; |
15 | 15 | use Balloon\App\Notification\Notifier; |
16 | 16 | use Balloon\App\Notification\TemplateHandler; |
17 | -use Balloon\Async\Mail; |
|
18 | 17 | use Balloon\Filesystem\Node\Collection; |
19 | 18 | use Balloon\Filesystem\Node\NodeInterface; |
20 | 19 | use Balloon\Hook\AbstractHook; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | $receiver = []; |
106 | 106 | foreach ($node->getAcl() as $rule) { |
107 | 107 | if ('user' === $rule['type']) { |
108 | - if (!isset($receiver[(string) $rule['role']->getId()]) && $this->checkNotify($node, $rule['role'])) { |
|
109 | - $receiver[(string) $rule['role']->getId()] = $rule['role']; |
|
108 | + if (!isset($receiver[(string)$rule['role']->getId()]) && $this->checkNotify($node, $rule['role'])) { |
|
109 | + $receiver[(string)$rule['role']->getId()] = $rule['role']; |
|
110 | 110 | } |
111 | 111 | } elseif ('group' === $rule['type']) { |
112 | 112 | foreach ($rule['role']->getResolvedMember() as $user) { |
113 | - if (!isset($receiver[(string) $user->getId()]) && $this->checkNotify($node, $user)) { |
|
114 | - $receiver[(string) $user->getId()] = $user; |
|
113 | + if (!isset($receiver[(string)$user->getId()]) && $this->checkNotify($node, $user)) { |
|
114 | + $receiver[(string)$user->getId()] = $user; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | /** |
65 | 65 | * Constructor. |
66 | 66 | * |
67 | - * @param Notification $notifier |
|
67 | + * @param Notifier $notifier |
|
68 | 68 | * @param Server $server |
69 | 69 | */ |
70 | 70 | public function __construct(Notifier $notifier, Server $server, TemplateHandler $template, LoggerInterface $logger, ?Iterable $config = null) |
@@ -20,7 +20,6 @@ |
||
20 | 20 | use Balloon\Filesystem\Node\NodeInterface; |
21 | 21 | use Balloon\Hook\AbstractHook; |
22 | 22 | use Balloon\Server; |
23 | -use Balloon\Server\User; |
|
24 | 23 | use MongoDB\BSON\UTCDateTime; |
25 | 24 | use Psr\Log\LoggerInterface; |
26 | 25 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | foreach ($config as $option => $value) { |
93 | 93 | switch ($option) { |
94 | 94 | case 'notification_throttle': |
95 | - $this->{$option} = (int) $value; |
|
95 | + $this->{$option} = (int)$value; |
|
96 | 96 | |
97 | 97 | break; |
98 | 98 | default: |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | public function postCreateCollection(Collection $parent, Collection $node, bool $clone): void |
110 | 110 | { |
111 | 111 | $this->notify($node); |
112 | - $user_id = (string) $this->server->getIdentity()->getId(); |
|
112 | + $user_id = (string)$this->server->getIdentity()->getId(); |
|
113 | 113 | $subs = $parent->getAppAttribute('Balloon\\App\\Notification', 'subscription'); |
114 | 114 | |
115 | 115 | if (isset($subs[$user_id]) && $subs[$user_id]['recursive'] === true) { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $parent = $node->getParent(); |
172 | 172 | |
173 | 173 | if ($parent !== null) { |
174 | - $subs = array_keys((array) $parent->getAppAttribute('Balloon\\App\\Notification', 'subscription')); |
|
174 | + $subs = array_keys((array)$parent->getAppAttribute('Balloon\\App\\Notification', 'subscription')); |
|
175 | 175 | $parents = $this->getReceiver($parent); |
176 | 176 | |
177 | 177 | $blacklist = array_diff($subs, $parents); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $node->setAppAttribute('Balloon\\App\\Notification', 'subscription', $update); |
224 | 224 | |
225 | 225 | if ($this->server->getIdentity() !== null) { |
226 | - $user_id = (string) $this->server->getIdentity()->getId(); |
|
226 | + $user_id = (string)$this->server->getIdentity()->getId(); |
|
227 | 227 | if (isset($subs[$user_id]) && $subs[$user_id]['exclude_me'] === true) { |
228 | 228 | $this->logger->debug('skip message for user ['.$user_id.'], user excludes own actions in node ['.$node->getId().']', [ |
229 | 229 | 'category' => get_class($this), |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param Database $db |
73 | 73 | * @param Server $server |
74 | - * @param LoggerInterace $logger |
|
74 | + * @param LoggerInterface $logger |
|
75 | 75 | * @param iterable $config |
76 | 76 | */ |
77 | 77 | public function __construct(Database $db, Server $server, LoggerInterface $logger, ?Iterable $config = null) |
@@ -116,9 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @param iterable $receiver |
118 | 118 | * @param User $sender |
119 | - * @param string $subject |
|
120 | - * @param string $body |
|
121 | - * @param array $context |
|
119 | + * @param string $context |
|
122 | 120 | * |
123 | 121 | * @return bool |
124 | 122 | */ |
@@ -226,10 +224,10 @@ discard block |
||
226 | 224 | /** |
227 | 225 | * Add notification. |
228 | 226 | * |
229 | - * @param array $receiver |
|
230 | - * @param User $user |
|
227 | + * @param User $receiver |
|
231 | 228 | * @param MessageInterface $message |
232 | 229 | * @param array $context |
230 | + * @param User $sender |
|
233 | 231 | * |
234 | 232 | * @return ObjectId |
235 | 233 | */ |
@@ -266,7 +264,7 @@ discard block |
||
266 | 264 | /** |
267 | 265 | * Get notifications. |
268 | 266 | * |
269 | - * @param ObjectId $id |
|
267 | + * @param User $id |
|
270 | 268 | * |
271 | 269 | * @return bool |
272 | 270 | */ |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | public function subscribeNode(NodeInterface $node, bool $subscribe = true, bool $exclude_me = true, bool $recursive = false): bool |
302 | 302 | { |
303 | 303 | $subs = $node->getAppAttribute(__NAMESPACE__, 'subscription'); |
304 | - $user_id = (string) $this->server->getIdentity()->getId(); |
|
304 | + $user_id = (string)$this->server->getIdentity()->getId(); |
|
305 | 305 | |
306 | 306 | if (true === $subscribe) { |
307 | 307 | $this->logger->debug('user ['.$this->server->getIdentity()->getId().'] subribes node ['.$node->getId().']', [ |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $subs[$user_id] = $subscription; |
318 | 318 | $node->setAppAttribute(__NAMESPACE__, 'subscription', $subs); |
319 | 319 | if ($node instanceof Collection && $recursive === true) { |
320 | - $node->doRecursiveAction(function ($child) use ($subscription, $user_id) { |
|
320 | + $node->doRecursiveAction(function($child) use ($subscription, $user_id) { |
|
321 | 321 | $subs = $child->getAppAttribute(__NAMESPACE__, 'subscription'); |
322 | 322 | $subs[$user_id] = $subscription; |
323 | 323 | $child->setAppAttribute(__NAMESPACE__, 'subscription', $subs); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $node->setAppAttribute(__NAMESPACE__, 'subscription', $subs); |
336 | 336 | |
337 | 337 | if ($node instanceof Collection && $recursive === true) { |
338 | - $node->doRecursiveAction(function ($child) use ($user_id) { |
|
338 | + $node->doRecursiveAction(function($child) use ($user_id) { |
|
339 | 339 | $subs = $child->getAppAttribute(__NAMESPACE__, 'subscription'); |
340 | 340 | |
341 | 341 | if (isset($subs[$user_id])) { |
@@ -218,8 +218,6 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * Replace variables. |
220 | 220 | * |
221 | - * @param string $type |
|
222 | - * @param User $user |
|
223 | 221 | */ |
224 | 222 | protected function decorate(string $template): string |
225 | 223 | { |
@@ -229,8 +227,6 @@ discard block |
||
229 | 227 | /** |
230 | 228 | * Replace variables. |
231 | 229 | * |
232 | - * @param string $type |
|
233 | - * @param User $user |
|
234 | 230 | */ |
235 | 231 | protected function decorateNode(string $template, NodeInterface $node): string |
236 | 232 | { |
@@ -248,7 +244,6 @@ discard block |
||
248 | 244 | /** |
249 | 245 | * Replace variables. |
250 | 246 | * |
251 | - * @param string $type |
|
252 | 247 | * @param User $user |
253 | 248 | */ |
254 | 249 | protected function decorateUser(string $template, User $user): string |
@@ -267,9 +262,9 @@ discard block |
||
267 | 262 | /** |
268 | 263 | * Get array value via string path. |
269 | 264 | * |
270 | - * @param iterable $arr |
|
265 | + * @param iterable $array |
|
271 | 266 | * @param string $path |
272 | - * @param string $seperator |
|
267 | + * @param string $separator |
|
273 | 268 | * |
274 | 269 | * @return mixed |
275 | 270 | */ |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * balloon |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | switch ($option) { |
121 | 121 | case 'asset_dir': |
122 | 122 | case 'fallback_locale': |
123 | - $this->{$option} = (string) $value; |
|
123 | + $this->{$option} = (string)$value; |
|
124 | 124 | |
125 | 125 | break; |
126 | 126 | default: |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | { |
237 | 237 | $decorator = $this->decorator; |
238 | 238 | |
239 | - return preg_replace_callback('/(\{node\.(([a-z]\.*)+)\})/', function ($match) use ($node, $decorator) { |
|
239 | + return preg_replace_callback('/(\{node\.(([a-z]\.*)+)\})/', function($match) use ($node, $decorator) { |
|
240 | 240 | $key = explode('.', $match[2]); |
241 | 241 | $key = array_shift($key); |
242 | 242 | $attrs = $decorator->decorate($node, [$key]); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | { |
256 | 256 | $role_decorator = $this->role_decorator; |
257 | 257 | |
258 | - return preg_replace_callback('/(\{user\.(([a-z]\.*)+)\})/', function ($match) use ($user, $role_decorator) { |
|
258 | + return preg_replace_callback('/(\{user\.(([a-z]\.*)+)\})/', function($match) use ($user, $role_decorator) { |
|
259 | 259 | $key = explode('.', $match[2]); |
260 | 260 | $key = array_shift($key); |
261 | 261 | $attrs = $role_decorator->decorate($user, [$key]); |