From 5a2b7f51e4978350bc6ae34e3bf47757a79c1324 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Sat, 20 Nov 2021 12:58:08 +0100 Subject: [PATCH 1/6] Bumping versions of Glide and PHPStan --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index ad2f2c680..727dc7eeb 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "jasny/twig-extensions": "^1.3", "knplabs/doctrine-behaviors": "^2.1", "knplabs/knp-menu-bundle": "^3.1", - "league/glide-symfony": "^1.0", + "league/glide-symfony": "^2.1", "miljar/php-exif": "^0.6.4", "nelexa/zip": "^3.3 || ^4.0", "nelmio/cors-bundle": "^2.1", @@ -103,9 +103,9 @@ "php-translation/loco-adapter": "^0.11", "phpspec/phpspec": "^6.3.1", "phpspec/prophecy": "^1.14", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-doctrine": "^0.12", - "phpstan/phpstan-symfony": "^0.12", + "phpstan/phpstan": "^1.2.0", + "phpstan/phpstan-doctrine": "^1.0.1", + "phpstan/phpstan-symfony": "^1.0.1", "phpunit/phpunit": "^8.5", "se/selenium-server-standalone": "^3.141", "symfony/browser-kit": "^5.3", From 7fd49ef0a6b12b242481e17e111c74255e2bc3aa Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Sat, 20 Nov 2021 13:38:11 +0100 Subject: [PATCH 2/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 727dc7eeb..974839350 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "jasny/twig-extensions": "^1.3", "knplabs/doctrine-behaviors": "^2.1", "knplabs/knp-menu-bundle": "^3.1", - "league/glide-symfony": "^2.1", + "league/glide-symfony": "^1.0.4", "miljar/php-exif": "^0.6.4", "nelexa/zip": "^3.3 || ^4.0", "nelmio/cors-bundle": "^2.1", From 94a2c4150ecee0bb83049c62991a51fd0ab2696f Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Sat, 20 Nov 2021 14:34:39 +0100 Subject: [PATCH 3/6] Working on PHPStan findings --- src/Api/Extensions/ContentExtension.php | 4 ++-- src/Command/CopyAssetsCommand.php | 8 +++----- src/Twig/TextExtension.php | 4 +--- src/Utils/Excerpt.php | 6 +++--- src/Utils/LocaleHelper.php | 2 +- src/Utils/MomentFormatConverter.php | 2 +- src/Widget/BaseWidget.php | 2 +- src/Widget/Injector/HtmlInjector.php | 6 +++--- src/Widget/Injector/RequestZone.php | 2 +- 9 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/Api/Extensions/ContentExtension.php b/src/Api/Extensions/ContentExtension.php index 31b168666..abb51291b 100644 --- a/src/Api/Extensions/ContentExtension.php +++ b/src/Api/Extensions/ContentExtension.php @@ -69,7 +69,7 @@ private function filterUnpublishedViewlessContent(QueryBuilder $queryBuilder): v $queryBuilder->setParameter('status', Statuses::PUBLISHED); //todo: Fix this when https://github.com/doctrine/orm/issues/3835 closed. - if (! empty($this->viewlessContentTypes)) { + if ($this->viewlessContentTypes->isNotEmpty()) { $queryBuilder->andWhere(sprintf('%s.contentType NOT IN (:cts)', $rootAlias)); $queryBuilder->setParameter('cts', $this->viewlessContentTypes); } @@ -82,7 +82,7 @@ private function filterUnpublishedViewlessFields(QueryBuilder $queryBuilder): vo $queryBuilder->setParameter('status', Statuses::PUBLISHED); //todo: Fix this when https://github.com/doctrine/orm/issues/3835 closed. - if (! empty($this->viewlessContentTypes)) { + if ($this->viewlessContentTypes->isNotEmpty()) { $queryBuilder->andWhere('c.contentType NOT IN (:cts)'); $queryBuilder->setParameter('cts', $this->viewlessContentTypes); } diff --git a/src/Command/CopyAssetsCommand.php b/src/Command/CopyAssetsCommand.php index 364f31fc3..698eaf251 100644 --- a/src/Command/CopyAssetsCommand.php +++ b/src/Command/CopyAssetsCommand.php @@ -77,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $this->filesystem->remove($targetDir); $this->hardCopy($originDir, $targetDir); - + dump($originDir, $targetDir); $rows[] = [sprintf('%s', "\xE2\x9C\x94"), $message, 'copied']; } catch (\Throwable $e) { $exitCode = 1; @@ -85,14 +85,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - if (! empty($rows)) { - $io->table(['', 'Folder', 'Method / Error'], $rows); - } + $io->table(['', 'Folder', 'Method / Error'], $rows); if ($exitCode !== 0) { $io->error('Some errors occurred while installing assets.'); } else { - $io->success(! empty($rows) ? 'All assets were successfully installed.' : 'No assets were provided by any bundle.'); + $io->success('All assets were successfully installed.'); } return $exitCode; diff --git a/src/Twig/TextExtension.php b/src/Twig/TextExtension.php index 1f2df8389..830307831 100644 --- a/src/Twig/TextExtension.php +++ b/src/Twig/TextExtension.php @@ -97,9 +97,7 @@ public function urlDecode(string $string) foreach (explode('&', $string) as $chunk) { $param = explode('=', $chunk); - if (! empty($param)) { - $params[urldecode($param[0])] = urldecode($param[1]); - } + $params[urldecode($param[0])] = urldecode($param[1]); } return $params; diff --git a/src/Utils/Excerpt.php b/src/Utils/Excerpt.php index 3d9d9061a..51dc71806 100644 --- a/src/Utils/Excerpt.php +++ b/src/Utils/Excerpt.php @@ -24,7 +24,7 @@ public static function getExcerpt(string $text, int $length = 200, $focus = null * Nothing exciting here. The array_unique is required, unless you decide * to make the words unique before passing in. */ - private static function extractLocations(array $words, string $fulltext): array + protected static function extractLocations(array $words, string $fulltext): array { $locations = []; foreach ($words as $word) { @@ -49,7 +49,7 @@ private static function extractLocations(array $words, string $fulltext): array * The only exception is where we have only two matches in which case we just take the * first as will be equally distant. */ - private static function determineSnipLocation(array $locations, int $prevCount): int + protected static function determineSnipLocation(array $locations, int $prevCount): int { // If we only have 1 match we don't actually do the for loop so set to the first $startPos = (int) reset($locations); @@ -84,7 +84,7 @@ private static function determineSnipLocation(array $locations, int $prevCount): * * @param string|array $words */ - private static function extractRelevant($words, string $fulltext, int $relLength = 300): string + protected static function extractRelevant($words, string $fulltext, int $relLength = 300): string { $fulltext = strip_tags($fulltext); diff --git a/src/Utils/LocaleHelper.php b/src/Utils/LocaleHelper.php index 32d069aed..654d09a76 100644 --- a/src/Utils/LocaleHelper.php +++ b/src/Utils/LocaleHelper.php @@ -56,7 +56,7 @@ public function getCurrentLocale(Environment $twig): ?Collection { // Getting the currentLocale is surprisingly inefficient, so we do it once per Request // See https://github.com/bolt/core/pull/2597 - if (! isset($this->currentLocale)) { + if (! $this->currentLocale instanceof Collection) { $this->currentLocale = $this->getLocales($twig)->firstWhere('current', true); } diff --git a/src/Utils/MomentFormatConverter.php b/src/Utils/MomentFormatConverter.php index 7336b1fc4..1a6f0dbba 100644 --- a/src/Utils/MomentFormatConverter.php +++ b/src/Utils/MomentFormatConverter.php @@ -18,7 +18,7 @@ class MomentFormatConverter * * @var array */ - private static $formatConvertRules = [ + protected static $formatConvertRules = [ // year 'yyyy' => 'YYYY', 'yy' => 'YY', diff --git a/src/Widget/BaseWidget.php b/src/Widget/BaseWidget.php index acd9303c7..7d87a6df6 100644 --- a/src/Widget/BaseWidget.php +++ b/src/Widget/BaseWidget.php @@ -82,7 +82,7 @@ public function getTargets(): array } /** - * @var string[] + * @param string[] $targets */ public function setTargets(array $targets): WidgetInterface { diff --git a/src/Widget/Injector/HtmlInjector.php b/src/Widget/Injector/HtmlInjector.php index 6c7201246..5468b96eb 100644 --- a/src/Widget/Injector/HtmlInjector.php +++ b/src/Widget/Injector/HtmlInjector.php @@ -80,7 +80,7 @@ public function inject(WidgetInterface $widget, Response $response): void $snippet = $widget() . "\n"; // If the widget doesn't produce output, there's no need to inject it. - if (empty($snippet)) { + if (mb_strlen($snippet) > 0) { return; } @@ -240,7 +240,7 @@ protected function jsTagsAfter(string $snippet, string $rawHtml): string return $result; } - private static function findTagStart(string $rawHtml, string $htmlTag): ?string + protected static function findTagStart(string $rawHtml, string $htmlTag): ?string { preg_match('~(<' . $htmlTag . '[^>]*?>)~mi', $rawHtml, $matches); @@ -251,7 +251,7 @@ private static function findTagStart(string $rawHtml, string $htmlTag): ?string return $matches[1]; } - private static function findTagEnd(string $rawHtml, string $htmlTag): ?string + protected static function findTagEnd(string $rawHtml, string $htmlTag): ?string { preg_match_all('~((<' . $htmlTag . '(\s[^>]*)?>)|())~mi', $rawHtml, $allMatches); diff --git a/src/Widget/Injector/RequestZone.php b/src/Widget/Injector/RequestZone.php index 858c8e656..c3a932144 100644 --- a/src/Widget/Injector/RequestZone.php +++ b/src/Widget/Injector/RequestZone.php @@ -12,7 +12,7 @@ */ class RequestZone { - private const KEY = 'zone'; + protected const KEY = 'zone'; public const FRONTEND = 'frontend'; public const BACKEND = 'backend'; From c4e165b5e6aaa019717f219318b5ac6fcba78f98 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Mon, 22 Nov 2021 17:27:31 +0100 Subject: [PATCH 4/6] Working on PHPStan findings --- composer.json | 2 +- phpstan.neon | 7 ++++++- src/Command/CopyAssetsCommand.php | 1 - src/Configuration/Content/FieldType.php | 2 +- src/DataFixtures/ContentFixtures.php | 2 +- src/Doctrine/TablePrefixTrait.php | 2 +- src/Entity/Content.php | 3 +-- src/Entity/Field/CollectionField.php | 2 +- src/Entity/Relation.php | 2 +- src/Event/Listener/ContentFillListener.php | 4 ++-- src/Log/RequestProcessor.php | 2 +- src/Security/LogoutListener.php | 6 +----- src/Twig/FieldExtension.php | 6 ++++-- 13 files changed, 21 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 974839350..6e9c121a2 100644 --- a/composer.json +++ b/composer.json @@ -104,7 +104,7 @@ "phpspec/phpspec": "^6.3.1", "phpspec/prophecy": "^1.14", "phpstan/phpstan": "^1.2.0", - "phpstan/phpstan-doctrine": "^1.0.1", + "phpstan/phpstan-doctrine": "^1.0", "phpstan/phpstan-symfony": "^1.0.1", "phpunit/phpunit": "^8.5", "se/selenium-server-standalone": "^3.141", diff --git a/phpstan.neon b/phpstan.neon index d40e0dbc7..ba94bce5c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -33,7 +33,7 @@ parameters: # false positive: An item to the Logger's Record added by us isn't recognized - - message: "#Offset 'location' does not exist on array#" + message: "#Offset '.*' ([a-z ]*)on array#" path: %currentWorkingDirectory%/src/Log/LogHandler.php # false positive: UserPasswordHasherInterface::isPasswordValid() given UserInterface @@ -41,6 +41,11 @@ parameters: message: '#UserPasswordHasherInterface::isPasswordValid\(\)#' path: %currentWorkingDirectory%/src/Security/LoginFormAuthenticator.php + # False positive: `id` on Entities + - + message: '#Property Bolt\\Entity\\(.*)::\$id is never written, only read#' + path: %currentWorkingDirectory%/src/Entity/* + includes: - vendor/phpstan/phpstan-symfony/extension.neon - vendor/phpstan/phpstan-doctrine/extension.neon diff --git a/src/Command/CopyAssetsCommand.php b/src/Command/CopyAssetsCommand.php index 698eaf251..ddfefe225 100644 --- a/src/Command/CopyAssetsCommand.php +++ b/src/Command/CopyAssetsCommand.php @@ -77,7 +77,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $this->filesystem->remove($targetDir); $this->hardCopy($originDir, $targetDir); - dump($originDir, $targetDir); $rows[] = [sprintf('%s', "\xE2\x9C\x94"), $message, 'copied']; } catch (\Throwable $e) { $exitCode = 1; diff --git a/src/Configuration/Content/FieldType.php b/src/Configuration/Content/FieldType.php index f543ee3ba..f8b856152 100644 --- a/src/Configuration/Content/FieldType.php +++ b/src/Configuration/Content/FieldType.php @@ -22,7 +22,7 @@ public function __construct($items, ?string $slug = null) ); } - private static function defaults(): Collection + protected static function defaults(): Collection { return new Collection([ 'slug' => '', diff --git a/src/DataFixtures/ContentFixtures.php b/src/DataFixtures/ContentFixtures.php index e5eff73e5..f05936640 100644 --- a/src/DataFixtures/ContentFixtures.php +++ b/src/DataFixtures/ContentFixtures.php @@ -247,7 +247,7 @@ function ($match) { try { return $this->faker->{$match}; - } catch (\Throwable $e) { + } finally { } return '(unknown)'; diff --git a/src/Doctrine/TablePrefixTrait.php b/src/Doctrine/TablePrefixTrait.php index d4966a75a..ae49fb4c2 100644 --- a/src/Doctrine/TablePrefixTrait.php +++ b/src/Doctrine/TablePrefixTrait.php @@ -54,6 +54,6 @@ protected function setTablePrefixes($tablePrefixes, ManagerRegistry $managerRegi */ protected function getTablePrefix(): string { - return current($this->tablePrefixes) ?? ''; + return current($this->tablePrefixes); } } diff --git a/src/Entity/Content.php b/src/Entity/Content.php index 5ed36877d..d775d77eb 100644 --- a/src/Entity/Content.php +++ b/src/Entity/Content.php @@ -246,7 +246,6 @@ public function getSlug($locale = null): ?string return (string) $this->getId(); } - $slug = null; if ($locale === null) { // get slug with locale the slug already has $slug = $this->getFieldValue('slug'); @@ -263,7 +262,7 @@ public function getSlug($locale = null): ?string } // if no slug exists for the current/requested locale, default fallback - if (! $slug && $this->hasField('slug')) { + if ($slug === '') { $field = $this->getField('slug'); // @todo: Refactor this. Field.php should be able to get locale diff --git a/src/Entity/Field/CollectionField.php b/src/Entity/Field/CollectionField.php index 7c0ff9e56..ca2a5f6ac 100644 --- a/src/Entity/Field/CollectionField.php +++ b/src/Entity/Field/CollectionField.php @@ -56,7 +56,7 @@ public function getApiValue() } /** - * @var FieldInterface[] + * @param FieldInterface[] $fields */ public function setValue($fields): Field { diff --git a/src/Entity/Relation.php b/src/Entity/Relation.php index 37972790e..668ff733a 100644 --- a/src/Entity/Relation.php +++ b/src/Entity/Relation.php @@ -116,7 +116,7 @@ public function setToContent($content): void public function getDefinition(): array { - if (empty($this->definition) === true && empty($this->fromContent) === false) { + if (empty($this->definition) && $this->fromContent instanceof Content) { $this->setDefinitionFromContentDefinition(); } diff --git a/src/Event/Listener/ContentFillListener.php b/src/Event/Listener/ContentFillListener.php index 1ca872dec..8a5579c9a 100644 --- a/src/Event/Listener/ContentFillListener.php +++ b/src/Event/Listener/ContentFillListener.php @@ -82,7 +82,7 @@ private function guesstimateAuthor(): User return $this->users->getFirstAdminUser(); } - private function guaranteeUniqueSLug(Content $content): void + private function guaranteeUniqueSlug(Content $content): void { $slug = $content->getSlug(); @@ -137,7 +137,7 @@ private function guaranteeUniqueSLug(Content $content): void if (! $safe) { $newSlug = $this->getSafeSlug($slug); $content->setFieldValue('slug', $newSlug); - $this->guaranteeUniqueSLug($content); + $this->guaranteeUniqueSlug($content); } } diff --git a/src/Log/RequestProcessor.php b/src/Log/RequestProcessor.php index 2b2e55df8..fd1e38b41 100644 --- a/src/Log/RequestProcessor.php +++ b/src/Log/RequestProcessor.php @@ -47,7 +47,7 @@ public function processRecord(array $record): array ]; } - if (! empty($user)) { + if ($user instanceof User) { $record['user'] = [ 'id' => $user->getId(), 'username' => $user->getUsername(), diff --git a/src/Security/LogoutListener.php b/src/Security/LogoutListener.php index 24f384a2c..de488d813 100644 --- a/src/Security/LogoutListener.php +++ b/src/Security/LogoutListener.php @@ -18,15 +18,11 @@ class LogoutListener implements LogoutHandlerInterface { use LoggerTrait; - /** @var EntityManagerInterface */ - private $em; - /** @var SessionInterface */ private $session; - public function __construct(EntityManagerInterface $em, SessionInterface $session) + public function __construct(SessionInterface $session) { - $this->em = $em; $this->session = $session; } diff --git a/src/Twig/FieldExtension.php b/src/Twig/FieldExtension.php index 011046be0..fea80b024 100644 --- a/src/Twig/FieldExtension.php +++ b/src/Twig/FieldExtension.php @@ -121,7 +121,9 @@ public function getLabel(Field $field): string public function getType(Field $field): string { - return $field->getType() ?? $field->getDefinition()->get('type'); + // Note, this used to be a ternary, with `?? $field->getDefinition()->get('type');`. I'm not sure + // how/when this would trigger, since $field->getType always returns a value. 🤔💭 + return $field->getType(); } /** @@ -131,7 +133,7 @@ public function getSelected(Field\SelectField $field, $returnsingle = false, $re { $definition = $field->getDefinition(); - if ($definition->get('type') !== 'select' || ! $field->isContentSelect() || ($field->isContentSelect() && $definition->get('mode') === 'format')) { + if ($definition->get('type') !== 'select' || ! $field->isContentSelect() || $definition->get('mode') === 'format') { return $this->notifications->warning( 'Incorrect usage of `selected`-filter', 'The `selected`-filter can only be applied to a field of `type: select`, and it must be used as a selector for other content, and without `mode: format`.' From 1ce79df2e8a32eeb933bb19882e710a54cdf6ec9 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Sun, 28 Nov 2021 15:52:55 +0100 Subject: [PATCH 5/6] Cleaning up code --- phpstan.neon | 5 ----- src/Cache/CachingTrait.php | 4 ++-- src/Security/LoginFormAuthenticator.php | 6 +++--- src/Twig/RelatedExtension.php | 19 ------------------- 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index ba94bce5c..0d9048055 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -36,11 +36,6 @@ parameters: message: "#Offset '.*' ([a-z ]*)on array#" path: %currentWorkingDirectory%/src/Log/LogHandler.php - # false positive: UserPasswordHasherInterface::isPasswordValid() given UserInterface - - - message: '#UserPasswordHasherInterface::isPasswordValid\(\)#' - path: %currentWorkingDirectory%/src/Security/LoginFormAuthenticator.php - # False positive: `id` on Entities - message: '#Property Bolt\\Entity\\(.*)::\$id is never written, only read#' diff --git a/src/Cache/CachingTrait.php b/src/Cache/CachingTrait.php index 1e9fa90f4..3d822755d 100644 --- a/src/Cache/CachingTrait.php +++ b/src/Cache/CachingTrait.php @@ -12,7 +12,7 @@ trait CachingTrait private $cache; /** @var string */ - private $cacheKey; + private $cacheKey = ''; /** @var Config */ private $config; @@ -40,7 +40,7 @@ public function setCacheKey(string $key): void public function getCacheKey(): string { - return $this->cacheKey ?? ''; + return $this->cacheKey; } public function execute(callable $fn, array $params = []) diff --git a/src/Security/LoginFormAuthenticator.php b/src/Security/LoginFormAuthenticator.php index 5870a8ef9..71c5aa7ce 100644 --- a/src/Security/LoginFormAuthenticator.php +++ b/src/Security/LoginFormAuthenticator.php @@ -111,11 +111,11 @@ public function getUser($credentials, UserProviderInterface $userProvider): ?Use return $this->userRepository->findOneByCredentials($credentials['username']); } - /** - * @var PasswordAuthenticatedUserInterface $user - */ public function checkCredentials($credentials, UserInterface $user): bool { + /** + * @var PasswordAuthenticatedUserInterface $user + */ return empty($credentials['password']) ? false : $this->passwordHasher->isPasswordValid($user, $credentials['password']); } diff --git a/src/Twig/RelatedExtension.php b/src/Twig/RelatedExtension.php index 1945805ba..17ffafa41 100644 --- a/src/Twig/RelatedExtension.php +++ b/src/Twig/RelatedExtension.php @@ -8,11 +8,7 @@ use Bolt\Entity\Content; use Bolt\Entity\Relation; use Bolt\Repository\RelationRepository; -use Bolt\Storage\Query; -use Bolt\Utils\ContentHelper; use Bolt\Utils\RelatedOptionsUtility; -use Symfony\Contracts\Cache\ItemInterface; -use Symfony\Contracts\Cache\TagAwareCacheInterface; use Tightenco\Collect\Support\Collection; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; @@ -26,36 +22,21 @@ class RelatedExtension extends AbstractExtension /** @var Config */ private $config; - /** @var Query */ - private $query; - - /** @var ContentHelper */ - private $contentHelper; - /** @var Notifications */ private $notifications; - /** @var TagAwareCacheInterface */ - private $cache; - /** @var RelatedOptionsUtility */ private $optionsUtility; public function __construct( RelationRepository $relationRepository, Config $config, - Query $query, - ContentHelper $contentHelper, Notifications $notifications, - TagAwareCacheInterface $cache, RelatedOptionsUtility $optionsUtility) { $this->relationRepository = $relationRepository; $this->config = $config; - $this->query = $query; - $this->contentHelper = $contentHelper; $this->notifications = $notifications; - $this->cache = $cache; $this->optionsUtility = $optionsUtility; } From bbcab45e873a2c07227c72385fa5b596c6aba309 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Sun, 28 Nov 2021 16:02:21 +0100 Subject: [PATCH 6/6] Fix HtmlInjector --- src/Twig/FieldExtension.php | 2 -- src/Widget/Injector/HtmlInjector.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Twig/FieldExtension.php b/src/Twig/FieldExtension.php index fea80b024..27704c55b 100644 --- a/src/Twig/FieldExtension.php +++ b/src/Twig/FieldExtension.php @@ -121,8 +121,6 @@ public function getLabel(Field $field): string public function getType(Field $field): string { - // Note, this used to be a ternary, with `?? $field->getDefinition()->get('type');`. I'm not sure - // how/when this would trigger, since $field->getType always returns a value. 🤔💭 return $field->getType(); } diff --git a/src/Widget/Injector/HtmlInjector.php b/src/Widget/Injector/HtmlInjector.php index 5468b96eb..a5ca00766 100644 --- a/src/Widget/Injector/HtmlInjector.php +++ b/src/Widget/Injector/HtmlInjector.php @@ -80,7 +80,7 @@ public function inject(WidgetInterface $widget, Response $response): void $snippet = $widget() . "\n"; // If the widget doesn't produce output, there's no need to inject it. - if (mb_strlen($snippet) > 0) { + if (mb_strlen($snippet) === 0) { return; }