From d75184c7d5566979be7879fb6de745249acae51f Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 15 Jul 2024 09:43:18 +0200 Subject: [PATCH] Fix --- phpstan-baseline.neon | 3 --- psalm-baseline.xml | 16 ---------------- psalm.xml | 2 +- src/Datagrid/ProxyQuery.php | 3 ++- src/FieldDescription/FieldDescriptionFactory.php | 6 ------ tests/Filter/FilterTest.php | 6 ++++-- tests/Fixtures/Query/FooWalker.php | 3 ++- tests/Fixtures/TestEntityManagerFactory.php | 10 +++++++--- 8 files changed, 16 insertions(+), 33 deletions(-) delete mode 100644 psalm-baseline.xml diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 78845e324..f649e624e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -9,6 +9,3 @@ parameters: - # https://github.com/phpstan/phpstan-strict-rules/issues/130 message: '#^Call to static method PHPUnit\\Framework\\Assert::.* will always evaluate to true\.$#' path: tests/ - - # https://github.com/doctrine/orm/pull/9778 - message: '#Parameter \#1 \$className of method Doctrine\\Persistence\\Mapping\\AbstractClassMetadataFactory::getMetadataFor\(\) expects class-string, string given.#' - path: src/Datagrid/ProxyQuery.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml deleted file mode 100644 index aba321032..000000000 --- a/psalm-baseline.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - string - - - $alias - - - - $rootEntity - - - diff --git a/psalm.xml b/psalm.xml index a22220489..eb9c69167 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Datagrid/ProxyQuery.php b/src/Datagrid/ProxyQuery.php index 3e3f4686e..68e7a7585 100644 --- a/src/Datagrid/ProxyQuery.php +++ b/src/Datagrid/ProxyQuery.php @@ -13,6 +13,7 @@ namespace Sonata\DoctrineORMAdminBundle\Datagrid; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\EntityManager; @@ -277,7 +278,7 @@ public function entityJoin(array $associationMappings): string $newAlias = 's'; - /** @var Query\Expr\Join[][] $joinedEntities */ + /** @var Join[][] $joinedEntities */ $joinedEntities = $this->queryBuilder->getDQLPart('join'); foreach ($associationMappings as $associationMapping) { diff --git a/src/FieldDescription/FieldDescriptionFactory.php b/src/FieldDescription/FieldDescriptionFactory.php index 9d8fd763f..12b9e3b04 100644 --- a/src/FieldDescription/FieldDescriptionFactory.php +++ b/src/FieldDescription/FieldDescriptionFactory.php @@ -102,7 +102,6 @@ private function getEntityManager(string $class): EntityManagerInterface } /** - * @psalm-suppress UndefinedClass * @phpstan-ignore-next-line */ private function mappingToArray(array|FieldMapping|AssociationMapping $mapping): array @@ -111,12 +110,7 @@ private function mappingToArray(array|FieldMapping|AssociationMapping $mapping): return $mapping; } - /** - * @psalm-suppress UndefinedClass - * @phpstan-ignore-next-line - */ if ($mapping instanceof AssociationMapping) { - /* @phpstan-ignore-next-line */ return $mapping->toArray(); } diff --git a/tests/Filter/FilterTest.php b/tests/Filter/FilterTest.php index b624af76b..111497b77 100644 --- a/tests/Filter/FilterTest.php +++ b/tests/Filter/FilterTest.php @@ -33,7 +33,7 @@ public function testOrExpression(string $expected, array $filterOptionsCollectio $entityManager->method('getExpressionBuilder')->willReturn(new Expr()); $queryBuilder = new TestQueryBuilder($entityManager); - $queryBuilder->select('e')->from('MyEntity', 'e'); + $queryBuilder->select('e')->from(MyEntity::class, 'e'); // Some custom conditions set previous to the filters. $queryBuilder @@ -46,7 +46,7 @@ public function testOrExpression(string $expected, array $filterOptionsCollectio ) ->setParameter('parameter_1', 3); - static::assertSame('SELECT e FROM MyEntity e WHERE 1 = 2 AND (:parameter_1 = 4 OR 5 = 6)', $queryBuilder->getDQL()); + static::assertSame('SELECT e FROM Sonata\DoctrineORMAdminBundle\Tests\Filter\MyEntity e WHERE 1 = 2 AND (:parameter_1 = 4 OR 5 = 6)', $queryBuilder->getDQL()); $proxyQuery = new ProxyQuery($queryBuilder); @@ -102,3 +102,5 @@ public function provideOrExpressionCases(): iterable ]; } } + +class MyEntity {} diff --git a/tests/Fixtures/Query/FooWalker.php b/tests/Fixtures/Query/FooWalker.php index da682026f..6c9ac92bb 100644 --- a/tests/Fixtures/Query/FooWalker.php +++ b/tests/Fixtures/Query/FooWalker.php @@ -13,11 +13,12 @@ namespace Sonata\DoctrineORMAdminBundle\Tests\Fixtures\Query; +use Doctrine\ORM\Query\AST\OrderByClause; use Doctrine\ORM\Query\SqlWalker; final class FooWalker extends SqlWalker { - public function walkOrderByClause($orderByClause): string + public function walkOrderByClause(OrderByClause $orderByClause): string { return str_replace(' ASC', ' DESC', parent::walkOrderByClause($orderByClause)); } diff --git a/tests/Fixtures/TestEntityManagerFactory.php b/tests/Fixtures/TestEntityManagerFactory.php index 930056230..7cf8ed8bd 100644 --- a/tests/Fixtures/TestEntityManagerFactory.php +++ b/tests/Fixtures/TestEntityManagerFactory.php @@ -15,6 +15,7 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\DriverManager; +use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\ORMSetup; @@ -22,9 +23,6 @@ final class TestEntityManagerFactory { - /** - * @psalm-suppress DeprecatedMethod - */ public static function create(): EntityManagerInterface { if (!\extension_loaded('pdo_sqlite')) { @@ -34,6 +32,12 @@ public static function create(): EntityManagerInterface if (version_compare(\PHP_VERSION, '8.0.0', '>=')) { $config = ORMSetup::createAttributeMetadataConfiguration([], true); } else { + /** + * @var Configuration $config + * + * @psalm-suppress UndefinedMethod + * @phpstan-ignore-next-line + */ $config = ORMSetup::createAnnotationMetadataConfiguration([], true); }