diff --git a/.github/workflows/diagnostics.yml b/.github/workflows/diagnostics.yml index a2a228e..b0c2716 100644 --- a/.github/workflows/diagnostics.yml +++ b/.github/workflows/diagnostics.yml @@ -28,6 +28,10 @@ jobs: output: '-o default' phpcq_install: 'update' contao: '~4.13.0' + - php: '8.2' + output: '-o default' + phpcq_install: 'update' + contao: '~4.13.0' steps: - name: Pull source diff --git a/.phpcq.lock b/.phpcq.lock index bc094d8..1d4cf0f 100644 --- a/.phpcq.lock +++ b/.phpcq.lock @@ -1 +1 @@ -{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.5.24","url":"https://phar.phpunit.de/phpunit-9.5.24.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"c6ea563d53fb64192d163c11fa7dd25fbca2ba638873138710451f58304289fc"},"signature":"https://phar.phpunit.de/phpunit-9.5.24.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/psalm-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"4.27.0","url":"https://github.com/vimeo/psalm/releases/download/4.27.0/psalm.phar","requirements":{"php":{"php":"^7.1|^8","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/4.27.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"3.8.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/3.8.0/composer-require-checker.phar","requirements":{"php":{"php":"^7.4 || ^8.0","ext-json":"*","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/3.8.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.13.0","url":"https://github.com/phpmd/phpmd/releases/download/2.13.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.13.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phpcs-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.7.1","url":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-tokenizer":"*","ext-xmlwriter":"*","ext-simplexml":"*"}},"checksum":null,"signature":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.1/phpcs.phar.asc"},"phpcbf":{"version":"3.7.1","url":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-tokenizer":"*","ext-xmlwriter":"*","ext-simplexml":"*"}},"checksum":null,"signature":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.28.3","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.28.3/composer-normalize.phar","requirements":{"php":{"php":"^7.4 || ^8.0"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.28.3/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.19","url":"https://phar.phpunit.de/phpunit-9.6.19.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"f30c21743f4fbea14ad8ab8f47673f9067117262dafa147fcb182e75fbc1c249"},"signature":"https://phar.phpunit.de/phpunit-9.6.19.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.23.1","url":"https://github.com/vimeo/psalm/releases/download/5.23.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.23.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"3.8.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/3.8.0/composer-require-checker.phar","requirements":{"php":{"php":"^7.4 || ^8.0","ext-json":"*","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/3.8.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.9.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.2/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.2/phpcs.phar.asc"},"phpcbf":{"version":"3.9.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.2/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.9.2/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.42.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist index e761294..fdf6e09 100644 --- a/.phpcq.yaml.dist +++ b/.phpcq.yaml.dist @@ -51,11 +51,13 @@ phpcq: - D2CCAC42F6295E7D # PHP_CodeSniffer - 31C7E470E2138192 + - 5E6DDE998AB73B8E # Composer normalize - C00543248C87FB13 # phpmd - 0F9684B8B16B7AB0 - A4E55EA12C7C085C + - 9093F8B32E4815AA # composer-require-checker - 033E5F8D801A2F8D diff --git a/composer.json b/composer.json index 3825b03..8b6766e 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "phpcq/runner-bootstrap": "^1.0@dev" }, "conflict": { - "contao-community-alliance/event-dispatcher": "<2.0,>=3.0" + "contao-community-alliance/event-dispatcher": "<2.0 >=3.0" }, "autoload": { "psr-4": { @@ -63,7 +63,8 @@ "config": { "allow-plugins": { "contao-components/installer": false, - "contao/manager-plugin": false + "contao/manager-plugin": false, + "php-http/discovery": true } }, "extra": { diff --git a/src/Events/Controller/AddImageToTemplateEvent.php b/src/Events/Controller/AddImageToTemplateEvent.php index 6e13b8b..5eb0eb1 100644 --- a/src/Events/Controller/AddImageToTemplateEvent.php +++ b/src/Events/Controller/AddImageToTemplateEvent.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/events-contao-bindings * - * (c) 2014-2018 The Contao Community Alliance + * (c) 2014-2024 The Contao Community Alliance * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +15,8 @@ * @author Christian Schiffler * @author Tristan Lins * @author Sven Baumann - * @copyright 2018 The Contao Community Alliance. + * @author Ingolf Steinhardt + * @copyright 2014-2024 The Contao Community Alliance. * @license https://github.com/contao-community-alliance/events-contao-bindings/blob/master/LICENSE LGPL-3.0 * @filesource */ @@ -72,8 +73,8 @@ public function __construct(array $imageData, $template, ?int $maxWidth = null, { $this->imageData = $imageData; $this->template = $template; - $this->maxWidth = empty($maxWidth) ? null : $maxWidth; - $this->lightboxId = empty($lightboxId) ? null : $lightboxId; + $this->maxWidth = (0 === $maxWidth) ? null : $maxWidth; + $this->lightboxId = ('' === $lightboxId) ? null : $lightboxId; } /** diff --git a/src/Events/Controller/GenerateFrontendUrlEvent.php b/src/Events/Controller/GenerateFrontendUrlEvent.php index 51a4156..85935e7 100644 --- a/src/Events/Controller/GenerateFrontendUrlEvent.php +++ b/src/Events/Controller/GenerateFrontendUrlEvent.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/events-contao-bindings * - * (c) 2014-2018 The Contao Community Alliance + * (c) 2014-2024 The Contao Community Alliance * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +15,8 @@ * @author Christian Schiffler * @author Tristan Lins * @author Sven Baumann - * @copyright 2018 The Contao Community Alliance. + * @author Ingolf Steinhardt + * @copyright 2014-2024 The Contao Community Alliance. * @license https://github.com/contao-community-alliance/events-contao-bindings/blob/master/LICENSE LGPL-3.0 * @filesource */ @@ -70,12 +71,9 @@ class GenerateFrontendUrlEvent extends ContaoApiEvent * Create a new instance. * * @param array $pageData The data for the page. - * - * @param string|null $parameters The parameters to use in the url. - * + * @param string|null $parameters The parameters to use in the url. * @param string|null $language The language code to use in the url. * This parameter will get dropped in Contao 5.0 (and thus then always be null). - * * @param bool $fixDomain Check the domain of the target page and append it if necessary. * This parameter will get dropped for Contao 5.0 (and thus then always be true). */ @@ -86,8 +84,8 @@ public function __construct( bool $fixDomain = false ) { $this->pageData = $pageData; - $this->parameters = empty($parameters) ? null : $parameters; - $this->language = empty($language) ? null : $language; + $this->parameters = ('' === $parameters) ? null : $parameters; + $this->language = ('' === $language) ? null : $language; $this->fixDomain = $fixDomain; $this->url = ''; } diff --git a/src/Subscribers/CalendarSubscriber.php b/src/Subscribers/CalendarSubscriber.php index 196348e..dd2c34a 100644 --- a/src/Subscribers/CalendarSubscriber.php +++ b/src/Subscribers/CalendarSubscriber.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/events-contao-bindings * - * (c) 2014-2018 The Contao Community Alliance + * (c) 2014-2024 The Contao Community Alliance * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +15,8 @@ * @author Christian Schiffler * @author Tristan Lins * @author Sven Baumann - * @copyright 2018 The Contao Community Alliance. + * @author Ingolf Steinhardt + * @copyright 2014-2024 The Contao Community Alliance. * @license https://github.com/contao-community-alliance/events-contao-bindings/blob/master/LICENSE LGPL-3.0 * @filesource */ @@ -78,9 +79,7 @@ public static function getSubscribedEvents(): array * Render a calendar event. * * @param GetCalendarEventEvent $event The event. - * * @param string $eventName The event name. - * * @param EventDispatcherInterface $eventDispatcher The event dispatcher. * * @return void @@ -102,7 +101,7 @@ public function handleEvent( string $eventName, EventDispatcherInterface $eventDispatcher ): void { - if ($event->getCalendarEventHtml()) { + if (null === $event->getCalendarEventHtml()) { return; } @@ -173,7 +172,7 @@ public function handleEvent( $span = $calendarAdapter->calculateSpan($intStartTime, $intEndTime); // Do not show dates in the past if the event is recurring (see #923). - if ($eventModel->recurring) { + if ((bool) $eventModel->recurring) { /** * @var StringUtil $stringUtilAdapter * @psalm-suppress InternalMethod - getAdapter is the official way and NOT internal. @@ -208,28 +207,29 @@ public function handleEvent( $dateAdapter = $this->framework->getAdapter(Date::class); // Get date. + $addTime = (bool) $eventModel->addTime; if ($span > 0) { $date = $strTimeStart . $dateAdapter->parse( - ($eventModel->addTime ? $objPage->datimFormat : $objPage->dateFormat), + ($addTime ? $objPage->datimFormat : $objPage->dateFormat), $intStartTime ) . $strTimeClose . ' - ' . $strTimeEnd . $dateAdapter->parse( - ($eventModel->addTime ? $objPage->datimFormat : $objPage->dateFormat), + ($addTime ? $objPage->datimFormat : $objPage->dateFormat), $intEndTime ) . $strTimeClose; } elseif ($intStartTime == $intEndTime) { $date = $strTimeStart . $dateAdapter->parse($objPage->dateFormat, $intStartTime) . - ($eventModel->addTime ? ' (' . $dateAdapter->parse($objPage->timeFormat, $intStartTime) . ')' : '') . + ($addTime ? ' (' . $dateAdapter->parse($objPage->timeFormat, $intStartTime) . ')' : '') . $strTimeClose; } else { $date = $strTimeStart . $dateAdapter->parse($objPage->dateFormat, $intStartTime) . ( - $eventModel->addTime ? ' (' . $dateAdapter->parse($objPage->timeFormat, $intStartTime) . + $addTime ? ' (' . $dateAdapter->parse($objPage->timeFormat, $intStartTime) . $strTimeClose . ' - ' . $strTimeEnd . $dateAdapter->parse($objPage->timeFormat, $intEndTime) . ')' : '' ) . @@ -240,7 +240,7 @@ public function handleEvent( $recurring = ''; // Recurring event. - if ($eventModel->recurring) { + if ((bool) $eventModel->recurring) { /** * @var StringUtil $stringUtilAdapter * @psalm-suppress InternalMethod - getAdapter is the official way and NOT internal. @@ -320,7 +320,7 @@ public function handleEvent( $filesModelAdapter = $this->framework->getAdapter(FilesModel::class); // Add an image. - if ($eventModel->addImage && !empty($eventModel->singleSRC)) { + if ((bool) $eventModel->addImage && null !== $eventModel->singleSRC) { $objModel = $filesModelAdapter->findByUuid($eventModel->singleSRC); if ($objModel === null) { @@ -350,10 +350,10 @@ public function handleEvent( $objTemplate->enclosure = []; // Add enclosures. - if ($eventModel->addEnclosure) { - $eclosureEvent = new AddEnclosureToTemplateEvent($eventModel->row(), $objTemplate); + if ((bool) $eventModel->addEnclosure) { + $enclosureEvent = new AddEnclosureToTemplateEvent($eventModel->row(), $objTemplate); - $eventDispatcher->dispatch($eclosureEvent, ContaoEvents::CONTROLLER_ADD_ENCLOSURE_TO_TEMPLATE); + $eventDispatcher->dispatch($enclosureEvent, ContaoEvents::CONTROLLER_ADD_ENCLOSURE_TO_TEMPLATE); } $calendarEvent = $objTemplate->parse(); diff --git a/src/Subscribers/NewsSubscriber.php b/src/Subscribers/NewsSubscriber.php index 00d0ab5..45f5639 100644 --- a/src/Subscribers/NewsSubscriber.php +++ b/src/Subscribers/NewsSubscriber.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/events-contao-bindings * - * (c) 2014-2018 The Contao Community Alliance + * (c) 2014-2024 The Contao Community Alliance * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,7 +15,8 @@ * @author Christian Schiffler * @author Tristan Lins * @author Sven Baumann - * @copyright 2018 The Contao Community Alliance. + * @author Ingolf Steinhardt + * @copyright 2014-2024 The Contao Community Alliance. * @license https://github.com/contao-community-alliance/events-contao-bindings/blob/master/LICENSE LGPL-3.0 * @filesource */ @@ -83,9 +84,7 @@ public static function getSubscribedEvents(): array * Render a news. * * @param GetNewsEvent $event The event. - * * @param string $eventName The event name. - * * @param EventDispatcherInterface $eventDispatcher The event dispatcher. * * @return void @@ -104,7 +103,7 @@ public static function getSubscribedEvents(): array */ public function handleNews(GetNewsEvent $event, string $eventName, EventDispatcherInterface $eventDispatcher): void { - if ($event->getNewsHtml()) { + if (null === $event->getNewsHtml()) { return; } @@ -153,7 +152,7 @@ public function handleNews(GetNewsEvent $event, string $eventName, EventDispatch $objTemplate->text = ''; - if (!empty($newsModel->teaser)) { + if (null !== $newsModel->teaser) { // Clean the RTE output. /** * @var StringUtil $stringUtilAdapter @@ -204,7 +203,7 @@ public function handleNews(GetNewsEvent $event, string $eventName, EventDispatch $objTemplate->addImage = false; // Add an image. - if ($newsModel->addImage && !empty($newsModel->singleSRC)) { + if ((bool) $newsModel->addImage && null !== $newsModel->singleSRC) { /** * @var FilesModel $filesModelAdapter * @psalm-suppress InternalMethod - getAdapter is the official way and NOT internal. @@ -258,7 +257,7 @@ public function handleNews(GetNewsEvent $event, string $eventName, EventDispatch $objTemplate->enclosure = []; // Add enclosures. - if ($newsModel->addEnclosure) { + if ((bool) $newsModel->addEnclosure) { $enclosureEvent = new AddEnclosureToTemplateEvent($newsModel->row(), $objTemplate); $eventDispatcher->dispatch($enclosureEvent, ContaoEvents::CONTROLLER_ADD_ENCLOSURE_TO_TEMPLATE); @@ -327,7 +326,7 @@ protected function getMetaFields(NewsModel $objArticle): array break; case 'comments': - if ($objArticle->noComments || $objArticle->source !== 'default') { + if ((bool) $objArticle->noComments || $objArticle->source !== 'default') { break; } @@ -356,9 +355,7 @@ protected function getMetaFields(NewsModel $objArticle): array * Generate a URL and return it as string. * * @param EventDispatcherInterface $eventDispatcher The event dispatcher. - * * @param NewsModel $objItem The news model. - * * @param boolean $blnAddArchive Add the current archive parameter (news archive) (default: false). * * @return string @@ -368,6 +365,7 @@ protected function getMetaFields(NewsModel $objArticle): array * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.CamelCaseVariableName) * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * * @psalm-suppress MixedArrayAccess - The global access can not be typed. */ @@ -464,7 +462,8 @@ protected function generateNewsUrl( // Add the current archive parameter (news archive). if ($blnAddArchive && !empty($inputAdapter->get('month'))) { - $url .= ($GLOBALS['TL_CONFIG']['disableAlias'] ? '&' : '?') . 'month=' . (string) $inputAdapter->get('month'); + $url .= ($GLOBALS['TL_CONFIG']['disableAlias'] ? '&' : '?') + . 'month=' . (string) $inputAdapter->get('month'); } } @@ -476,14 +475,10 @@ protected function generateNewsUrl( * Generate a link and return it as string. * * @param EventDispatcherInterface $eventDispatcher The event dispatcher. - * * @param string $strLink The link text. - * * @param NewsModel $objArticle The model. - * * @param bool $blnAddArchive Add the current archive parameter (news archive) * (default: false). - * * @param bool $blnIsReadMore Determine if the link is a "read more" link. * * @return string @@ -533,7 +528,7 @@ protected function generateLink( '%s', $strArticleUrl, $stringUtilAdapter->specialchars(sprintf((string) $GLOBALS['TL_LANG']['MSC']['open'], $strArticleUrl)), - $objArticle->target ? ' target="_blank"' : '', + (bool) $objArticle->target ? ' target="_blank"' : '', $strLink ); } diff --git a/src/Subscribers/WidgetSubscriber.php b/src/Subscribers/WidgetSubscriber.php index c02671b..b6fdba8 100644 --- a/src/Subscribers/WidgetSubscriber.php +++ b/src/Subscribers/WidgetSubscriber.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/events-contao-bindings * - * (c) 2014-2018 The Contao Community Alliance + * (c) 2014-2024 The Contao Community Alliance * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -14,7 +14,8 @@ * @subpackage Subscribers * @author Christian Schiffler * @author Sven Baumann - * @copyright 2018 The Contao Community Alliance. + * @author Ingolf Steinhardt + * @copyright 2014-2024 The Contao Community Alliance. * @license https://github.com/contao-community-alliance/events-contao-bindings/blob/master/LICENSE LGPL-3.0 * @filesource */ @@ -70,16 +71,23 @@ public function handleGetAttributesFromDca(GetAttributesFromDcaEvent $event): vo * @psalm-suppress InternalMethod - getAdapter is the official way and NOT internal. */ $widgetAdapter = $this->framework->getAdapter(Widget::class); - - $event->setResult( - $widgetAdapter->getAttributesFromDca( - $event->getFieldConfiguration(), - $event->getWidgetName(), - $event->getValue(), - $event->getWidgetId(), - $event->getTable(), - $event->getDataContainer() - ) + $result = $widgetAdapter->getAttributesFromDca( + $event->getFieldConfiguration(), + $event->getWidgetName(), + $event->getValue(), + $event->getWidgetId(), + $event->getTable(), + $event->getDataContainer() ); + + // Bugfix: Contao does not validate for label array when determining the description. + if ( + strlen((string) $result['description']) === 1 + && !\is_array($event->getFieldConfiguration()['label'] ?? null) + ) { + $result['description'] = ''; + } + + $event->setResult($result); } }