From 33b858aa13a346076f6a2629e45e5b603f0f613d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 2 Dec 2024 13:09:42 +0100 Subject: [PATCH] Bump PHPStan to level 7 While working on a static analysis improvement on another PR, I was surprised not to have any baseline to modify. Here is a big baseline we could work on. --- phpstan-baseline.neon | 230 ++++++++++++++++++++++++++++++++++++++++++ phpstan.neon.dist | 2 +- 2 files changed, 231 insertions(+), 1 deletion(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5cda74c7..789cda34 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,30 @@ parameters: ignoreErrors: + - + message: "#^Strict comparison using \\=\\=\\= between array\\ and false will always evaluate to false\\.$#" + count: 1 + path: src/Event/Listener/MongoDBReferenceListener.php + + - + message: "#^Strict comparison using \\=\\=\\= between array\\ and false will always evaluate to false\\.$#" + count: 1 + path: src/Event/Listener/ORMReferenceListener.php + + - + message: "#^Method class@anonymous/src/Executor/AbstractExecutor\\.php\\:131\\:\\:log\\(\\) has parameter \\$message with no type specified\\.$#" + count: 1 + path: src/Executor/AbstractExecutor.php + + - + message: "#^Method class@anonymous/src/Executor/AbstractExecutor\\.php\\:95\\:\\:log\\(\\) has parameter \\$message with no type specified\\.$#" + count: 1 + path: src/Executor/AbstractExecutor.php + + - + message: "#^Strict comparison using \\!\\=\\= between null and null will always evaluate to false\\.$#" + count: 1 + path: src/Executor/AbstractExecutor.php + - message: "#^Call to method transactional\\(\\) on an unknown class Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManagerInterface\\.$#" count: 1 @@ -10,6 +35,16 @@ parameters: count: 1 path: src/Executor/PHPCRExecutor.php + - + message: "#^Parameter \\#1 \\$dm of method Doctrine\\\\Common\\\\DataFixtures\\\\Purger\\\\PHPCRPurger\\:\\:setDocumentManager\\(\\) expects Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManager, Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManagerInterface given\\.$#" + count: 1 + path: src/Executor/PHPCRExecutor.php + + - + message: "#^Parameter \\#1 \\$manager of method Doctrine\\\\Common\\\\DataFixtures\\\\Executor\\\\AbstractExecutor\\:\\:__construct\\(\\) expects Doctrine\\\\Persistence\\\\ObjectManager, Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManagerInterface given\\.$#" + count: 1 + path: src/Executor/PHPCRExecutor.php + - message: "#^Parameter \\$dm of method Doctrine\\\\Common\\\\DataFixtures\\\\Executor\\\\PHPCRExecutor\\:\\:__construct\\(\\) has invalid type Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManagerInterface\\.$#" count: 2 @@ -25,6 +60,36 @@ parameters: count: 1 path: src/Loader.php + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Loader\\:\\:addFixture\\(\\) has no return type specified\\.$#" + count: 1 + path: src/Loader.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Loader\\:\\:createFixture\\(\\) should return Doctrine\\\\Common\\\\DataFixtures\\\\FixtureInterface but returns object\\.$#" + count: 1 + path: src/Loader.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Loader\\:\\:getUnsequencedClasses\\(\\) should return array\\\\> but returns array\\, class\\-string\\\\|class\\-string\\\\>\\.$#" + count: 1 + path: src/Loader.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Loader\\:\\:loadFromDirectory\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Loader.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Loader\\:\\:loadFromFile\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Loader.php + + - + message: "#^Parameter \\#1 \\$sequences of method Doctrine\\\\Common\\\\DataFixtures\\\\Loader\\:\\:getUnsequencedClasses\\(\\) expects array\\, int\\>, array\\\\|class\\-string\\, int\\> given\\.$#" + count: 2 + path: src/Loader.php + - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getReference\\(\\)\\.$#" count: 2 @@ -35,6 +100,46 @@ parameters: count: 1 path: src/ProxyReferenceRepository.php + - + message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + count: 1 + path: src/Purger/ORMPurger.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Purger\\\\ORMPurger\\:\\:getAssociationTables\\(\\) has parameter \\$classes with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata but does not specify its types\\: T$#" + count: 1 + path: src/Purger/ORMPurger.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Purger\\\\ORMPurger\\:\\:getCommitOrder\\(\\) has parameter \\$classes with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata but does not specify its types\\: T$#" + count: 1 + path: src/Purger/ORMPurger.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Purger\\\\ORMPurger\\:\\:getCommitOrder\\(\\) return type with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata does not specify its types\\: T$#" + count: 1 + path: src/Purger/ORMPurger.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Purger\\\\ORMPurger\\:\\:getJoinTableName\\(\\) has parameter \\$class with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata but does not specify its types\\: T$#" + count: 1 + path: src/Purger/ORMPurger.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Purger\\\\ORMPurger\\:\\:getTableName\\(\\) has parameter \\$class with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata but does not specify its types\\: T$#" + count: 1 + path: src/Purger/ORMPurger.php + + - + message: "#^Parameter \\#1 \\$assoc of method Doctrine\\\\Common\\\\DataFixtures\\\\Purger\\\\ORMPurger\\:\\:getJoinTableName\\(\\) expects array\\|Doctrine\\\\ORM\\\\Mapping\\\\ManyToManyOwningSideMapping, Doctrine\\\\ORM\\\\Mapping\\\\ManyToManyInverseSideMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\ManyToManyOwningSideMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\ManyToOneAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToManyAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneInverseSideMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneOwningSideMapping given\\.$#" + count: 1 + path: src/Purger/ORMPurger.php + + - + message: "#^Parameter \\#1 \\$association of method Doctrine\\\\ORM\\\\Mapping\\\\QuoteStrategy\\:\\:getJoinTableName\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ManyToManyOwningSideMapping, array\\|Doctrine\\\\ORM\\\\Mapping\\\\ManyToManyOwningSideMapping given\\.$#" + count: 1 + path: src/Purger/ORMPurger.php + - message: "#^Call to method getPhpcrSession\\(\\) on an unknown class Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManagerInterface\\.$#" count: 1 @@ -50,6 +155,11 @@ parameters: count: 1 path: src/Purger/PHPCRPurger.php + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Purger\\\\PHPCRPurger\\:\\:setDocumentManager\\(\\) has no return type specified\\.$#" + count: 1 + path: src/Purger/PHPCRPurger.php + - message: "#^Parameter \\$dm of method Doctrine\\\\Common\\\\DataFixtures\\\\Purger\\\\PHPCRPurger\\:\\:__construct\\(\\) has invalid type Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManagerInterface\\.$#" count: 1 @@ -85,11 +195,76 @@ parameters: count: 2 path: src/ReferenceRepository.php + - + message: "#^Call to an undefined method object\\:\\:getDocumentId\\(\\)\\.$#" + count: 1 + path: src/ReferenceRepository.php + + - + message: "#^Call to an undefined method object\\:\\:getDocumentIdentifier\\(\\)\\.$#" + count: 1 + path: src/ReferenceRepository.php + - message: "#^Class Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManager not found\\.$#" count: 2 path: src/ReferenceRepository.php + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\ReferenceRepository\\:\\:getIdentifier\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/ReferenceRepository.php + + - + message: "#^Parameter \\#1 \\$className of method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getClassMetadata\\(\\) expects class\\-string\\, string given\\.$#" + count: 2 + path: src/ReferenceRepository.php + + - + message: "#^Property Doctrine\\\\Common\\\\DataFixtures\\\\ReferenceRepository\\:\\:\\$identitiesByClass \\(array\\\\>\\) does not accept array\\\\>\\.$#" + count: 2 + path: src/ReferenceRepository.php + + - + message: "#^Property Doctrine\\\\Common\\\\DataFixtures\\\\ReferenceRepository\\:\\:\\$referencesByClass \\(array\\\\>\\) does not accept array\\\\>\\.$#" + count: 1 + path: src/ReferenceRepository.php + + - + message: "#^Property Doctrine\\\\Common\\\\DataFixtures\\\\ReferenceRepository\\:\\:\\$referencesByClass \\(array\\\\>\\) does not accept array\\\\>\\.$#" + count: 1 + path: src/ReferenceRepository.php + + - + message: "#^Unable to resolve the template type T in call to method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getClassMetadata\\(\\)$#" + count: 2 + path: src/ReferenceRepository.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Sorter\\\\TopologicalSorter\\:\\:addNode\\(\\) has parameter \\$node with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata but does not specify its types\\: T$#" + count: 1 + path: src/Sorter/TopologicalSorter.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Sorter\\\\TopologicalSorter\\:\\:sort\\(\\) return type with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata does not specify its types\\: T$#" + count: 1 + path: src/Sorter/TopologicalSorter.php + + - + message: "#^Property Doctrine\\\\Common\\\\DataFixtures\\\\Sorter\\\\TopologicalSorter\\:\\:\\$sortedNodeList with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata does not specify its types\\: T$#" + count: 1 + path: src/Sorter/TopologicalSorter.php + + - + message: "#^Method Doctrine\\\\Common\\\\DataFixtures\\\\Sorter\\\\Vertex\\:\\:__construct\\(\\) has parameter \\$value with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata but does not specify its types\\: T$#" + count: 1 + path: src/Sorter/Vertex.php + + - + message: "#^Property Doctrine\\\\Common\\\\DataFixtures\\\\Sorter\\\\Vertex\\:\\:\\$value with generic class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata does not specify its types\\: T$#" + count: 1 + path: src/Sorter/Vertex.php + - message: "#^Method Doctrine\\\\Tests\\\\Common\\\\DataFixtures\\\\FixtureWithUnexistentDependency\\:\\:getDependencies\\(\\) should return array\\\\> but returns array\\\\.$#" count: 1 @@ -105,7 +280,62 @@ parameters: count: 2 path: tests/Common/DataFixtures/Executor/PHPCRExecutorTest.php + - + message: "#^Parameter \\#1 \\$dm of class Doctrine\\\\Common\\\\DataFixtures\\\\Executor\\\\PHPCRExecutor constructor expects Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManagerInterface, Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManager&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject given\\.$#" + count: 5 + path: tests/Common/DataFixtures/Executor/PHPCRExecutorTest.php + - message: "#^Call to an undefined method Doctrine\\\\ODM\\\\MongoDB\\\\DocumentManager\\:\\:getConnection\\(\\)\\.$#" count: 1 path: tests/Common/DataFixtures/Purger/MongoDBPurgerTest.php + + - + message: "#^Parameter \\#1 \\$name of class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata constructor expects class\\-string\\<1\\>, string given\\.$#" + count: 6 + path: tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php + + - + message: "#^Parameter \\#1 \\$name of class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata constructor expects class\\-string\\<2\\>, string given\\.$#" + count: 5 + path: tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php + + - + message: "#^Parameter \\#1 \\$name of class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata constructor expects class\\-string\\<3\\>, string given\\.$#" + count: 5 + path: tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php + + - + message: "#^Parameter \\#1 \\$name of class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata constructor expects class\\-string\\<4\\>, string given\\.$#" + count: 3 + path: tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php + + - + message: "#^Parameter \\#1 \\$name of class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata constructor expects class\\-string\\<5\\>, string given\\.$#" + count: 3 + path: tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php + + - + message: "#^Parameter \\#1 \\$name of class Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata constructor expects class\\-string\\<\\\\Sample\\\\Entity\\>, string given\\.$#" + count: 1 + path: tests/Common/DataFixtures/Sorter/VertexTest.php + + - + message: "#^Method Doctrine\\\\Tests\\\\Common\\\\DataFixtures\\\\TestEntity\\\\Quoted\\:\\:getSelects\\(\\) return type with generic interface Doctrine\\\\Common\\\\Collections\\\\Collection does not specify its types\\: TKey, T$#" + count: 1 + path: tests/Common/DataFixtures/TestEntity/Quoted.php + + - + message: "#^Method Doctrine\\\\Tests\\\\Common\\\\DataFixtures\\\\TestEntity\\\\Quoted\\:\\:setSelects\\(\\) has parameter \\$selects with generic interface Doctrine\\\\Common\\\\Collections\\\\Collection but does not specify its types\\: TKey, T$#" + count: 1 + path: tests/Common/DataFixtures/TestEntity/Quoted.php + + - + message: "#^Property Doctrine\\\\Tests\\\\Common\\\\DataFixtures\\\\TestEntity\\\\Quoted\\:\\:\\$selects with generic interface Doctrine\\\\Common\\\\Collections\\\\Collection does not specify its types\\: TKey, T$#" + count: 1 + path: tests/Common/DataFixtures/TestEntity/Quoted.php + + - + message: "#^Method Doctrine\\\\Tests\\\\Common\\\\DataFixtures\\\\TestValueObjects\\\\Uuid\\:\\:__unserialize\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + count: 1 + path: tests/Common/DataFixtures/TestValueObjects/Uuid.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 20b0dc06..b8c2369b 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,6 @@ parameters: phpVersion: 80200 - level: 3 + level: 7 paths: - src - tests