From f3ff5cbd8ba24efba2b8a480a63167974c65caca Mon Sep 17 00:00:00 2001 From: David Molineus Date: Mon, 19 Feb 2024 15:08:31 +0100 Subject: [PATCH] Fix code style issues after rebasing --- src/Migration/BackboneNavigationMigration.php | 7 +++--- src/QueryBuilder/PageQueryBuilder.php | 24 +++++++++---------- src/Renderer/NavigationRenderer.php | 10 ++++---- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/Migration/BackboneNavigationMigration.php b/src/Migration/BackboneNavigationMigration.php index a5b3985..f71bc45 100644 --- a/src/Migration/BackboneNavigationMigration.php +++ b/src/Migration/BackboneNavigationMigration.php @@ -7,6 +7,7 @@ use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Schema\Column; use function is_int; use function sprintf; @@ -67,7 +68,7 @@ public function run(): MigrationResult $this->renameNavigationModules(); $affectedFields = $this->determineAffectedFields(); - $table = $this->connection->getSchemaManager()->listTableDetails('tl_module'); + $table = $this->connection->createSchemaManager()->introspectTable('tl_module'); foreach ($affectedFields as $oldName => $newName) { $this->renameField($table->getColumn(self::OLD_PREFIX . $oldName), $newName); } @@ -122,8 +123,8 @@ private function renameField(Column $column, string $newName): void sprintf( 'ALTER TABLE tl_module CHANGE %s %s', $column->getName(), - $platform->getColumnDeclarationSQL(self::NEW_PREFIX . $newName, $column->toArray()) - ) + $platform->getColumnDeclarationSQL(self::NEW_PREFIX . $newName, $column->toArray()), + ), ); } } diff --git a/src/QueryBuilder/PageQueryBuilder.php b/src/QueryBuilder/PageQueryBuilder.php index fa0ba0a..894803b 100644 --- a/src/QueryBuilder/PageQueryBuilder.php +++ b/src/QueryBuilder/PageQueryBuilder.php @@ -64,9 +64,9 @@ function (QueryBuilder $queryBuilder): void { $queryBuilder ->select( ...array_map( - fn (string $field) => ($field !== '*') ? $this->connection->quoteIdentifier($field) : $field, - $this->fields - ) + fn (string $field) => $field !== '*' ? $this->connection->quoteIdentifier($field) : $field, + $this->fields, + ), ) ->andWhere('type != :rootType') ->setParameter('rootType', 'root') @@ -105,8 +105,8 @@ function (QueryBuilder $queryBuilder): void { ->select( ...array_map( fn (string $field) => $this->connection->quoteIdentifier($field), - ['id', 'pid', 'protected', 'groups'] - ) + ['id', 'pid', 'protected', 'groups'], + ), ); $this @@ -139,8 +139,8 @@ function (QueryBuilder $queryBuilder): void { $queryBuilder->select( ...array_map( fn (string $field) => $this->connection->quoteIdentifier($field), - ['id', 'pid', 'protected', 'groups'] - ) + ['id', 'pid', 'protected', 'groups'], + ), ); $this @@ -169,8 +169,8 @@ function (QueryBuilder $queryBuilder): void { ->select( ...array_map( fn (string $field) => $this->connection->quoteIdentifier($field), - ['id', 'pid', 'protected', 'groups'] - ) + ['id', 'pid', 'protected', 'groups'], + ), ) ->where('id IN (:ids)'); }, @@ -191,8 +191,8 @@ function (QueryBuilder $queryBuilder): void { ->select( ...array_map( fn (string $field) => $this->connection->quoteIdentifier($field), - $this->fields - ) + $this->fields, + ), ) ->where('id IN (:rootIds)'); }, @@ -215,7 +215,7 @@ static function (QueryBuilder $queryBuilder): void { }, ); - $query->setParameter('ids', $pageIds, Connection::PARAM_STR_ARRAY); + $query->setParameter('ids', $pageIds, ArrayParameterType::STRING); return $query; } diff --git a/src/Renderer/NavigationRenderer.php b/src/Renderer/NavigationRenderer.php index bf11a5f..e2d1ff8 100644 --- a/src/Renderer/NavigationRenderer.php +++ b/src/Renderer/NavigationRenderer.php @@ -146,26 +146,27 @@ private function renderTree( $containsActive = true; if ($item['href'] === Environment::get('request')) { - $item['isActive'] = true; // nothing else (active class is set in template) - $item['isInTrail'] = false; + $item['isActive'] = true; // nothing else (active class is set in template) } else { - $item['isActive'] = false; // nothing else (active class is set in template) $item['isInTrail'] = true; } } else { // do not flatten if/else + /** @psalm-suppress RiskyTruthyFalsyComparison */ if (isset($item['tid']) && $item['tid'] === $activeId) { if ($item['href'] === Environment::get('request')) { - $item['isActive'] = true; // nothing else (active class is set in template) + $item['isActive'] = true; // nothing else (active class is set in template) } else { $item['isInTrail'] = true; } } } + /** @psalm-suppress RiskyTruthyFalsyComparison */ if ($item['isInTrail']) { $item['class'] .= ' trail'; } + /** @psalm-suppress RiskyTruthyFalsyComparison */ if (! isset($this->items->subItems[$itemId])) { $item['class'] .= ' leaf'; } elseif ($currentLevel >= $hardLevel) { @@ -196,6 +197,7 @@ private function renderTree( if ($containsActive) { foreach ($renderedItems as &$item) { + /** @psalm-suppress RiskyTruthyFalsyComparison */ if ($item['isActive']) { continue; }