@@ -12,7 +12,6 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace Balloon\App\Preview; |
| 14 | 14 | |
| 15 | -use Balloon\Exception; |
|
| 16 | 15 | use Balloon\Filesystem\Node\File; |
| 17 | 16 | use Balloon\Hook\AbstractHook; |
| 18 | 17 | use MongoDB\GridFS\Exception\FileNotFoundException; |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * balloon |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | * @param string $path |
| 695 | 695 | * @param bool $new |
| 696 | 696 | * |
| 697 | - * @return bool |
|
| 697 | + * @return string |
|
| 698 | 698 | */ |
| 699 | 699 | protected function verifyFile(?string $path, bool $new = false): string |
| 700 | 700 | { |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | /** |
| 828 | 828 | * Finalize put request. |
| 829 | 829 | * |
| 830 | - * @param resource|string $file |
|
| 830 | + * @param string|null $file |
|
| 831 | 831 | * @param bool $new |
| 832 | 832 | * @param array $attributes |
| 833 | 833 | * |
@@ -589,7 +589,7 @@ |
||
| 589 | 589 | ]); |
| 590 | 590 | |
| 591 | 591 | $this->addVersion($attributes) |
| 592 | - ->postPutFile($file, $new, $attributes); |
|
| 592 | + ->postPutFile($file, $new, $attributes); |
|
| 593 | 593 | |
| 594 | 594 | return $this->version; |
| 595 | 595 | } |
@@ -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 |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | * @param array |
| 45 | 45 | **/ |
| 46 | 46 | protected $temp_files = [ |
| 47 | - '/^\._(.*)$/', // OS/X resource forks |
|
| 48 | - '/^.DS_Store$/', // OS/X custom folder settings |
|
| 47 | + '/^\._(.*)$/', // OS/X resource forks |
|
| 48 | + '/^.DS_Store$/', // OS/X custom folder settings |
|
| 49 | 49 | '/^desktop.ini$/', // Windows custom folder settings |
| 50 | - '/^Thumbs.db$/', // Windows thumbnail cache |
|
| 51 | - '/^.(.*).swpx$/', // ViM temporary files |
|
| 52 | - '/^.(.*).swx$/', // ViM temporary files |
|
| 53 | - '/^.(.*).swp$/', // ViM temporary files |
|
| 54 | - '/^\.dat(.*)$/', // Smultron seems to create these |
|
| 50 | + '/^Thumbs.db$/', // Windows thumbnail cache |
|
| 51 | + '/^.(.*).swpx$/', // ViM temporary files |
|
| 52 | + '/^.(.*).swx$/', // ViM temporary files |
|
| 53 | + '/^.(.*).swp$/', // ViM temporary files |
|
| 54 | + '/^\.dat(.*)$/', // Smultron seems to create these |
|
| 55 | 55 | '/^~lock.(.*)#$/', // Windows 7 lockfiles |
| 56 | 56 | ]; |
| 57 | 57 | |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | $this->hash = $new_hash; |
| 546 | - $max = (int) (string) $this->_fs->getServer()->getMaxFileVersion(); |
|
| 546 | + $max = (int)(string)$this->_fs->getServer()->getMaxFileVersion(); |
|
| 547 | 547 | if (count($this->history) >= $max) { |
| 548 | 548 | $del = key($this->history); |
| 549 | 549 | $this->_logger->debug('history limit ['.$max.'] reached, remove oldest version ['.$del.'] from file ['.$this->_id.']', [ |
@@ -637,8 +637,8 @@ discard block |
||
| 637 | 637 | { |
| 638 | 638 | assert(16 === strlen($data)); |
| 639 | 639 | |
| 640 | - $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 |
|
| 641 | - $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 |
|
| 640 | + $data[6] = chr(ord($data[6])&0x0f|0x40); // set version to 0100 |
|
| 641 | + $data[8] = chr(ord($data[8])&0x3f|0x80); // set bits 6-7 to 10 |
|
| 642 | 642 | |
| 643 | 643 | return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); |
| 644 | 644 | } |
@@ -741,11 +741,11 @@ discard block |
||
| 741 | 741 | |
| 742 | 742 | $tmp_file = $tmp.DIRECTORY_SEPARATOR.$this->guidv4(openssl_random_pseudo_bytes(16)); |
| 743 | 743 | $stream = fopen($tmp_file, 'w+'); |
| 744 | - $size = stream_copy_to_stream($file, $stream, ((int) $this->_fs->getServer()->getMaxFileSize() + 1)); |
|
| 744 | + $size = stream_copy_to_stream($file, $stream, ((int)$this->_fs->getServer()->getMaxFileSize() + 1)); |
|
| 745 | 745 | rewind($stream); |
| 746 | 746 | fclose($file); |
| 747 | 747 | |
| 748 | - if ($size > (int) $this->_fs->getServer()->getMaxFileSize()) { |
|
| 748 | + if ($size > (int)$this->_fs->getServer()->getMaxFileSize()) { |
|
| 749 | 749 | unlink($tmp_file); |
| 750 | 750 | |
| 751 | 751 | throw new Exception\InsufficientStorage( |
@@ -18,7 +18,6 @@ |
||
| 18 | 18 | use Balloon\Filesystem\Storage; |
| 19 | 19 | use Balloon\Hook; |
| 20 | 20 | use Balloon\Mime; |
| 21 | -use Balloon\Server\User; |
|
| 22 | 21 | use MongoDB\BSON\UTCDateTime; |
| 23 | 22 | use Psr\Log\LoggerInterface; |
| 24 | 23 | use Sabre\DAV\IFile; |
@@ -108,14 +108,13 @@ |
||
| 108 | 108 | * |
| 109 | 109 | * @param bool $reference |
| 110 | 110 | * |
| 111 | - * @return ObjectId |
|
| 111 | + * @return ObjectId|null |
|
| 112 | 112 | */ |
| 113 | 113 | public function getShareId(bool $reference = false): ?ObjectId; |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * Get share node. |
| 117 | 117 | * |
| 118 | - * @param bool $reference |
|
| 119 | 118 | * |
| 120 | 119 | * @return Collection |
| 121 | 120 | */ |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * balloon |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | /** |
| 174 | 174 | * Configure cli logger. |
| 175 | 175 | * |
| 176 | - * @return Cli |
|
| 176 | + * @return Console |
|
| 177 | 177 | */ |
| 178 | 178 | protected function configureLogger(?int $level = null): self |
| 179 | 179 | { |
@@ -264,7 +264,6 @@ discard block |
||
| 264 | 264 | /** |
| 265 | 265 | * Start. |
| 266 | 266 | * |
| 267 | - * @param array $options |
|
| 268 | 267 | * |
| 269 | 268 | * @return bool |
| 270 | 269 | */ |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * balloon |
@@ -50,7 +50,6 @@ |
||
| 50 | 50 | /** |
| 51 | 51 | * Constructor. |
| 52 | 52 | * |
| 53 | - * @param App $app |
|
| 54 | 53 | * @param Async $async |
| 55 | 54 | * @param LoggerInterface $logger |
| 56 | 55 | * @param GetOpt $getopt |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * balloon |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | * |
| 61 | 61 | * @param Server $server |
| 62 | 62 | * @param Acl $acl |
| 63 | - * @param Decorator $role_decorator |
|
| 63 | + * @param RoleAttributeDecorator $role_decorator |
|
| 64 | 64 | */ |
| 65 | 65 | public function __construct(Server $server, Acl $acl, RoleAttributeDecorator $role_decorator) |
| 66 | 66 | { |
@@ -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 |
@@ -125,25 +125,25 @@ discard block |
||
| 125 | 125 | $decorator = $this->role_decorator; |
| 126 | 126 | |
| 127 | 127 | return [ |
| 128 | - 'id' => (string) $attributes['_id'], |
|
| 129 | - 'name' => (string) $attributes['name'], |
|
| 130 | - 'mime' => (string) $attributes['mime'], |
|
| 131 | - 'readonly' => (bool) $attributes['readonly'], |
|
| 128 | + 'id' => (string)$attributes['_id'], |
|
| 129 | + 'name' => (string)$attributes['name'], |
|
| 130 | + 'mime' => (string)$attributes['mime'], |
|
| 131 | + 'readonly' => (bool)$attributes['readonly'], |
|
| 132 | 132 | 'directory' => $node instanceof Collection, |
| 133 | - 'meta' => function ($node) { |
|
| 134 | - return (object) $node->getMetaAttributes(); |
|
| 133 | + 'meta' => function($node) { |
|
| 134 | + return (object)$node->getMetaAttributes(); |
|
| 135 | 135 | }, |
| 136 | - 'size' => function ($node) { |
|
| 136 | + 'size' => function($node) { |
|
| 137 | 137 | return $node->getSize(); |
| 138 | 138 | }, |
| 139 | - 'path' => function ($node) { |
|
| 139 | + 'path' => function($node) { |
|
| 140 | 140 | try { |
| 141 | 141 | return $node->getPath(); |
| 142 | 142 | } catch (\Exception $e) { |
| 143 | 143 | return null; |
| 144 | 144 | } |
| 145 | 145 | }, |
| 146 | - 'parent' => function ($node) { |
|
| 146 | + 'parent' => function($node) { |
|
| 147 | 147 | $parent = $node->getParent(); |
| 148 | 148 | |
| 149 | 149 | if (null === $parent || $parent->isRoot()) { |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | return $this->decorate($node->getParent(), ['id', 'name', '_links']); |
| 154 | 154 | }, |
| 155 | - 'access' => function ($node) use ($acl) { |
|
| 155 | + 'access' => function($node) use ($acl) { |
|
| 156 | 156 | return $acl->getAclPrivilege($node); |
| 157 | 157 | }, |
| 158 | - 'share' => function ($node) { |
|
| 158 | + 'share' => function($node) { |
|
| 159 | 159 | if ($node->isShared() || !$node->isSpecial()) { |
| 160 | 160 | return null; |
| 161 | 161 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | return null; |
| 167 | 167 | } |
| 168 | 168 | }, |
| 169 | - 'sharename' => function ($node) { |
|
| 169 | + 'sharename' => function($node) { |
|
| 170 | 170 | if (!$node->isShared()) { |
| 171 | 171 | return null; |
| 172 | 172 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | return null; |
| 178 | 178 | } |
| 179 | 179 | }, |
| 180 | - 'shareowner' => function ($node) use ($server, $fs, $decorator) { |
|
| 180 | + 'shareowner' => function($node) use ($server, $fs, $decorator) { |
|
| 181 | 181 | if (!$node->isSpecial()) { |
| 182 | 182 | return null; |
| 183 | 183 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | return null; |
| 192 | 192 | } |
| 193 | 193 | }, |
| 194 | - 'owner' => function ($node) use ($server, $decorator) { |
|
| 194 | + 'owner' => function($node) use ($server, $decorator) { |
|
| 195 | 195 | try { |
| 196 | 196 | return $decorator->decorate( |
| 197 | 197 | $server->getUserById($node->getOwner()), |
@@ -215,20 +215,20 @@ discard block |
||
| 215 | 215 | protected function getTimeAttributes(NodeInterface $node, array $attributes): array |
| 216 | 216 | { |
| 217 | 217 | return [ |
| 218 | - 'created' => function ($node) use ($attributes) { |
|
| 218 | + 'created' => function($node) use ($attributes) { |
|
| 219 | 219 | return $attributes['created']->toDateTime()->format('c'); |
| 220 | 220 | }, |
| 221 | - 'changed' => function ($node) use ($attributes) { |
|
| 221 | + 'changed' => function($node) use ($attributes) { |
|
| 222 | 222 | return $attributes['changed']->toDateTime()->format('c'); |
| 223 | 223 | }, |
| 224 | - 'deleted' => function ($node) use ($attributes) { |
|
| 224 | + 'deleted' => function($node) use ($attributes) { |
|
| 225 | 225 | if (false === $attributes['deleted']) { |
| 226 | 226 | return null; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | return $attributes['deleted']->toDateTime()->format('c'); |
| 230 | 230 | }, |
| 231 | - 'destroy' => function ($node) use ($attributes) { |
|
| 231 | + 'destroy' => function($node) use ($attributes) { |
|
| 232 | 232 | if (null === $attributes['destroy']) { |
| 233 | 233 | return null; |
| 234 | 234 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | return [ |
| 262 | 262 | 'shared' => $node->isShared(), |
| 263 | 263 | 'reference' => $node->isReference(), |
| 264 | - 'filter' => function ($node) use ($attributes) { |
|
| 264 | + 'filter' => function($node) use ($attributes) { |
|
| 265 | 265 | if (null === $attributes['filter']) { |
| 266 | 266 | return null; |
| 267 | 267 | } |
@@ -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,8 +140,8 @@ discard block |
||
| 140 | 140 | 'BaseFileName' => $attrs['name'], |
| 141 | 141 | 'Size' => $doc->getSize(), |
| 142 | 142 | 'Version' => $attrs['version'], |
| 143 | - 'OwnerId' => (string) $doc->getNode()->getOwner(), |
|
| 144 | - 'UserId' => (string) $this->user->getId(), |
|
| 143 | + 'OwnerId' => (string)$doc->getNode()->getOwner(), |
|
| 144 | + 'UserId' => (string)$this->user->getId(), |
|
| 145 | 145 | 'UserFriendlyName' => $this->user->getUsername(), |
| 146 | 146 | 'UserCanWrite' => true, |
| 147 | 147 | 'PostMessageOrigin' => null, |
@@ -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 |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | foreach ($config as $key => $value) { |
| 69 | 69 | switch ($key) { |
| 70 | 70 | case 'index_configuration': |
| 71 | - $this->{$key} = (string) $value; |
|
| 71 | + $this->{$key} = (string)$value; |
|
| 72 | 72 | |
| 73 | 73 | break; |
| 74 | 74 | default: |
@@ -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 |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | $role_decorator = $this->role_decorator; |
| 79 | 79 | |
| 80 | - $string = preg_replace_callback('/(\{user\.(([a-z]\.*)+)\})/', function ($match) use ($user, $role_decorator) { |
|
| 80 | + $string = preg_replace_callback('/(\{user\.(([a-z]\.*)+)\})/', function($match) use ($user, $role_decorator) { |
|
| 81 | 81 | return $role_decorator->decorate($user, [$match[2]])[$match[2]]; |
| 82 | 82 | }, $this->{$type}); |
| 83 | 83 | |