From dc627290d10b6872f98bb3de61ea5f8905b21649 Mon Sep 17 00:00:00 2001 From: tischsoic Date: Tue, 22 Oct 2024 12:01:17 +0200 Subject: [PATCH] PHPStan fixes --- phpstan-baseline.neon | 15 ++++++++++----- phpstan.neon.dist | 2 +- .../Command/VirtualFieldDuplicateFixCommand.php | 10 +++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b1e31685b4..29e79b78ae 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -420,6 +420,16 @@ parameters: count: 1 path: src/bundle/Core/Command/UpdateTimestampsToUTCCommand.php + - + message: "#^Cannot cast Doctrine\\\\DBAL\\\\ForwardCompatibility\\\\Result\\|int\\|string to int\\.$#" + count: 1 + path: src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php + + - + message: "#^Method Ibexa\\\\Bundle\\\\Core\\\\Command\\\\VirtualFieldDuplicateFixCommand\\:\\:getDuplicatedAttributesBatch\\(\\) should return array\\ but returns array\\\\>\\.$#" + count: 1 + path: src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php + - message: "#^Method Ibexa\\\\Bundle\\\\Core\\\\Converter\\\\ContentParamConverter\\:\\:getSupportedClass\\(\\) has no return type specified\\.$#" count: 1 @@ -10885,11 +10895,6 @@ parameters: count: 1 path: src/lib/IO/IOMetadataHandler/LegacyDFSCluster.php - - - message: "#^Cannot call method rowCount\\(\\) on Doctrine\\\\DBAL\\\\ForwardCompatibility\\\\Result\\|int\\|string\\.$#" - count: 3 - path: src/lib/IO/IOMetadataHandler/LegacyDFSCluster.php - - message: "#^Method Ibexa\\\\Core\\\\IO\\\\IOMetadataHandler\\\\LegacyDFSCluster\\:\\:delete\\(\\) has no return type specified\\.$#" count: 1 diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 54acab26b1..a8e4451c5c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -9,7 +9,7 @@ parameters: treatPhpDocTypesAsCertain: false ignoreErrors: - - message: "#^Cannot call method (fetchOne|fetchColumn|fetchAllAssociative|fetchAssociative|fetchAllKeyValue|fetchFirstColumn)\\(\\) on Doctrine\\\\DBAL\\\\ForwardCompatibility\\\\Result\\|int\\|string\\.$#" + message: "#^Cannot call method (fetchOne|fetchColumn|fetchAllAssociative|fetchAssociative|fetchAllKeyValue|fetchFirstColumn|rowCount)\\(\\) on Doctrine\\\\DBAL\\\\ForwardCompatibility\\\\Result\\|int\\|string\\.$#" paths: - src/* - tests/* diff --git a/src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php b/src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php index 2f4d93f58f..cae7b56911 100644 --- a/src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php +++ b/src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php @@ -164,7 +164,7 @@ private function getDuplicatedAttributeTotalCount( ->from('ezcontentobject_attribute', 'a') ->having('instances > 1'); - $count = $query->execute()->rowCount(); + $count = (int) $query->execute()->rowCount(); if ($count > 0) { $style->warning( @@ -245,13 +245,17 @@ private function askForConfirmation(SymfonyStyle $style): bool ); } - private function deleteAttributes($ids): int + /** + * @param int[] $ids + * @throws \Doctrine\DBAL\Exception + */ + private function deleteAttributes(array $ids): int { $query = $this->connection->createQueryBuilder(); $query ->delete('ezcontentobject_attribute') - ->andWhere($query->expr()->in('id', $ids)); + ->andWhere($query->expr()->in('id', array_map("strval", $ids))); return (int)$query->execute(); }