@@ -2,7 +2,6 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Charcoal\Admin\Widget; |
4 | 4 | |
5 | -use ArrayIterator; |
|
6 | 5 | use Charcoal\Model\ModelInterface; |
7 | 6 | use RuntimeException; |
8 | 7 | use InvalidArgumentException; |
@@ -11,7 +10,6 @@ discard block |
||
11 | 10 | use Pimple\Container; |
12 | 11 | |
13 | 12 | // From 'bobthecow/mustache.php' |
14 | -use Mustache_LambdaHelper as LambdaHelper; |
|
15 | 13 | |
16 | 14 | // From 'charcoal-config' |
17 | 15 | use Charcoal\Config\ConfigurableInterface; |
@@ -20,7 +18,6 @@ discard block |
||
20 | 18 | use Charcoal\Factory\FactoryInterface; |
21 | 19 | |
22 | 20 | // From 'charcoal-core' |
23 | -use Charcoal\Loader\CollectionLoader; |
|
24 | 21 | |
25 | 22 | // From 'charcoal-translator' |
26 | 23 | use Charcoal\Translator\Translation; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ]); |
208 | 208 | |
209 | 209 | foreach ($attachments as $attachment) { |
210 | - $GLOBALS['widget_template'] = (string)$attachment->rawPreview(); |
|
210 | + $GLOBALS['widget_template'] = (string) $attachment->rawPreview(); |
|
211 | 211 | |
212 | 212 | if (isset($attachableObjects[$attachment->objType()])) { |
213 | 213 | $attachment->attachmentType = $attachableObjects[$attachment->objType()]; |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | ); |
474 | 474 | } |
475 | 475 | |
476 | - $num = (int)$num; |
|
476 | + $num = (int) $num; |
|
477 | 477 | |
478 | 478 | if ($num < 0) { |
479 | 479 | throw new InvalidArgumentException( |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | ); |
502 | 502 | } |
503 | 503 | |
504 | - $page = (int)$page; |
|
504 | + $page = (int) $page; |
|
505 | 505 | |
506 | 506 | if ($page < 0) { |
507 | 507 | throw new InvalidArgumentException( |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | /** |
225 | 225 | * Determine the number of attachments. |
226 | 226 | * |
227 | - * @return boolean |
|
227 | + * @return integer |
|
228 | 228 | */ |
229 | 229 | public function hasAttachments() |
230 | 230 | { |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param string $lang The language code. |
378 | 378 | * @throws InvalidArgumentException If the argument is not a string. |
379 | - * @return UserDataInterface Chainable |
|
379 | + * @return AttachmentWidget Chainable |
|
380 | 380 | */ |
381 | 381 | public function setLang($lang) |
382 | 382 | { |
@@ -25,7 +25,6 @@ |
||
25 | 25 | // From 'locomotivemtl/charcoal-attachments' |
26 | 26 | use Charcoal\Attachment\Interfaces\AttachableInterface; |
27 | 27 | use Charcoal\Attachment\Interfaces\AttachmentContainerInterface; |
28 | - |
|
29 | 28 | use Charcoal\Attachment\Object\File; |
30 | 29 | use Charcoal\Attachment\Object\Image; |
31 | 30 | use Charcoal\Attachment\Object\Text; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | parent::__construct($data); |
182 | 182 | |
183 | - if (is_callable([ $this, 'defaultData' ])) { |
|
183 | + if (is_callable([$this, 'defaultData'])) { |
|
184 | 184 | $defaultData = $this->defaultData(); |
185 | 185 | if ($defaultData) { |
186 | 186 | $this->setData($defaultData); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | */ |
357 | 357 | public function heading() |
358 | 358 | { |
359 | - $heading = $this->render((string)$this->heading); |
|
359 | + $heading = $this->render((string) $this->heading); |
|
360 | 360 | |
361 | 361 | if (!$heading) { |
362 | 362 | $heading = $this->translator()->translation('{{ objType }} #{{ id }}', [ |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | public function preview() |
400 | 400 | { |
401 | 401 | if ($this->preview) { |
402 | - return $this->render((string)$this->preview); |
|
402 | + return $this->render((string) $this->preview); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | return ''; |
@@ -927,19 +927,19 @@ discard block |
||
927 | 927 | static $search; |
928 | 928 | |
929 | 929 | if ($search === null) { |
930 | - $attr = [ 'href', 'link', 'url', 'src' ]; |
|
931 | - $scheme = [ '../', './', '/', 'data', 'mailto', 'http' ]; |
|
930 | + $attr = ['href', 'link', 'url', 'src']; |
|
931 | + $scheme = ['../', './', '/', 'data', 'mailto', 'http']; |
|
932 | 932 | |
933 | 933 | $search = sprintf( |
934 | 934 | '(?<=%1$s=")(?!%2$s)(\S+)(?=")', |
935 | - implode('="|', array_map('preg_quote', $attr, [ '~' ])), |
|
936 | - implode('|', array_map('preg_quote', $scheme, [ '~' ])) |
|
935 | + implode('="|', array_map('preg_quote', $attr, ['~'])), |
|
936 | + implode('|', array_map('preg_quote', $scheme, ['~'])) |
|
937 | 937 | ); |
938 | 938 | } |
939 | 939 | |
940 | 940 | $text = preg_replace_callback( |
941 | 941 | '~'.$search.'~i', |
942 | - function ($matches) { |
|
942 | + function($matches) { |
|
943 | 943 | return $this->createAbsoluteUrl($matches[1]); |
944 | 944 | }, |
945 | 945 | $text |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | protected function isRelativeUri($uri) |
959 | 959 | { |
960 | 960 | if ($uri && !parse_url($uri, PHP_URL_SCHEME)) { |
961 | - if (!in_array($uri[0], [ '/', '#', '?' ])) { |
|
961 | + if (!in_array($uri[0], ['/', '#', '?'])) { |
|
962 | 962 | return true; |
963 | 963 | } |
964 | 964 | } |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @param string $type The attachment type. |
320 | 320 | * @throws InvalidArgumentException If provided argument is not of type 'string'. |
321 | - * @return string |
|
321 | + * @return Attachment |
|
322 | 322 | */ |
323 | 323 | public function setType($type) |
324 | 324 | { |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | /** |
760 | 760 | * Retrieve the attachment's sub-title. |
761 | 761 | * |
762 | - * @return Translation|string|null |
|
762 | + * @return null|Translation |
|
763 | 763 | */ |
764 | 764 | public function subtitle() |
765 | 765 | { |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | /** |
770 | 770 | * Retrieve attachment's description. |
771 | 771 | * |
772 | - * @return Translation|string|null |
|
772 | + * @return null|Translation |
|
773 | 773 | */ |
774 | 774 | public function description() |
775 | 775 | { |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | /** |
790 | 790 | * Retrieve the path to the thumbnail associated with the object. |
791 | 791 | * |
792 | - * @return string|null |
|
792 | + * @return string |
|
793 | 793 | */ |
794 | 794 | public function thumbnail() |
795 | 795 | { |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | /** |
833 | 833 | * Retrieve the file label. |
834 | 834 | * |
835 | - * @return string|null |
|
835 | + * @return null|Translation |
|
836 | 836 | */ |
837 | 837 | public function fileLabel() |
838 | 838 | { |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | /** |
843 | 843 | * Retrieve the link label. |
844 | 844 | * |
845 | - * @return string|null |
|
845 | + * @return null|Translation |
|
846 | 846 | */ |
847 | 847 | public function linkLabel() |
848 | 848 | { |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | * Prepend the base URI to the given path. |
977 | 977 | * |
978 | 978 | * @param string $text A string to parse relative URIs. |
979 | - * @return UriInterface|null |
|
979 | + * @return string |
|
980 | 980 | */ |
981 | 981 | protected function resolveUrls($text) |
982 | 982 | { |
@@ -13,7 +13,7 @@ |
||
13 | 13 | /** |
14 | 14 | * Alias of {@see Attachment::file()}. |
15 | 15 | * |
16 | - * @return string|null |
|
16 | + * @return \Psr\Http\Message\UriInterface|null |
|
17 | 17 | */ |
18 | 18 | public function src() |
19 | 19 | { |
@@ -12,7 +12,7 @@ |
||
12 | 12 | /** |
13 | 13 | * Alias of {@see Attachment::thumbnail()} and {@see Attachment::file()}. |
14 | 14 | * |
15 | - * @return string|null |
|
15 | + * @return \Psr\Http\Message\UriInterface|null |
|
16 | 16 | */ |
17 | 17 | public function src() |
18 | 18 | { |
@@ -471,7 +471,7 @@ |
||
471 | 471 | /** |
472 | 472 | * Retrieve the relationship's group ID. |
473 | 473 | * |
474 | - * @return mixed |
|
474 | + * @return string |
|
475 | 475 | */ |
476 | 476 | public function group() |
477 | 477 | { |
@@ -402,7 +402,7 @@ |
||
402 | 402 | ); |
403 | 403 | } |
404 | 404 | |
405 | - $this->position = (int)$position; |
|
405 | + $this->position = (int) $position; |
|
406 | 406 | |
407 | 407 | return $this; |
408 | 408 | } |
@@ -293,7 +293,7 @@ |
||
293 | 293 | * Set the attachment widget. |
294 | 294 | * |
295 | 295 | * @param AttachmentWidget $widget The widget displaying attachments. |
296 | - * @return string |
|
296 | + * @return AttachmentAwareTrait |
|
297 | 297 | */ |
298 | 298 | protected function setAttachmentWidget(AttachmentWidget $widget) |
299 | 299 | { |
@@ -13,8 +13,6 @@ |
||
13 | 13 | |
14 | 14 | // From 'locomotivemtl/charcoal-attachments' |
15 | 15 | use Charcoal\Attachment\Interfaces\AttachableInterface; |
16 | -use Charcoal\Attachment\Interfaces\AttachmentContainerInterface; |
|
17 | - |
|
18 | 16 | use Charcoal\Attachment\Object\Join; |
19 | 17 | use Charcoal\Attachment\Object\Attachment; |
20 | 18 |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $this->logger->warning( |
81 | 81 | 'AttachmentAwareTrait::attachments() parameters are deprecated. '. |
82 | 82 | 'An array of parameters should be used.', |
83 | - [ 'package' => 'locomotivemtl/charcoal-attachment' ] |
|
83 | + ['package' => 'locomotivemtl/charcoal-attachment'] |
|
84 | 84 | ); |
85 | 85 | } |
86 | 86 | $options = [ |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $loader->setDynamicTypeField('type'); |
182 | 182 | |
183 | 183 | if ($widget instanceof AttachmentWidget) { |
184 | - $callable = function (&$att) use ($widget, $before) { |
|
184 | + $callable = function(&$att) use ($widget, $before) { |
|
185 | 185 | if ($this instanceof AttachableInterface) { |
186 | 186 | $att->setContainerObj($this); |
187 | 187 | } |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | $att->isPresentable(true); |
209 | 209 | |
210 | 210 | if ($before !== null) { |
211 | - call_user_func_array($before, [ &$att ]); |
|
211 | + call_user_func_array($before, [&$att]); |
|
212 | 212 | } |
213 | 213 | }; |
214 | 214 | } else { |
215 | - $callable = function (&$att) use ($before) { |
|
215 | + $callable = function(&$att) use ($before) { |
|
216 | 216 | if ($this instanceof AttachableInterface) { |
217 | 217 | $att->setContainerObj($this); |
218 | 218 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $att->isPresentable(true); |
221 | 221 | |
222 | 222 | if ($before !== null) { |
223 | - call_user_func_array($before, [ &$att ]); |
|
223 | + call_user_func_array($before, [&$att]); |
|
224 | 224 | } |
225 | 225 | }; |
226 | 226 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $this->logger->warning( |
295 | 295 | 'AttachmentAwareTrait::removeJoins() is deprecated. '. |
296 | 296 | 'Use AttachmentAwareTrait::removeAttachmentJoins() instead.', |
297 | - [ 'package' => 'locomotivemtl/charcoal-attachment' ] |
|
297 | + ['package' => 'locomotivemtl/charcoal-attachment'] |
|
298 | 298 | ); |
299 | 299 | |
300 | 300 | return $this->removeAttachmentJoins(); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $defaults = $this->getDefaultAttachmentOptions(); |
423 | 423 | |
424 | 424 | $options = array_intersect_key($options, $defaults); |
425 | - $options = array_filter($options, [ $this, 'filterAttachmentOption' ], ARRAY_FILTER_USE_BOTH); |
|
425 | + $options = array_filter($options, [$this, 'filterAttachmentOption'], ARRAY_FILTER_USE_BOTH); |
|
426 | 426 | $options = array_replace($defaults, $options); |
427 | 427 | |
428 | 428 | return $options; |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * |
36 | 36 | * @param ConfigInterface|array $config The datas to set. |
37 | 37 | * @throws InvalidArgumentException If the parameter is invalid. |
38 | - * @return ConfigurableInterface Chainable |
|
38 | + * @return ConfigurableAttachmentsTrait Chainable |
|
39 | 39 | */ |
40 | 40 | public function setConfig($config) |
41 | 41 | { |
@@ -69,7 +69,7 @@ |
||
69 | 69 | $pivot = $this->modelFactory()->create(Join::class); |
70 | 70 | |
71 | 71 | if (is_string($data) && strpos($data, '_') > 1) { |
72 | - $data = array_combine([ 'obj_type', 'obj_id' ], explode('_', $data, 1)); |
|
72 | + $data = array_combine(['obj_type', 'obj_id'], explode('_', $data, 1)); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if (is_scalar($data)) { |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | ]); |
257 | 257 | $rows = $source->dbQuery( |
258 | 258 | strtr($sql, $binds), |
259 | - [ 'objType' => $row['object_type'] ] |
|
259 | + ['objType' => $row['object_type']] |
|
260 | 260 | ); |
261 | 261 | |
262 | 262 | /** @todo Show found rows, confirm deletion of dead relationships */ |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $sql = 'SELECT p.* FROM `%pivotTable` AS p WHERE p.`%sourceType` = :objType;'; |
277 | 277 | $rows = $source->dbQuery( |
278 | 278 | strtr($sql, $defaultBinds), |
279 | - [ 'objType' => $model ] |
|
279 | + ['objType' => $model] |
|
280 | 280 | ); |
281 | 281 | |
282 | 282 | /** @todo Explain missing model, confirm deletion of dead relationships */ |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | ]; |
395 | 395 | |
396 | 396 | if ($ask && $verb) { |
397 | - $dead = array_merge([ 'Deleted' => null, 'Failed' => null ], $dead); |
|
397 | + $dead = array_merge(['Deleted' => null, 'Failed' => null], $dead); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | $cli = $this->climate(); |
618 | 618 | |
619 | 619 | if (is_string($this->action)) { |
620 | - $opts = [ 'y', 'n', 'r', 'q', '?' ]; |
|
620 | + $opts = ['y', 'n', 'r', 'q', '?']; |
|
621 | 621 | $help = [ |
622 | 622 | '[y]es — delete the attachment', |
623 | 623 | '[n]o — don’t delete the attachment', |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | '[q]uit — exit immediately (does not undo previous actions)', |
626 | 626 | ]; |
627 | 627 | } else { |
628 | - $opts = [ 'y', 'a', 'n', 's', 'q', '?' ]; |
|
628 | + $opts = ['y', 'a', 'n', 's', 'q', '?']; |
|
629 | 629 | $help = [ |
630 | 630 | '[y]es — delete this attachment', |
631 | 631 | '[a]ll — delete all attachments', |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | { |
687 | 687 | $cli = $this->climate(); |
688 | 688 | |
689 | - $opts = [ 'y', 'n', 'v', '?' ]; |
|
689 | + $opts = ['y', 'n', 'v', '?']; |
|
690 | 690 | $help = [ |
691 | 691 | '[y]es — continue to deletion phase', |
692 | 692 | '[n]o — cancel deletion phase', |