Skip to content

Commit

Permalink
PHPStan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tischsoic committed Oct 22, 2024
1 parent 4bde741 commit dc62729
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
15 changes: 10 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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\\<array\\{version\\: int, contentclassattribute_id\\: int, contentobject_id\\: int, language_id\\: int\\}\\> but returns array\\<int, array\\<string, mixed\\>\\>\\.$#"
count: 1
path: src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Core\\\\Converter\\\\ContentParamConverter\\:\\:getSupportedClass\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
10 changes: 7 additions & 3 deletions src/bundle/Core/Command/VirtualFieldDuplicateFixCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit dc62729

Please sign in to comment.