diff --git a/src/Frontend/AbstractMapHybrid.php b/src/Frontend/AbstractMapHybrid.php index a69d87f..7344558 100644 --- a/src/Frontend/AbstractMapHybrid.php +++ b/src/Frontend/AbstractMapHybrid.php @@ -9,15 +9,17 @@ * */ +declare(strict_types=1); + namespace Netzmacht\Contao\Leaflet\Frontend; -use ContaoCommunityAlliance\Translator\TranslatorInterface as Translator; use Database\Result; use Model\Collection; use Netzmacht\Contao\Leaflet\MapProvider; use Netzmacht\Contao\Leaflet\Model\MapModel; use Netzmacht\Contao\Toolkit\Component\Hybrid\AbstractHybrid; use Netzmacht\Contao\Toolkit\View\Template\TemplateFactory; +use Symfony\Component\Translation\TranslatorInterface as Translator; /** * Class HybridTrait provides method required by the frontend module and content element the same time. @@ -79,7 +81,7 @@ abstract class AbstractMapHybrid extends AbstractHybrid * * @return string */ - public function generate() + public function generate(): string { $this->mapProvider->handleAjaxRequest($this->getIdentifier()); @@ -113,7 +115,7 @@ abstract class AbstractMapHybrid extends AbstractHybrid * * @SuppressWarnings(PHPMD.Superglobals) */ - protected function compile() + protected function compile(): void { try { $template = $this->get('leaflet_template') ?: 'leaflet_map_js'; @@ -146,5 +148,5 @@ abstract class AbstractMapHybrid extends AbstractHybrid * * @return string */ - abstract protected function getIdentifier(); + abstract protected function getIdentifier(): string; } diff --git a/src/Frontend/InsertTag/LeafletInsertTagParser.php b/src/Frontend/InsertTag/LeafletInsertTagParser.php index fb2c35b..58c53ad 100644 --- a/src/Frontend/InsertTag/LeafletInsertTagParser.php +++ b/src/Frontend/InsertTag/LeafletInsertTagParser.php @@ -9,6 +9,8 @@ * */ +declare(strict_types=1); + namespace Netzmacht\Contao\Leaflet\Frontend\InsertTag; use Netzmacht\Contao\Leaflet\MapProvider; @@ -57,28 +59,20 @@ class LeafletInsertTagParser implements Parser /** * {@inheritDoc} */ - public static function getTags() + public function supports(string $tag): bool { - return ['leaflet']; + return $tag === 'leaflet'; } /** * {@inheritDoc} */ - public function supports($tag) - { - return in_array($tag, static::getTags()); - } - - /** - * {@inheritDoc} - */ - public function parse($raw, $tag, $params = null, $cache = true) + public function parse(string $raw, string $tag, string $params = null, bool $cache = true): string { $parts = explode('::', $params); if (empty($parts[0])) { - return false; + return ''; } $style = empty($parts[1]) ? 'width:400px;height:300px' : $parts[1]; @@ -98,7 +92,7 @@ class LeafletInsertTagParser implements Parser * * @throws \Exception If debug mode is enabled and something went wrong. */ - private function generateMap($mapId, $template, $style) + private function generateMap($mapId, string $template, string $style) { try { return $this->mapProvider->generate($mapId, null, $mapId, $template, $style); diff --git a/src/Frontend/MapElement.php b/src/Frontend/MapElement.php index 0ae08f1..dc1cdb2 100644 --- a/src/Frontend/MapElement.php +++ b/src/Frontend/MapElement.php @@ -9,6 +9,8 @@ * */ +declare(strict_types=1); + namespace Netzmacht\Contao\Leaflet\Frontend; /** @@ -30,7 +32,7 @@ class MapElement extends AbstractMapHybrid * * @return string */ - protected function getIdentifier() + protected function getIdentifier(): string { if ($this->get('leaflet_mapId')) { return $this->get('leaflet_mapId'); diff --git a/src/Frontend/MapModule.php b/src/Frontend/MapModule.php index 3819d8e..13b1431 100644 --- a/src/Frontend/MapModule.php +++ b/src/Frontend/MapModule.php @@ -9,6 +9,8 @@ * */ +declare(strict_types=1); + namespace Netzmacht\Contao\Leaflet\Frontend; /** @@ -30,7 +32,7 @@ class MapModule extends AbstractMapHybrid * * @return string */ - protected function getIdentifier() + protected function getIdentifier(): string { if ($this->get('leaflet_mapId')) { return $this->get('leaflet_mapId');