@@ -86,7 +86,7 @@ |
||
| 86 | 86 | /** |
| 87 | 87 | * Retrieve the renderable object's template identifier. |
| 88 | 88 | * |
| 89 | - * @return mixed |
|
| 89 | + * @return string |
|
| 90 | 90 | */ |
| 91 | 91 | public function templateIdent() |
| 92 | 92 | { |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | if ($property instanceof SelectablePropertyInterface) { |
| 108 | 108 | if ($property->hasChoice($templateIdent)) { |
| 109 | 109 | $choice = $property->choice($templateIdent); |
| 110 | - $keys = [ 'controller', 'template', 'class' ]; |
|
| 110 | + $keys = ['controller', 'template', 'class']; |
|
| 111 | 111 | foreach ($keys as $key) { |
| 112 | 112 | if (isset($choice[$key])) { |
| 113 | 113 | return $choice[$key]; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | public function hasTemplateOptions() |
| 184 | 184 | { |
| 185 | 185 | if ($this->templateOptionsStructure()) { |
| 186 | - return (bool)count( |
|
| 186 | + return (bool) count( |
|
| 187 | 187 | iterator_to_array( |
| 188 | 188 | $this->templateOptionsStructure()->properties() |
| 189 | 189 | ) |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $struct = $property->structureVal($obj[$propertyIdent]); |
| 246 | 246 | |
| 247 | 247 | /** Provide support for dynamically wrapping translation sets. */ |
| 248 | - if (in_array(get_class($struct), [ Model::class, StructureModel::class ])) { |
|
| 248 | + if (in_array(get_class($struct), [Model::class, StructureModel::class])) { |
|
| 249 | 249 | $struct = $this->translateTemplateOptionsModel($struct); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | if ($property instanceof SelectablePropertyInterface) { |
| 291 | 291 | if ($property->hasChoice($val)) { |
| 292 | 292 | $choice = $property->choice($val); |
| 293 | - $keys = [ 'controller', 'template', 'class' ]; |
|
| 293 | + $keys = ['controller', 'template', 'class']; |
|
| 294 | 294 | foreach ($keys as $key) { |
| 295 | 295 | if (isset($choice[$key])) { |
| 296 | 296 | $interface = $choice[$key]; |
@@ -200,7 +200,7 @@ |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $attachmentWidgets = $structureMetadata->get('attachments.widgets'); |
| 203 | - foreach ((array)$attachmentWidgets as $ident => $metadata) { |
|
| 203 | + foreach ((array) $attachmentWidgets as $ident => $metadata) { |
|
| 204 | 204 | $this->addGroup($ident, $metadata); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -238,7 +238,7 @@ |
||
| 238 | 238 | /** |
| 239 | 239 | * Retrieve the form object's template controller identifier. |
| 240 | 240 | * |
| 241 | - * @return mixed |
|
| 241 | + * @return string |
|
| 242 | 242 | */ |
| 243 | 243 | public function controllerIdent() |
| 244 | 244 | { |
@@ -2,13 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Charcoal\Cms\Section; |
| 4 | 4 | |
| 5 | -use RuntimeException; |
|
| 6 | - |
|
| 7 | 5 | // From Pimple |
| 8 | -use Pimple\Container; |
|
| 9 | 6 | |
| 10 | 7 | // From 'charcoal-core' |
| 11 | -use Charcoal\Loader\CollectionLoader; |
|
| 12 | 8 | |
| 13 | 9 | // From 'charcoal-cms' |
| 14 | 10 | use Charcoal\Cms\AbstractSection; |
@@ -7,14 +7,12 @@ |
||
| 7 | 7 | use Pimple\ServiceProviderInterface; |
| 8 | 8 | |
| 9 | 9 | // From 'charcoal-core' |
| 10 | -use Charcoal\Model\AbstractModel; |
|
| 11 | 10 | |
| 12 | 11 | // From 'charcoal-factory' |
| 13 | 12 | use Charcoal\Factory\GenericFactory as Factory; |
| 14 | 13 | |
| 15 | 14 | // From 'charcoal-cms' |
| 16 | 15 | use Charcoal\Cms\SectionInterface; |
| 17 | -use Charcoal\Cms\Config; |
|
| 18 | 16 | use Charcoal\Cms\Config\CmsConfig; |
| 19 | 17 | use Charcoal\Cms\Service\Loader\EventLoader; |
| 20 | 18 | use Charcoal\Cms\Service\Loader\NewsLoader; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param Container $container Pimple DI Container. |
| 61 | 61 | * @return CmsConfig Website configurations (from cms.json). |
| 62 | 62 | */ |
| 63 | - $container['cms/config'] = function (Container $container) { |
|
| 63 | + $container['cms/config'] = function(Container $container) { |
|
| 64 | 64 | $appConfig = $container['config']; |
| 65 | 65 | $cms = $appConfig->get('cms'); |
| 66 | 66 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param Container $container Pimple DI Container. |
| 96 | 96 | * @return DateHelper |
| 97 | 97 | */ |
| 98 | - $container['cms/date/helper'] = function (Container $container) { |
|
| 98 | + $container['cms/date/helper'] = function(Container $container) { |
|
| 99 | 99 | return new DateHelper([ |
| 100 | 100 | 'date_formats' => $container['cms/config']->get('date_formats'), |
| 101 | 101 | 'time_formats' => $container['cms/config']->get('time_formats'), |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @param Container $container Pimple DI Container. |
| 108 | 108 | * @return DateHelper |
| 109 | 109 | */ |
| 110 | - $container['date/helper'] = function (Container $container) { |
|
| 110 | + $container['date/helper'] = function(Container $container) { |
|
| 111 | 111 | trigger_error(sprintf( |
| 112 | 112 | '%s is deprecated, use %s instead', |
| 113 | 113 | '$container[\'date/helper\']', |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param Container $container Pimple DI Container. |
| 129 | 129 | * @return Factory |
| 130 | 130 | */ |
| 131 | - $container['cms/section/factory'] = function (Container $container) { |
|
| 131 | + $container['cms/section/factory'] = function(Container $container) { |
|
| 132 | 132 | return new Factory([ |
| 133 | 133 | 'base_class' => SectionInterface::class, |
| 134 | 134 | 'arguments' => $container['model/factory']->arguments(), |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param Container $container Pimple DI Container. |
| 143 | 143 | * @return SectionLoader |
| 144 | 144 | */ |
| 145 | - $container['cms/section/loader'] = function (Container $container) { |
|
| 145 | + $container['cms/section/loader'] = function(Container $container) { |
|
| 146 | 146 | $sectionLoader = new SectionLoader([ |
| 147 | 147 | 'loader' => $container['model/collection/loader'], |
| 148 | 148 | 'factory' => $container['model/factory'], |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param Container $container Pimple DI Container. |
| 172 | 172 | * @return NewsLoader |
| 173 | 173 | */ |
| 174 | - $container['cms/news/loader'] = function (Container $container) { |
|
| 174 | + $container['cms/news/loader'] = function(Container $container) { |
|
| 175 | 175 | $newsLoader = new NewsLoader([ |
| 176 | 176 | 'loader' => $container['model/collection/loader'], |
| 177 | 177 | 'factory' => $container['model/factory'], |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param Container $container |
| 193 | 193 | * @return NewsManager |
| 194 | 194 | */ |
| 195 | - $container['cms/news/manager'] = function (Container $container) { |
|
| 195 | + $container['cms/news/manager'] = function(Container $container) { |
|
| 196 | 196 | |
| 197 | 197 | $newsManager = new NewsManager([ |
| 198 | 198 | 'loader' => $container['model/collection/loader'], |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param Container $container Pimple DI Container. |
| 218 | 218 | * @return EventLoader |
| 219 | 219 | */ |
| 220 | - $container['cms/event/loader'] = function (Container $container) { |
|
| 220 | + $container['cms/event/loader'] = function(Container $container) { |
|
| 221 | 221 | $eventLoader = new EventLoader([ |
| 222 | 222 | 'loader' => $container['model/collection/loader'], |
| 223 | 223 | 'factory' => $container['model/factory'], |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param Container $container |
| 242 | 242 | * @return EventManager |
| 243 | 243 | */ |
| 244 | - $container['cms/event/manager'] = function (Container $container) { |
|
| 244 | + $container['cms/event/manager'] = function(Container $container) { |
|
| 245 | 245 | |
| 246 | 246 | $eventManager = new EventManager([ |
| 247 | 247 | 'loader' => $container['model/collection/loader'], |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * @param mixed $date The news date to filter |
|
| 90 | + * @param DateTime $date The news date to filter |
|
| 91 | 91 | * [startDate, endDate] |
| 92 | 92 | * DateTimeInterface |
| 93 | 93 | * string. |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * @param mixed $date The news date to filter |
|
| 106 | + * @param DateTime $date The news date to filter |
|
| 107 | 107 | * [startDate, endDate] |
| 108 | 108 | * DateTimeInterface |
| 109 | 109 | * string. |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | - * @return mixed |
|
| 122 | + * @return string |
|
| 123 | 123 | */ |
| 124 | 124 | public function lifespan() |
| 125 | 125 | { |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $now = new DateTime(); |
| 58 | 58 | $loader = $this->all(); |
| 59 | - $loader->addFilter('publishDate', $now->format('Y-m-d H:i:s'), [ 'operator' => '<=' ]) |
|
| 59 | + $loader->addFilter('publishDate', $now->format('Y-m-d H:i:s'), ['operator' => '<=']) |
|
| 60 | 60 | ->addOrder('start_date', 'asc'); |
| 61 | 61 | |
| 62 | 62 | return $loader; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $date = $this->parseAsDate($date); |
| 99 | 99 | $loader = $this->published(); |
| 100 | - $loader->addFilter('end_date', $date->format('Y-m-d H:i:s'), [ 'operator' => '>=' ]); |
|
| 100 | + $loader->addFilter('end_date', $date->format('Y-m-d H:i:s'), ['operator' => '>=']); |
|
| 101 | 101 | |
| 102 | 102 | return $loader; |
| 103 | 103 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | $date = $this->parseAsDate($date); |
| 115 | 115 | $loader = $this->published(); |
| 116 | - $loader->addFilter('end_date', $date->format('Y-m-d H:i:s'), [ 'operator' => '<' ]); |
|
| 116 | + $loader->addFilter('end_date', $date->format('Y-m-d H:i:s'), ['operator' => '<']); |
|
| 117 | 117 | |
| 118 | 118 | return $loader; |
| 119 | 119 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | { |
| 113 | 113 | parent::__construct($data); |
| 114 | 114 | |
| 115 | - if (is_callable([ $this, 'defaultData' ])) { |
|
| 115 | + if (is_callable([$this, 'defaultData'])) { |
|
| 116 | 116 | $this->setData($this->defaultData()); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | */ |
| 366 | 366 | public function setTicketPriceMin($price) |
| 367 | 367 | { |
| 368 | - $this->ticketPriceMin = (float)$price; |
|
| 368 | + $this->ticketPriceMin = (float) $price; |
|
| 369 | 369 | return $this; |
| 370 | 370 | } |
| 371 | 371 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | public function setTicketPriceMax($price) |
| 385 | 385 | { |
| 386 | - $this->ticketPriceMax = (float)$price; |
|
| 386 | + $this->ticketPriceMax = (float) $price; |
|
| 387 | 387 | return $this; |
| 388 | 388 | } |
| 389 | 389 | |
@@ -166,7 +166,7 @@ |
||
| 166 | 166 | /** |
| 167 | 167 | * Retrieve the canonical URI of the object. |
| 168 | 168 | * |
| 169 | - * @return \Psr\Http\Message\UriInterface|string|null |
|
| 169 | + * @return UriInterface|null |
|
| 170 | 170 | */ |
| 171 | 171 | public function canonicalUrl() |
| 172 | 172 | { |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | use Pimple\Container; |
| 13 | 13 | |
| 14 | 14 | // From 'charcoal-core' |
| 15 | -use Charcoal\Model\ModelInterface; |
|
| 16 | 15 | |
| 17 | 16 | // From 'charcoal-translator' |
| 18 | 17 | use Charcoal\Translator\TranslatorAwareTrait; |
@@ -197,11 +197,11 @@ discard block |
||
| 197 | 197 | $title = null; |
| 198 | 198 | |
| 199 | 199 | if ($context instanceof MetatagInterface) { |
| 200 | - $title = (string)$context['metaTitle']; |
|
| 200 | + $title = (string) $context['metaTitle']; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | if (!$title) { |
| 204 | - $title = (string)$this->fallbackMetaTitle(); |
|
| 204 | + $title = (string) $this->fallbackMetaTitle(); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | return $title; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | protected function fallbackMetaTitle() |
| 218 | 218 | { |
| 219 | - return (string)$this->title(); |
|
| 219 | + return (string) $this->title(); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -230,11 +230,11 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $desc = null; |
| 232 | 232 | if ($context instanceof MetatagInterface) { |
| 233 | - $desc = (string)$context['metaDescription']; |
|
| 233 | + $desc = (string) $context['metaDescription']; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | if (!$desc) { |
| 237 | - $desc = (string)$this->fallbackMetaDescription(); |
|
| 237 | + $desc = (string) $this->fallbackMetaDescription(); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | return $desc; |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | $img = null; |
| 265 | 265 | if ($context instanceof MetatagInterface) { |
| 266 | - $img = (string)$context['metaImage']; |
|
| 266 | + $img = (string) $context['metaImage']; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | if (!$img) { |
| 270 | - $img = (string)$this->fallbackMetaImage(); |
|
| 270 | + $img = (string) $this->fallbackMetaImage(); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | return $this->resolveMetaImage($img); |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | $img = null; |
| 344 | 344 | if ($context instanceof MetatagInterface) { |
| 345 | - $img = (string)$context['opengraphImage']; |
|
| 345 | + $img = (string) $context['opengraphImage']; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | if (!$img) { |
| 349 | - $img = (string)$this->fallbackOpengraphImage(); |
|
| 349 | + $img = (string) $this->fallbackOpengraphImage(); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | if ($img) { |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | |
| 413 | 413 | $this->seoMetadata[] = [ |
| 414 | 414 | 'name' => $key, |
| 415 | - 'content' => (string)$value |
|
| 415 | + 'content' => (string) $value |
|
| 416 | 416 | ]; |
| 417 | 417 | } |
| 418 | 418 | |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | } else { |
| 508 | 508 | $parts = parse_url($uri); |
| 509 | 509 | if (!isset($parts['scheme'])) { |
| 510 | - if (!in_array($uri[0], [ '/', '#', '?' ])) { |
|
| 510 | + if (!in_array($uri[0], ['/', '#', '?'])) { |
|
| 511 | 511 | $path = isset($parts['path']) ? $parts['path'] : ''; |
| 512 | 512 | $query = isset($parts['query']) ? $parts['query'] : ''; |
| 513 | 513 | $hash = isset($parts['fragment']) ? $parts['fragment'] : ''; |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | * |
| 59 | 59 | * @param string $className The class name of the section model. |
| 60 | 60 | * @throws InvalidArgumentException If the class name is not a string. |
| 61 | - * @return AbstractPropertyDisplay Chainable |
|
| 61 | + * @return ContextualTemplateTrait Chainable |
|
| 62 | 62 | */ |
| 63 | 63 | public function setGenericContextClass($className) |
| 64 | 64 | { |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * Note: The application's locale is already modified and will be reset |
| 169 | 169 | * after processing all available languages. |
| 170 | 170 | * |
| 171 | - * @param mixed $context The translated {@see \Charcoal\Model\ModelInterface model} |
|
| 171 | + * @param \Charcoal\Model\ModelInterface|null $context The translated {@see \Charcoal\Model\ModelInterface model} |
|
| 172 | 172 | * or array-accessible structure. |
| 173 | 173 | * @param array $localeStruct The currently iterated language. |
| 174 | 174 | * @return array Returns a link structure. |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | /** |
| 214 | 214 | * Yield the alternate translations associated with the current route. |
| 215 | 215 | * |
| 216 | - * @return Generator|null |
|
| 216 | + * @return \Generator |
|
| 217 | 217 | */ |
| 218 | 218 | public function alternateTranslations() |
| 219 | 219 | { |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | protected function formatAlternateTranslation($context, array $localeStruct) |
| 177 | 177 | { |
| 178 | 178 | return [ |
| 179 | - 'id' => ($context['id']) ? : $this->templateName(), |
|
| 180 | - 'title' => ((string)$context['title']) ? : $this->title(), |
|
| 179 | + 'id' => ($context['id']) ?: $this->templateName(), |
|
| 180 | + 'title' => ((string) $context['title']) ?: $this->title(), |
|
| 181 | 181 | 'url' => $this->formatAlternateTranslationUrl($context, $localeStruct), |
| 182 | 182 | 'hreflang' => $localeStruct['code'], |
| 183 | 183 | 'locale' => $localeStruct['locale'], |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | { |
| 202 | 202 | $isRoutable = ($context instanceof RoutableInterface && $context->isActiveRoute()); |
| 203 | 203 | $langCode = $localeStruct['code']; |
| 204 | - $path = ($isRoutable ? $context->url($langCode) : ($this->currentUrl() ? : $langCode)); |
|
| 204 | + $path = ($isRoutable ? $context->url($langCode) : ($this->currentUrl() ?: $langCode)); |
|
| 205 | 205 | |
| 206 | 206 | if ($path instanceof UriInterface) { |
| 207 | 207 | $path = $path->getPath(); |