From 91709c12751598bb44afe132ebe4620a0e207792 Mon Sep 17 00:00:00 2001 From: Max Mustermann Date: Sat, 5 Oct 2024 13:40:04 +0200 Subject: [PATCH 1/7] fix generating duplicate method stubs When adding the same lifecycle event callback to two or more lifecycle events, the generator will create a stub for each event resulting in fatal 'Cannot redeclare' errors. That is, only if the callback name contains uppercase letters. --- src/Tools/EntityGenerator.php | 33 +++++++++++++++---- tests/Tests/ORM/Tools/EntityGeneratorTest.php | 10 ++++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/Tools/EntityGenerator.php b/src/Tools/EntityGenerator.php index 04be6551881..2c17ca33c93 100644 --- a/src/Tools/EntityGenerator.php +++ b/src/Tools/EntityGenerator.php @@ -1275,12 +1275,25 @@ protected function generateEntityLifecycleCallbackMethods(ClassMetadataInfo $met $methods = []; - foreach ($metadata->lifecycleCallbacks as $name => $callbacks) { + $lifecycleEventsByCallback = []; + foreach ($metadata->lifecycleCallbacks as $event => $callbacks) { foreach ($callbacks as $callback) { - $methods[] = $this->generateLifecycleCallbackMethod($name, $callback, $metadata); + $callbackCaseInsensitive = $callback; + foreach (array_keys($lifecycleEventsByCallback) as $key) { + if (strtolower($key) === strtolower($callback)) { + $callbackCaseInsensitive = $key; + break; + } + } + + $lifecycleEventsByCallback[$callbackCaseInsensitive][] = $event; } } + foreach ($lifecycleEventsByCallback as $callback => $events) { + $methods[] = $this->generateLifecycleCallbackMethod($events, $callback, $metadata); + } + return implode("\n\n", array_filter($methods)); } @@ -1408,8 +1421,8 @@ protected function generateEntityStubMethod(ClassMetadataInfo $metadata, $type, } /** - * @param string $name - * @param string $methodName + * @param string|string[] $name + * @param string $methodName * * @return string */ @@ -1419,10 +1432,16 @@ protected function generateLifecycleCallbackMethod($name, $methodName, ClassMeta return ''; } - $this->staticReflection[$metadata->name]['methods'][] = $methodName; + $this->staticReflection[$metadata->name]['methods'][] = strtolower($methodName); - $replacements = [ - '' => $this->annotationsPrefix . ucfirst($name), + $eventAnnotations = array_map( + function ($event) { + return $this->annotationsPrefix . ucfirst($event); + }, + is_array($name) ? $name : [$name] + ); + $replacements = [ + '' => implode("\n * @", $eventAnnotations), '' => $methodName, ]; diff --git a/tests/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Tests/ORM/Tools/EntityGeneratorTest.php index c37841210f2..c3193686c50 100644 --- a/tests/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Tests/ORM/Tools/EntityGeneratorTest.php @@ -112,6 +112,9 @@ public function generateBookEntityFixture(array $embeddedClasses = []): ClassMet ] ); $metadata->addLifecycleCallback('loading', 'postLoad'); + $metadata->addLifecycleCallback('logChange', 'prePersist'); + $metadata->addLifecycleCallback('logChange', 'preRemove'); + $metadata->addLifecycleCallback('logchange', 'preUpdate'); $metadata->addLifecycleCallback('willBeRemoved', 'preRemove'); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); @@ -282,7 +285,7 @@ public function testGeneratedEntityClass(): void $reflClass = new ReflectionClass($metadata->name); self::assertCount(6, $reflClass->getProperties()); - self::assertCount(15, $reflClass->getMethods()); + self::assertCount(16, $reflClass->getMethods()); self::assertEquals('published', $book->getStatus()); @@ -453,6 +456,7 @@ public function testLifecycleCallbacks(): void self::assertTrue($reflClass->hasMethod('loading'), 'Check for postLoad lifecycle callback.'); self::assertTrue($reflClass->hasMethod('willBeRemoved'), 'Check for preRemove lifecycle callback.'); + self::assertTrue($reflClass->hasMethod('logChange'), 'Check for prePersist and preRemove lifecycle callback.'); } public function testLoadMetadata(): void @@ -472,7 +476,7 @@ public function testLoadMetadata(): void self::assertEquals($cm->columnNames, $metadata->columnNames); self::assertEquals($cm->getTableName(), $metadata->getTableName()); - self::assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); + self::assertEqualsIgnoringCase($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); self::assertEquals($cm->identifier, $metadata->identifier); self::assertEquals($cm->idGenerator, $metadata->idGenerator); self::assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); @@ -513,7 +517,7 @@ public function testLoadPrefixedMetadata(): void self::assertEquals($cm->columnNames, $metadata->columnNames); self::assertEquals($cm->getTableName(), $metadata->getTableName()); - self::assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); + self::assertEqualsIgnoringCase($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); self::assertEquals($cm->identifier, $metadata->identifier); self::assertEquals($cm->idGenerator, $metadata->idGenerator); self::assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); From 65806884b03da413125719bcd88e18ede0c8447f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 8 Oct 2024 17:02:40 +0200 Subject: [PATCH 2/7] Add CI job for PHP 8.4 For now doctrine/common generates proxies that trigger deprecation, so let us only test with lazy ghosts only. --- .github/workflows/continuous-integration.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c6c3cb752aa..e5e887a5838 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -40,6 +40,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" dbal-version: - "default" extension: @@ -113,6 +114,7 @@ jobs: php-version: - "8.2" - "8.3" + - "8.4" dbal-version: - "default" - "3@dev" @@ -186,6 +188,7 @@ jobs: php-version: - "8.2" - "8.3" + - "8.4" dbal-version: - "default" - "3@dev" @@ -256,6 +259,7 @@ jobs: php-version: - "8.2" - "8.3" + - "8.4" dbal-version: - "default" - "3@dev" From 08328adc6c74a17ce8f0f2243ab13a131c35ffd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 8 Oct 2024 17:27:18 +0200 Subject: [PATCH 3/7] Use E_ALL instead of E_ALL | E_STRICT E_STRICT is deprecated as of PHP 8.4 --- tests/Tests/TestInit.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Tests/TestInit.php b/tests/Tests/TestInit.php index eb2db606747..5b8ec4048f4 100644 --- a/tests/Tests/TestInit.php +++ b/tests/Tests/TestInit.php @@ -16,9 +16,8 @@ use function mkdir; use const E_ALL; -use const E_STRICT; -error_reporting(E_ALL | E_STRICT); +error_reporting(E_ALL); date_default_timezone_set('UTC'); if (file_exists(__DIR__ . '/../../vendor/autoload.php')) { From 0e48b19cd3c0167a3d4f6f263ed4510818de4c90 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 9 Oct 2024 10:36:21 +0200 Subject: [PATCH 4/7] Prepare PHP 8.4 support: Prevent property hooks from being used (#11628) Prevent property hooks from being used as they currently would work on external non-raw values without explicit code. --- phpstan-baseline.neon | 5 +++++ psalm-baseline.xml | 3 +++ src/Mapping/ClassMetadataInfo.php | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6f0a73dd5a3..3905f4fc1fe 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -165,6 +165,11 @@ parameters: count: 2 path: src/Mapping/ClassMetadataFactory.php + - + message: "#^Call to an undefined method ReflectionProperty\\:\\:getHooks\\(\\)\\.$#" + count: 1 + path: src/Mapping/ClassMetadataInfo.php + - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\NamingStrategy\\:\\:joinColumnName\\(\\) invoked with 2 parameters, 1 required\\.$#" count: 2 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b9473bebb66..0d2d23f6ae7 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -713,6 +713,9 @@ + + + diff --git a/src/Mapping/ClassMetadataInfo.php b/src/Mapping/ClassMetadataInfo.php index 3780a5d44af..881fabe28db 100644 --- a/src/Mapping/ClassMetadataInfo.php +++ b/src/Mapping/ClassMetadataInfo.php @@ -3890,6 +3890,10 @@ private function getAccessibleProperty(ReflectionService $reflService, string $c } } + if (PHP_VERSION_ID >= 80400 && $reflectionProperty !== null && count($reflectionProperty->getHooks()) > 0) { + throw new LogicException('Doctrine ORM does not support property hooks in this version. Check https://github.com/doctrine/orm/issues/11624 for details of versions that support property hooks.'); + } + return $reflectionProperty; } } From 8a25b264f7d315f166d164847bd6264bdcf83b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 9 Oct 2024 11:05:58 +0200 Subject: [PATCH 5/7] Add upgrade note about property hooks (#11636) People that might have experimented with property hooks while still using ORM < 2.20.0 need to know that they need to remove their experiment or upgrade to a version that explicitly supports them. --- UPGRADE.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index e20a8fef89b..9ffc7d0f3e4 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,13 @@ # Upgrade to 2.20 +## Explictly forbid property hooks + +Property hooks are not supported yet by Doctrine ORM. Until support is added, +they are explicitly forbidden because the support would result in a breaking +change in behavior. + +Progress on this is tracked at https://github.com/doctrine/orm/issues/11624 . + ## PARTIAL DQL syntax is undeprecated for non-object hydration Use of the PARTIAL keyword is not deprecated anymore in DQL when used with a hydrator From 52660297ab8e46880db74901591bdd9d3865a167 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 9 Oct 2024 14:47:57 +0200 Subject: [PATCH 6/7] Let PHPStan detect deprecated usages (#11639) --- composer.json | 5 ++++- phpstan-dbal2.neon | 5 +++++ phpstan-persistence2.neon | 12 +++++++++++ src/AbstractQuery.php | 7 +++++++ src/Cache/Region.php | 2 ++ src/Cache/Region/DefaultRegion.php | 2 ++ src/Configuration.php | 3 +++ src/Decorator/EntityManagerDecorator.php | 1 + src/EntityManager.php | 7 +++++-- src/Event/PostLoadEventArgs.php | 1 + src/Event/PostPersistEventArgs.php | 1 + src/Event/PostRemoveEventArgs.php | 1 + src/Event/PostUpdateEventArgs.php | 1 + src/Event/PrePersistEventArgs.php | 1 + src/Event/PreRemoveEventArgs.php | 1 + src/Event/PreUpdateEventArgs.php | 3 +++ src/Exception/ORMException.php | 2 ++ src/Id/AbstractIdGenerator.php | 1 + src/Internal/CriteriaOrderings.php | 1 + src/Mapping/Builder/ClassMetadataBuilder.php | 2 ++ src/Mapping/ClassMetadataFactory.php | 11 +++++++--- src/Mapping/ClassMetadataInfo.php | 12 +++++++++-- src/Mapping/DefaultQuoteStrategy.php | 4 +++- src/Mapping/Driver/AttributeDriver.php | 2 ++ src/Mapping/Driver/SimplifiedYamlDriver.php | 2 ++ src/Mapping/Driver/XmlDriver.php | 4 ++++ src/Mapping/MappingAttribute.php | 6 +++++- .../Entity/JoinedSubclassPersister.php | 1 + src/Proxy/ProxyFactory.php | 1 + src/Query.php | 1 + src/Query/AST/InListExpression.php | 2 ++ src/Query/AST/InSubselectExpression.php | 2 ++ src/Query/AST/IndexBy.php | 1 + src/Query/Exec/AbstractSqlExecutor.php | 4 ++++ src/Query/Lexer.php | 7 ++++++- src/Query/ParameterTypeInferer.php | 14 +++++++++++-- src/Query/Parser.php | 3 +++ src/Query/TreeWalkerAdapter.php | 1 + src/QueryBuilder.php | 20 +++++++++++++++++-- .../Command/ClearCache/QueryCommand.php | 1 + .../Command/ClearCache/ResultCommand.php | 5 +++-- src/Tools/Console/ConsoleRunner.php | 8 ++++++++ .../Export/Driver/AnnotationExporter.php | 2 ++ src/Tools/Export/Driver/PhpExporter.php | 2 ++ src/Tools/Export/Driver/XmlExporter.php | 2 ++ src/Tools/Export/Driver/YamlExporter.php | 2 ++ src/Tools/Pagination/LimitSubqueryWalker.php | 1 + src/Tools/SchemaTool.php | 6 ++++++ 48 files changed, 169 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 5d2272ad0d7..68d8961f52d 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "config": { "allow-plugins": { "composer/package-versions-deprecated": true, - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true }, "sort-packages": true }, @@ -42,7 +43,9 @@ "doctrine/annotations": "^1.13 || ^2", "doctrine/coding-standard": "^9.0.2 || ^12.0", "phpbench/phpbench": "^0.16.10 || ^1.0", + "phpstan/extension-installer": "~1.1.0 || ^1.4", "phpstan/phpstan": "~1.4.10 || 1.12.6", + "phpstan/phpstan-deprecation-rules": "^1", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6", "psr/log": "^1 || ^2 || ^3", "squizlabs/php_codesniffer": "3.7.2", diff --git a/phpstan-dbal2.neon b/phpstan-dbal2.neon index 98cba7badc1..b6ad21dc1ee 100644 --- a/phpstan-dbal2.neon +++ b/phpstan-dbal2.neon @@ -61,6 +61,11 @@ parameters: count: 2 path: src/Mapping/ClassMetadataFactory.php + - '~^Call to deprecated method getSQLResultCasing\(\) of class Doctrine\\DBAL\\Platforms\\AbstractPlatform\.$~' + - + message: '~deprecated class Doctrine\\DBAL\\Tools\\Console\\Command\\ImportCommand\:~' + path: src/Tools/Console/ConsoleRunner.php + # Symfony cache supports passing a key prefix to the clear method. - '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/' diff --git a/phpstan-persistence2.neon b/phpstan-persistence2.neon index 931876129c3..9cf17979fbe 100644 --- a/phpstan-persistence2.neon +++ b/phpstan-persistence2.neon @@ -3,6 +3,8 @@ includes: - phpstan-params.neon parameters: + reportUnmatchedIgnoredErrors: false + ignoreErrors: # deprecations from doctrine/dbal:3.x - '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getGuidExpression\(\).$/' @@ -70,3 +72,13 @@ parameters: paths: - src/Mapping/Driver/XmlDriver.php - src/Mapping/Driver/YamlDriver.php + + # Extending a deprecated class conditionally to maintain BC + - + message: '~deprecated class Doctrine\\Persistence\\Mapping\\Driver\\AnnotationDriver\:~' + path: src/Mapping/Driver/CompatibilityAnnotationDriver.php + + # We're sniffing for this deprecated class in order to detect Persistence 2 + - + message: '~deprecated class Doctrine\\Common\\Persistence\\PersistentObject\:~' + path: src/EntityManager.php diff --git a/src/AbstractQuery.php b/src/AbstractQuery.php index 7532681580c..731e6b621b9 100644 --- a/src/AbstractQuery.php +++ b/src/AbstractQuery.php @@ -558,9 +558,11 @@ public function setHydrationCacheProfile(?QueryCacheProfile $profile = null) // DBAL 2 if (! method_exists(QueryCacheProfile::class, 'setResultCache')) { + // @phpstan-ignore method.deprecated if (! $profile->getResultCacheDriver()) { $defaultHydrationCacheImpl = $this->_em->getConfiguration()->getHydrationCache(); if ($defaultHydrationCacheImpl) { + // @phpstan-ignore method.deprecated $profile = $profile->setResultCacheDriver(DoctrineProvider::wrap($defaultHydrationCacheImpl)); } } @@ -609,9 +611,11 @@ public function setResultCacheProfile(?QueryCacheProfile $profile = null) // DBAL 2 if (! method_exists(QueryCacheProfile::class, 'setResultCache')) { + // @phpstan-ignore method.deprecated if (! $profile->getResultCacheDriver()) { $defaultResultCacheDriver = $this->_em->getConfiguration()->getResultCache(); if ($defaultResultCacheDriver) { + // @phpstan-ignore method.deprecated $profile = $profile->setResultCacheDriver(DoctrineProvider::wrap($defaultResultCacheDriver)); } } @@ -677,6 +681,7 @@ public function setResultCache(?CacheItemPoolInterface $resultCache = null) $resultCacheDriver = DoctrineProvider::wrap($resultCache); $this->_queryCacheProfile = $this->_queryCacheProfile + // @phpstan-ignore method.deprecated ? $this->_queryCacheProfile->setResultCacheDriver($resultCacheDriver) : new QueryCacheProfile(0, null, $resultCacheDriver); @@ -780,6 +785,7 @@ public function setResultCacheLifetime($lifetime) // Compatibility for DBAL 2 if (! method_exists($this->_queryCacheProfile, 'setResultCache')) { + // @phpstan-ignore method.deprecated $this->_queryCacheProfile = $this->_queryCacheProfile->setResultCacheDriver(DoctrineProvider::wrap($cache)); return $this; @@ -1235,6 +1241,7 @@ private function getHydrationCache(): CacheItemPoolInterface // Support for DBAL 2 if (! method_exists($this->_hydrationCacheProfile, 'getResultCache')) { + // @phpstan-ignore method.deprecated $cacheDriver = $this->_hydrationCacheProfile->getResultCacheDriver(); assert($cacheDriver !== null); diff --git a/src/Cache/Region.php b/src/Cache/Region.php index 46b0624f5ec..a87afb9b951 100644 --- a/src/Cache/Region.php +++ b/src/Cache/Region.php @@ -8,6 +8,8 @@ /** * Defines a contract for accessing a particular named region. + * + * @phpstan-ignore interface.extendsDeprecatedInterface */ interface Region extends MultiGetRegion { diff --git a/src/Cache/Region/DefaultRegion.php b/src/Cache/Region/DefaultRegion.php index 3a452a6e82b..8100b2d6921 100644 --- a/src/Cache/Region/DefaultRegion.php +++ b/src/Cache/Region/DefaultRegion.php @@ -72,6 +72,7 @@ public function __construct(string $name, $cacheItemPool, int $lifetime = 0) CacheItemPoolInterface::class ); + // @phpstan-ignore property.deprecated $this->cache = $cacheItemPool; $this->cacheItemPool = CacheAdapter::wrap($cacheItemPool); } elseif (! $cacheItemPool instanceof CacheItemPoolInterface) { @@ -82,6 +83,7 @@ public function __construct(string $name, $cacheItemPool, int $lifetime = 0) get_debug_type($cacheItemPool) )); } else { + // @phpstan-ignore property.deprecated $this->cache = DoctrineProvider::wrap($cacheItemPool); $this->cacheItemPool = $cacheItemPool; } diff --git a/src/Configuration.php b/src/Configuration.php index a6c932724f7..32adbd16bd3 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -269,6 +269,7 @@ public function getEntityNamespace($entityNamespaceAlias) ); if (! isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) { + // @phpstan-ignore staticMethod.deprecatedClass throw UnknownEntityNamespace::fromNamespaceAlias($entityNamespaceAlias); } @@ -314,6 +315,7 @@ public function getResultCache(): ?CacheItemPoolInterface { // Compatibility with DBAL 2 if (! method_exists(parent::class, 'getResultCache')) { + // @phpstan-ignore method.deprecated $cacheImpl = $this->getResultCacheImpl(); return $cacheImpl ? CacheAdapter::wrap($cacheImpl) : null; @@ -329,6 +331,7 @@ public function setResultCache(CacheItemPoolInterface $cache): void { // Compatibility with DBAL 2 if (! method_exists(parent::class, 'setResultCache')) { + // @phpstan-ignore method.deprecated $this->setResultCacheImpl(DoctrineProvider::wrap($cache)); return; diff --git a/src/Decorator/EntityManagerDecorator.php b/src/Decorator/EntityManagerDecorator.php index c8007e40ae1..889479aa32a 100644 --- a/src/Decorator/EntityManagerDecorator.php +++ b/src/Decorator/EntityManagerDecorator.php @@ -96,6 +96,7 @@ public function wrapInTransaction(callable $func) E_USER_NOTICE ); + // @phpstan-ignore method.deprecated return $this->wrapped->transactional($func); } diff --git a/src/EntityManager.php b/src/EntityManager.php index f7d47d7b12e..0e52f1934e2 100644 --- a/src/EntityManager.php +++ b/src/EntityManager.php @@ -162,8 +162,9 @@ public function __construct(Connection $conn, Configuration $config, ?EventManag throw MissingMappingDriverImplementation::create(); } - $this->conn = $conn; - $this->config = $config; + $this->conn = $conn; + $this->config = $config; + // @phpstan-ignore method.deprecated $this->eventManager = $eventManager ?? $conn->getEventManager(); $metadataFactoryClassName = $config->getClassMetadataFactoryName(); @@ -615,6 +616,7 @@ public function getPartialReference($entityName, $identifier) public function clear($entityName = null) { if ($entityName !== null && ! is_string($entityName)) { + // @phpstan-ignore staticMethod.deprecated throw ORMInvalidArgumentException::invalidEntityName($entityName); } @@ -1109,6 +1111,7 @@ private function configureMetadataCache(): void private function configureLegacyMetadataCache(): void { + // @phpstan-ignore method.deprecated $metadataCache = $this->config->getMetadataCacheImpl(); if (! $metadataCache) { return; diff --git a/src/Event/PostLoadEventArgs.php b/src/Event/PostLoadEventArgs.php index 6365f360db3..466bd019e0e 100644 --- a/src/Event/PostLoadEventArgs.php +++ b/src/Event/PostLoadEventArgs.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Event; +/** @phpstan-ignore class.extendsDeprecatedClass */ final class PostLoadEventArgs extends LifecycleEventArgs { } diff --git a/src/Event/PostPersistEventArgs.php b/src/Event/PostPersistEventArgs.php index 49773f8b790..f7074f5f22b 100644 --- a/src/Event/PostPersistEventArgs.php +++ b/src/Event/PostPersistEventArgs.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Event; +/** @phpstan-ignore class.extendsDeprecatedClass */ final class PostPersistEventArgs extends LifecycleEventArgs { } diff --git a/src/Event/PostRemoveEventArgs.php b/src/Event/PostRemoveEventArgs.php index 8e105a57435..d6b2afa7282 100644 --- a/src/Event/PostRemoveEventArgs.php +++ b/src/Event/PostRemoveEventArgs.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Event; +/** @phpstan-ignore class.extendsDeprecatedClass */ final class PostRemoveEventArgs extends LifecycleEventArgs { } diff --git a/src/Event/PostUpdateEventArgs.php b/src/Event/PostUpdateEventArgs.php index 927f3c3487f..448292b6098 100644 --- a/src/Event/PostUpdateEventArgs.php +++ b/src/Event/PostUpdateEventArgs.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Event; +/** @phpstan-ignore class.extendsDeprecatedClass */ final class PostUpdateEventArgs extends LifecycleEventArgs { } diff --git a/src/Event/PrePersistEventArgs.php b/src/Event/PrePersistEventArgs.php index 5554ef3d757..96c7f82fde2 100644 --- a/src/Event/PrePersistEventArgs.php +++ b/src/Event/PrePersistEventArgs.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Event; +/** @phpstan-ignore class.extendsDeprecatedClass */ final class PrePersistEventArgs extends LifecycleEventArgs { } diff --git a/src/Event/PreRemoveEventArgs.php b/src/Event/PreRemoveEventArgs.php index 042b737983b..b2fb51bd998 100644 --- a/src/Event/PreRemoveEventArgs.php +++ b/src/Event/PreRemoveEventArgs.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Event; +/** @phpstan-ignore class.extendsDeprecatedClass */ final class PreRemoveEventArgs extends LifecycleEventArgs { } diff --git a/src/Event/PreUpdateEventArgs.php b/src/Event/PreUpdateEventArgs.php index 716a82cc7b9..153f69cbfb1 100644 --- a/src/Event/PreUpdateEventArgs.php +++ b/src/Event/PreUpdateEventArgs.php @@ -13,6 +13,8 @@ /** * Class that holds event arguments for a preUpdate event. + * + * @phpstan-ignore class.extendsDeprecatedClass */ class PreUpdateEventArgs extends LifecycleEventArgs { @@ -26,6 +28,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs */ public function __construct($entity, EntityManagerInterface $em, array &$changeSet) { + // @phpstan-ignore staticMethod.deprecatedClass parent::__construct($entity, $em); $this->entityChangeSet = &$changeSet; diff --git a/src/Exception/ORMException.php b/src/Exception/ORMException.php index 55962b515cd..5e54fa372c2 100644 --- a/src/Exception/ORMException.php +++ b/src/Exception/ORMException.php @@ -8,6 +8,8 @@ /** * Should become an interface in 3.0 + * + * @phpstan-ignore class.extendsDeprecatedClass */ class ORMException extends BaseORMException { diff --git a/src/Id/AbstractIdGenerator.php b/src/Id/AbstractIdGenerator.php index 2da3766f388..809697e825d 100644 --- a/src/Id/AbstractIdGenerator.php +++ b/src/Id/AbstractIdGenerator.php @@ -73,6 +73,7 @@ public function generateId(EntityManagerInterface $em, $entity) throw new InvalidArgumentException('Unsupported entity manager implementation.'); } + // @phpstan-ignore method.deprecated return $this->generate($em, $entity); } diff --git a/src/Internal/CriteriaOrderings.php b/src/Internal/CriteriaOrderings.php index 249b0c6f664..af02ca2b77e 100644 --- a/src/Internal/CriteriaOrderings.php +++ b/src/Internal/CriteriaOrderings.php @@ -22,6 +22,7 @@ trait CriteriaOrderings private static function getCriteriaOrderings(Criteria $criteria): array { if (! method_exists(Criteria::class, 'orderings')) { + // @phpstan-ignore method.deprecated return $criteria->getOrderings(); } diff --git a/src/Mapping/Builder/ClassMetadataBuilder.php b/src/Mapping/Builder/ClassMetadataBuilder.php index 652db841291..cce88a15887 100644 --- a/src/Mapping/Builder/ClassMetadataBuilder.php +++ b/src/Mapping/Builder/ClassMetadataBuilder.php @@ -172,6 +172,8 @@ public function addUniqueConstraint(array $columns, $name) /** * Adds named query. * + * @deprecated + * * @param string $name * @param string $dqlQuery * diff --git a/src/Mapping/ClassMetadataFactory.php b/src/Mapping/ClassMetadataFactory.php index 4134ca097c9..63bcecec7ae 100644 --- a/src/Mapping/ClassMetadataFactory.php +++ b/src/Mapping/ClassMetadataFactory.php @@ -558,6 +558,7 @@ private function addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata { foreach ($parentClass->namedQueries as $name => $query) { if (! isset($subClass->namedQueries[$name])) { + // @phpstan-ignore method.deprecated $subClass->addNamedQuery( [ 'name' => $query['name'], @@ -575,6 +576,7 @@ private function addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMe { foreach ($parentClass->namedNativeQueries as $name => $query) { if (! isset($subClass->namedNativeQueries[$name])) { + // @phpstan-ignore method.deprecated $subClass->addNamedNativeQuery( [ 'name' => $query['name'], @@ -637,7 +639,7 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void $platform = $this->getTargetPlatform(); // Platforms that do not have native IDENTITY support need a sequence to emulate this behaviour. - /** @psalm-suppress UndefinedClass, InvalidClass */ + /** @psalm-suppress UndefinedClass, InvalidClass */ // @phpstan-ignore method.deprecated if (! $platform instanceof MySQLPlatform && ! $platform instanceof SqlitePlatform && ! $platform instanceof SQLServerPlatform && $platform->usesSequenceEmulatedIdentityColumns()) { Deprecation::trigger( 'doctrine/orm', @@ -654,8 +656,9 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void $columnName = $class->getSingleIdentifierColumnName(); $quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']); $sequencePrefix = $class->getSequencePrefix($this->getTargetPlatform()); - $sequenceName = $this->getTargetPlatform()->getIdentitySequenceName($sequencePrefix, $columnName); - $definition = [ + // @phpstan-ignore method.deprecated + $sequenceName = $this->getTargetPlatform()->getIdentitySequenceName($sequencePrefix, $columnName); + $definition = [ 'sequenceName' => $this->truncateSequenceName($sequenceName), ]; @@ -711,6 +714,7 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void $class->setIdGenerator(new AssignedGenerator()); break; + // @phpstan-ignore classConstant.deprecated case ClassMetadata::GENERATOR_TYPE_UUID: Deprecation::trigger( 'doctrine/orm', @@ -718,6 +722,7 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void 'Mapping for %s: the "UUID" id generator strategy is deprecated with no replacement', $class->name ); + // @phpstan-ignore new.deprecated $class->setIdGenerator(new UuidGenerator()); break; diff --git a/src/Mapping/ClassMetadataInfo.php b/src/Mapping/ClassMetadataInfo.php index 881fabe28db..b0da6e31f49 100644 --- a/src/Mapping/ClassMetadataInfo.php +++ b/src/Mapping/ClassMetadataInfo.php @@ -1405,6 +1405,7 @@ public function isNullable($fieldName) */ public function getColumnName($fieldName) { + // @phpstan-ignore property.deprecated return $this->columnNames[$fieldName] ?? $fieldName; } @@ -1659,6 +1660,7 @@ protected function validateAndCompleteFieldMapping(array $mapping): array $mapping['quoted'] = true; } + // @phpstan-ignore property.deprecated $this->columnNames[$mapping['fieldName']] = $mapping['columnName']; if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn && $this->discriminatorColumn['name'] === $mapping['columnName'])) { @@ -1683,6 +1685,7 @@ protected function validateAndCompleteFieldMapping(array $mapping): array } } + // @phpstan-ignore method.deprecated if (Type::hasType($mapping['type']) && Type::getType($mapping['type'])->canRequireSQLConversion()) { if (isset($mapping['id']) && $mapping['id'] === true) { throw MappingException::sqlConversionNotAllowedForIdentifiers($this->name, $mapping['fieldName'], $mapping['type']); @@ -2576,6 +2579,7 @@ public function setAttributeOverride($fieldName, array $overrideMapping) unset($this->fieldMappings[$fieldName]); unset($this->fieldNames[$mapping['columnName']]); + // @phpstan-ignore property.deprecated unset($this->columnNames[$mapping['fieldName']]); $overrideMapping = $this->validateAndCompleteFieldMapping($overrideMapping); @@ -2699,6 +2703,7 @@ public function setPrimaryTable(array $table) */ private function isInheritanceType(int $type): bool { + // @phpstan-ignore classConstant.deprecated if ($type === self::INHERITANCE_TYPE_TABLE_PER_CLASS) { Deprecation::trigger( 'doctrine/orm', @@ -2710,6 +2715,7 @@ private function isInheritanceType(int $type): bool return $type === self::INHERITANCE_TYPE_NONE || $type === self::INHERITANCE_TYPE_SINGLE_TABLE || $type === self::INHERITANCE_TYPE_JOINED || + // @phpstan-ignore classConstant.deprecated $type === self::INHERITANCE_TYPE_TABLE_PER_CLASS; } @@ -2766,8 +2772,9 @@ public function addInheritedAssociationMapping(array $mapping/*, $owningClassNam public function addInheritedFieldMapping(array $fieldMapping) { $this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping; - $this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName']; - $this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName']; + // @phpstan-ignore property.deprecated + $this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName']; + $this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName']; if (isset($fieldMapping['generated'])) { $this->requiresFetchAfterChange = true; @@ -3859,6 +3866,7 @@ public function getSequencePrefix(AbstractPlatform $platform) if ($schemaName) { $sequencePrefix = $schemaName . '.' . $tableName; + // @phpstan-ignore method.deprecated if (! $platform->supportsSchemas() && $platform->canEmulateSchemas()) { $sequencePrefix = $schemaName . '__' . $tableName; } diff --git a/src/Mapping/DefaultQuoteStrategy.php b/src/Mapping/DefaultQuoteStrategy.php index f2c2aad4fa1..78404e88dd1 100644 --- a/src/Mapping/DefaultQuoteStrategy.php +++ b/src/Mapping/DefaultQuoteStrategy.php @@ -42,6 +42,7 @@ public function getTableName(ClassMetadata $class, AbstractPlatform $platform) if (! empty($class->table['schema'])) { $tableName = $class->table['schema'] . '.' . $class->table['name']; + // @phpstan-ignore method.deprecated if (! $platform->supportsSchemas() && $platform->canEmulateSchemas()) { $tableName = $class->table['schema'] . '__' . $class->table['name']; } @@ -90,7 +91,8 @@ public function getJoinTableName(array $association, ClassMetadata $class, Abstr $schema = ''; if (isset($association['joinTable']['schema'])) { - $schema = $association['joinTable']['schema']; + $schema = $association['joinTable']['schema']; + // @phpstan-ignore method.deprecated $schema .= ! $platform->supportsSchemas() && $platform->canEmulateSchemas() ? '__' : '.'; } diff --git a/src/Mapping/Driver/AttributeDriver.php b/src/Mapping/Driver/AttributeDriver.php index 1e14836833e..f1537522e84 100644 --- a/src/Mapping/Driver/AttributeDriver.php +++ b/src/Mapping/Driver/AttributeDriver.php @@ -65,6 +65,7 @@ public function __construct(array $paths, bool $reportFieldsWhereDeclared = fals $this->reader = new AttributeReader(); $this->addPaths($paths); + // @phpstan-ignore property.deprecated if ($this->entityAnnotationClasses !== self::ENTITY_ATTRIBUTE_CLASSES) { Deprecation::trigger( 'doctrine/orm', @@ -114,6 +115,7 @@ public function isTransient($className) foreach ($classAttributes as $a) { $attr = $a instanceof RepeatableAttributeCollection ? $a[0] : $a; + // @phpstan-ignore property.deprecated if (isset($this->entityAnnotationClasses[get_class($attr)])) { return false; } diff --git a/src/Mapping/Driver/SimplifiedYamlDriver.php b/src/Mapping/Driver/SimplifiedYamlDriver.php index 30f3348c198..c1fb4bd538b 100644 --- a/src/Mapping/Driver/SimplifiedYamlDriver.php +++ b/src/Mapping/Driver/SimplifiedYamlDriver.php @@ -10,6 +10,8 @@ * YamlDriver that additionally looks for mapping information in a global file. * * @deprecated This class is being removed from the ORM and won't have any replacement + * + * @phpstan-ignore class.extendsDeprecatedClass */ class SimplifiedYamlDriver extends YamlDriver { diff --git a/src/Mapping/Driver/XmlDriver.php b/src/Mapping/Driver/XmlDriver.php index c993a2ba794..036b2f35d05 100644 --- a/src/Mapping/Driver/XmlDriver.php +++ b/src/Mapping/Driver/XmlDriver.php @@ -122,6 +122,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad // Evaluate named queries if (isset($xmlRoot->{'named-queries'})) { foreach ($xmlRoot->{'named-queries'}->{'named-query'} ?? [] as $namedQueryElement) { + // @phpstan-ignore method.deprecated $metadata->addNamedQuery( [ 'name' => (string) $namedQueryElement['name'], @@ -134,6 +135,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad // Evaluate native named queries if (isset($xmlRoot->{'named-native-queries'})) { foreach ($xmlRoot->{'named-native-queries'}->{'named-native-query'} ?? [] as $nativeQueryElement) { + // @phpstan-ignore method.deprecated $metadata->addNamedNativeQuery( [ 'name' => isset($nativeQueryElement['name']) ? (string) $nativeQueryElement['name'] : null, @@ -489,6 +491,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad /** @psalm-suppress DeprecatedConstant */ $orderBy[(string) $orderByField['name']] = isset($orderByField['direction']) ? (string) $orderByField['direction'] + // @phpstan-ignore classConstant.deprecated : (class_exists(Order::class) ? (Order::Ascending)->value : Criteria::ASC); } @@ -618,6 +621,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad /** @psalm-suppress DeprecatedConstant */ $orderBy[(string) $orderByField['name']] = isset($orderByField['direction']) ? (string) $orderByField['direction'] + // @phpstan-ignore classConstant.deprecated : (class_exists(Order::class) ? (Order::Ascending)->value : Criteria::ASC); } diff --git a/src/Mapping/MappingAttribute.php b/src/Mapping/MappingAttribute.php index 979d5031744..48b491c0bdc 100644 --- a/src/Mapping/MappingAttribute.php +++ b/src/Mapping/MappingAttribute.php @@ -4,7 +4,11 @@ namespace Doctrine\ORM\Mapping; -/** A marker interface for mapping attributes. */ +/** + * A marker interface for mapping attributes. + * + * @phpstan-ignore interface.extendsDeprecatedInterface + */ interface MappingAttribute extends Annotation { } diff --git a/src/Persisters/Entity/JoinedSubclassPersister.php b/src/Persisters/Entity/JoinedSubclassPersister.php index 1d6a47855f9..2b2b842ea4f 100644 --- a/src/Persisters/Entity/JoinedSubclassPersister.php +++ b/src/Persisters/Entity/JoinedSubclassPersister.php @@ -250,6 +250,7 @@ public function delete($entity) // If the database platform supports FKs, just // delete the row from the root table. Cascades do the rest. + // @phpstan-ignore method.deprecated if ($this->platform->supportsForeignKeyConstraints()) { $rootClass = $this->em->getClassMetadata($this->class->rootEntityName); $rootTable = $this->quoteStrategy->getTableName($rootClass, $this->platform); diff --git a/src/Proxy/ProxyFactory.php b/src/Proxy/ProxyFactory.php index dc8a72bfcea..aaf51e19fe7 100644 --- a/src/Proxy/ProxyFactory.php +++ b/src/Proxy/ProxyFactory.php @@ -173,6 +173,7 @@ public function __construct(EntityManagerInterface $em, $proxyDir, $proxyNs, $au $this->isLazyGhostObjectEnabled = false; $proxyGenerator = new ProxyGenerator($proxyDir, $proxyNs); + // @phpstan-ignore classConstant.deprecatedInterface $proxyGenerator->setPlaceholder('baseProxyInterface', LegacyProxy::class); parent::__construct($proxyGenerator, $em->getMetadataFactory(), $autoGenerate); diff --git a/src/Query.php b/src/Query.php index a9be33b4da3..2654e04b0cc 100644 --- a/src/Query.php +++ b/src/Query.php @@ -344,6 +344,7 @@ private function evictResultSetCache( $cache = method_exists(QueryCacheProfile::class, 'getResultCache') ? $this->_queryCacheProfile->getResultCache() + // @phpstan-ignore method.deprecated : $this->_queryCacheProfile->getResultCacheDriver(); assert($cache !== null); diff --git a/src/Query/AST/InListExpression.php b/src/Query/AST/InListExpression.php index 10fda3adbff..5139fefba1a 100644 --- a/src/Query/AST/InListExpression.php +++ b/src/Query/AST/InListExpression.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Query\AST; +/** @phpstan-ignore class.extendsDeprecatedClass */ class InListExpression extends InExpression { /** @var non-empty-list */ @@ -15,6 +16,7 @@ public function __construct(ArithmeticExpression $expression, array $literals, b $this->literals = $literals; $this->not = $not; + // @phpstan-ignore staticMethod.deprecatedClass parent::__construct($expression); } } diff --git a/src/Query/AST/InSubselectExpression.php b/src/Query/AST/InSubselectExpression.php index 735b3d3c6a1..12d3aa61dfd 100644 --- a/src/Query/AST/InSubselectExpression.php +++ b/src/Query/AST/InSubselectExpression.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Query\AST; +/** @phpstan-ignore class.extendsDeprecatedClass */ class InSubselectExpression extends InExpression { /** @var Subselect */ @@ -14,6 +15,7 @@ public function __construct(ArithmeticExpression $expression, Subselect $subsele $this->subselect = $subselect; $this->not = $not; + // @phpstan-ignore staticMethod.deprecatedClass parent::__construct($expression); } } diff --git a/src/Query/AST/IndexBy.php b/src/Query/AST/IndexBy.php index fa4c85eacfc..0f0eb6a5316 100644 --- a/src/Query/AST/IndexBy.php +++ b/src/Query/AST/IndexBy.php @@ -23,6 +23,7 @@ class IndexBy extends Node public function __construct(PathExpression $singleValuedPathExpression) { + // @phpstan-ignore property.deprecated $this->singleValuedPathExpression = $this->simpleStateFieldPathExpression = $singleValuedPathExpression; } diff --git a/src/Query/Exec/AbstractSqlExecutor.php b/src/Query/Exec/AbstractSqlExecutor.php index ec8ad481d7b..45277413e2a 100644 --- a/src/Query/Exec/AbstractSqlExecutor.php +++ b/src/Query/Exec/AbstractSqlExecutor.php @@ -39,6 +39,7 @@ abstract class AbstractSqlExecutor public function __construct() { + // @phpstan-ignore property.deprecated $this->_sqlStatements = &$this->sqlStatements; } @@ -93,10 +94,13 @@ public function __sleep(): array public function __wakeup(): void { + // @phpstan-ignore property.deprecated if ($this->_sqlStatements !== null && $this->sqlStatements === null) { + // @phpstan-ignore property.deprecated $this->sqlStatements = $this->_sqlStatements; } + // @phpstan-ignore property.deprecated $this->_sqlStatements = &$this->sqlStatements; } } diff --git a/src/Query/Lexer.php b/src/Query/Lexer.php index 69c329fe590..0c6050c3b55 100644 --- a/src/Query/Lexer.php +++ b/src/Query/Lexer.php @@ -84,7 +84,11 @@ class Lexer extends AbstractLexer public const T_CLOSE_CURLY_BRACE = TokenType::T_CLOSE_CURLY_BRACE; // All tokens that are identifiers or keywords that could be considered as identifiers should be >= 100 - /** @deprecated No Replacement planned. */ + /** + * @deprecated No Replacement planned. + * + * @phpstan-ignore classConstant.deprecated + */ public const T_ALIASED_NAME = TokenType::T_ALIASED_NAME; /** @deprecated use {@see TokenType::T_FULLY_QUALIFIED_NAME} */ @@ -341,6 +345,7 @@ protected function getType(&$value) $value ); + // @phpstan-ignore classConstant.deprecated return TokenType::T_ALIASED_NAME; } diff --git a/src/Query/ParameterTypeInferer.php b/src/Query/ParameterTypeInferer.php index 3f4dee00969..0de508279cd 100644 --- a/src/Query/ParameterTypeInferer.php +++ b/src/Query/ParameterTypeInferer.php @@ -8,10 +8,12 @@ use DateInterval; use DateTimeImmutable; use DateTimeInterface; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Connection; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Types; +use function class_exists; use function current; use function is_array; use function is_bool; @@ -67,9 +69,17 @@ public static function inferType($value) $firstValue = $firstValue->value; } + if (! class_exists(ArrayParameterType::class)) { + return is_int($firstValue) + // @phpstan-ignore classConstant.deprecated + ? Connection::PARAM_INT_ARRAY + // @phpstan-ignore classConstant.deprecated + : Connection::PARAM_STR_ARRAY; + } + return is_int($firstValue) - ? Connection::PARAM_INT_ARRAY - : Connection::PARAM_STR_ARRAY; + ? ArrayParameterType::INTEGER + : ArrayParameterType::STRING; } return ParameterType::STRING; diff --git a/src/Query/Parser.php b/src/Query/Parser.php index a76cd4e45a6..8852c8eef82 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -981,6 +981,7 @@ public function AbstractSchemaName() return $this->lexer->token->value; } + // @phpstan-ignore classConstant.deprecated $this->match(TokenType::T_ALIASED_NAME); assert($this->lexer->token !== null); @@ -2577,6 +2578,8 @@ public function ConditionalPrimary() * AST\InstanceOfExpression| * AST\LikeExpression| * AST\NullComparisonExpression) + * + * @phpstan-ignore return.deprecatedClass */ public function SimpleConditionalExpression() { diff --git a/src/Query/TreeWalkerAdapter.php b/src/Query/TreeWalkerAdapter.php index 4d9776ccd73..c705c52bf2b 100644 --- a/src/Query/TreeWalkerAdapter.php +++ b/src/Query/TreeWalkerAdapter.php @@ -806,6 +806,7 @@ public function getExecutor($AST) final protected function getMetadataForDqlAlias(string $dqlAlias): ClassMetadata { + // @phpstan-ignore method.deprecated $metadata = $this->_getQueryComponents()[$dqlAlias]['metadata'] ?? null; if ($metadata === null) { diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index deb67b6b291..b99c05b44e8 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -86,6 +86,7 @@ class QueryBuilder * * @var int * @psalm-var self::SELECT|self::DELETE|self::UPDATE + * @phpstan-ignore classConstant.deprecated */ private $type = self::SELECT; @@ -94,6 +95,7 @@ class QueryBuilder * * @var int * @psalm-var self::STATE_* + * @phpstan-ignore classConstant.deprecated */ private $state = self::STATE_CLEAN; @@ -342,25 +344,30 @@ public function getState() */ public function getDQL() { + // @phpstan-ignore classConstant.deprecated if ($this->dql !== null && $this->state === self::STATE_CLEAN) { return $this->dql; } switch ($this->type) { + // @phpstan-ignore classConstant.deprecated case self::DELETE: $dql = $this->getDQLForDelete(); break; + // @phpstan-ignore classConstant.deprecated case self::UPDATE: $dql = $this->getDQLForUpdate(); break; + // @phpstan-ignore classConstant.deprecated case self::SELECT: default: $dql = $this->getDQLForSelect(); break; } + // @phpstan-ignore classConstant.deprecated $this->state = self::STATE_CLEAN; $this->dql = $dql; @@ -422,6 +429,7 @@ private function findRootAlias(string $alias, string $parentAlias): string } else { // Should never happen with correct joining order. Might be // thoughtful to throw exception instead. + // @phpstan-ignore method.deprecated $rootAlias = $this->getRootAlias(); } @@ -743,6 +751,7 @@ public function add($dqlPartName, $dqlPart, $append = false) $newDqlPart = []; foreach ($dqlPart as $k => $v) { + // @phpstan-ignore method.deprecated $k = is_numeric($k) ? $this->getRootAlias() : $k; $newDqlPart[$k] = $v; @@ -763,6 +772,7 @@ public function add($dqlPartName, $dqlPart, $append = false) $this->dqlParts[$dqlPartName] = $isMultiple ? [$dqlPart] : $dqlPart; } + // @phpstan-ignore classConstant.deprecated $this->state = self::STATE_DIRTY; return $this; @@ -785,6 +795,7 @@ public function add($dqlPartName, $dqlPart, $append = false) */ public function select($select = null) { + // @phpstan-ignore classConstant.deprecated $this->type = self::SELECT; if (empty($select)) { @@ -816,7 +827,8 @@ public function distinct($flag = true) if ($this->dqlParts['distinct'] !== $flag) { $this->dqlParts['distinct'] = $flag; - $this->state = self::STATE_DIRTY; + // @phpstan-ignore classConstant.deprecated + $this->state = self::STATE_DIRTY; } return $this; @@ -839,6 +851,7 @@ public function distinct($flag = true) */ public function addSelect($select = null) { + // @phpstan-ignore classConstant.deprecated $this->type = self::SELECT; if (empty($select)) { @@ -868,6 +881,7 @@ public function addSelect($select = null) */ public function delete($delete = null, $alias = null) { + // @phpstan-ignore classConstant.deprecated $this->type = self::DELETE; if (! $delete) { @@ -903,6 +917,7 @@ public function delete($delete = null, $alias = null) */ public function update($update = null, $alias = null) { + // @phpstan-ignore classConstant.deprecated $this->type = self::UPDATE; if (! $update) { @@ -1528,7 +1543,8 @@ public function resetDQLParts($parts = null) public function resetDQLPart($part) { $this->dqlParts[$part] = is_array($this->dqlParts[$part]) ? [] : null; - $this->state = self::STATE_DIRTY; + // @phpstan-ignore classConstant.deprecated + $this->state = self::STATE_DIRTY; return $this; } diff --git a/src/Tools/Console/Command/ClearCache/QueryCommand.php b/src/Tools/Console/Command/ClearCache/QueryCommand.php index bdce5adfe4b..8468251b14f 100644 --- a/src/Tools/Console/Command/ClearCache/QueryCommand.php +++ b/src/Tools/Console/Command/ClearCache/QueryCommand.php @@ -71,6 +71,7 @@ private function doExecute(InputInterface $input, OutputInterface $output): int $cacheDriver = null; if (! $cache) { + // @phpstan-ignore method.deprecated $cacheDriver = $em->getConfiguration()->getQueryCacheImpl(); if (! $cacheDriver) { diff --git a/src/Tools/Console/Command/ClearCache/ResultCommand.php b/src/Tools/Console/Command/ClearCache/ResultCommand.php index b79916bfab0..b61a55e0fe7 100644 --- a/src/Tools/Console/Command/ClearCache/ResultCommand.php +++ b/src/Tools/Console/Command/ClearCache/ResultCommand.php @@ -63,8 +63,9 @@ private function doExecute(InputInterface $input, OutputInterface $output): int { $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); - $em = $this->getEntityManager($input); - $cache = $em->getConfiguration()->getResultCache(); + $em = $this->getEntityManager($input); + $cache = $em->getConfiguration()->getResultCache(); + // @phpstan-ignore method.deprecated $cacheDriver = method_exists(Configuration::class, 'getResultCacheImpl') ? $em->getConfiguration()->getResultCacheImpl() : null; if (! $cacheDriver && ! $cache) { diff --git a/src/Tools/Console/ConsoleRunner.php b/src/Tools/Console/ConsoleRunner.php index 63543c7980e..f45dc2163c3 100644 --- a/src/Tools/Console/ConsoleRunner.php +++ b/src/Tools/Console/ConsoleRunner.php @@ -71,6 +71,7 @@ public static function createApplication($helperSetOrProvider, array $commands = if ($helperSetOrProvider instanceof HelperSet) { $cli->setHelperSet($helperSetOrProvider); + // @phpstan-ignore new.deprecated $helperSetOrProvider = new HelperSetManagerProvider($helperSetOrProvider); } @@ -83,6 +84,7 @@ public static function createApplication($helperSetOrProvider, array $commands = public static function addCommands(Application $cli, ?EntityManagerProvider $entityManagerProvider = null): void { if ($entityManagerProvider === null) { + // @phpstan-ignore new.deprecated $entityManagerProvider = new HelperSetManagerProvider($cli->getHelperSet()); } @@ -95,6 +97,7 @@ public static function addCommands(Application $cli, ?EntityManagerProvider $ent $cli->addCommands( [ // DBAL Commands + // @phpstan-ignore new.deprecated new DBALConsole\Command\ReservedWordsCommand($connectionProvider), new DBALConsole\Command\RunSqlCommand($connectionProvider), @@ -108,11 +111,16 @@ public static function addCommands(Application $cli, ?EntityManagerProvider $ent new Command\SchemaTool\CreateCommand($entityManagerProvider), new Command\SchemaTool\UpdateCommand($entityManagerProvider), new Command\SchemaTool\DropCommand($entityManagerProvider), + // @phpstan-ignore new.deprecated new Command\EnsureProductionSettingsCommand($entityManagerProvider), + // @phpstan-ignore new.deprecated new Command\ConvertDoctrine1SchemaCommand(), + // @phpstan-ignore new.deprecated new Command\GenerateRepositoriesCommand($entityManagerProvider), + // @phpstan-ignore new.deprecated new Command\GenerateEntitiesCommand($entityManagerProvider), new Command\GenerateProxiesCommand($entityManagerProvider), + // @phpstan-ignore new.deprecated new Command\ConvertMappingCommand($entityManagerProvider), new Command\RunDqlCommand($entityManagerProvider), new Command\ValidateSchemaCommand($entityManagerProvider), diff --git a/src/Tools/Export/Driver/AnnotationExporter.php b/src/Tools/Export/Driver/AnnotationExporter.php index a543f2b26cc..1facd6735db 100644 --- a/src/Tools/Export/Driver/AnnotationExporter.php +++ b/src/Tools/Export/Driver/AnnotationExporter.php @@ -16,6 +16,8 @@ * @deprecated 2.7 This class is being removed from the ORM and won't have any replacement * * @link www.doctrine-project.org + * + * @phpstan-ignore class.extendsDeprecatedClass */ class AnnotationExporter extends AbstractExporter { diff --git a/src/Tools/Export/Driver/PhpExporter.php b/src/Tools/Export/Driver/PhpExporter.php index db7f205c6b6..8838011fe1d 100644 --- a/src/Tools/Export/Driver/PhpExporter.php +++ b/src/Tools/Export/Driver/PhpExporter.php @@ -23,6 +23,8 @@ * @deprecated 2.7 This class is being removed from the ORM and won't have any replacement * * @link www.doctrine-project.org + * + * @phpstan-ignore class.extendsDeprecatedClass */ class PhpExporter extends AbstractExporter { diff --git a/src/Tools/Export/Driver/XmlExporter.php b/src/Tools/Export/Driver/XmlExporter.php index 2c5bc05e488..e6b7a35c72d 100644 --- a/src/Tools/Export/Driver/XmlExporter.php +++ b/src/Tools/Export/Driver/XmlExporter.php @@ -21,6 +21,8 @@ * @deprecated 2.7 This class is being removed from the ORM and won't have any replacement * * @link www.doctrine-project.org + * + * @phpstan-ignore class.extendsDeprecatedClass */ class XmlExporter extends AbstractExporter { diff --git a/src/Tools/Export/Driver/YamlExporter.php b/src/Tools/Export/Driver/YamlExporter.php index 3d7285c6156..4b633f6dfbc 100644 --- a/src/Tools/Export/Driver/YamlExporter.php +++ b/src/Tools/Export/Driver/YamlExporter.php @@ -16,6 +16,8 @@ * @deprecated 2.7 This class is being removed from the ORM and won't have any replacement * * @link www.doctrine-project.org + * + * @phpstan-ignore class.extendsDeprecatedClass */ class YamlExporter extends AbstractExporter { diff --git a/src/Tools/Pagination/LimitSubqueryWalker.php b/src/Tools/Pagination/LimitSubqueryWalker.php index 9090a803457..173e65236b3 100644 --- a/src/Tools/Pagination/LimitSubqueryWalker.php +++ b/src/Tools/Pagination/LimitSubqueryWalker.php @@ -74,6 +74,7 @@ public function walkSelectStatement(SelectStatement $AST) return; } + // @phpstan-ignore method.deprecated $queryComponents = $this->_getQueryComponents(); foreach ($AST->orderByClause->orderByItems as $item) { if ($item->expression instanceof PathExpression) { diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index 532d40d82a9..262d0772598 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -84,6 +84,7 @@ public function __construct(EntityManagerInterface $em) $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); $this->schemaManager = method_exists(Connection::class, 'createSchemaManager') ? $em->getConnection()->createSchemaManager() + // @phpstan-ignore method.deprecated : $em->getConnection()->getSchemaManager(); } @@ -311,6 +312,7 @@ static function (ClassMetadata $class) use ($idMapping): bool { $table->setPrimaryKey($pkColumns); } } + // @phpstan-ignore method.deprecated } elseif ($class->isInheritanceTypeTablePerClass()) { throw NotSupported::create(); } else { @@ -412,7 +414,9 @@ static function (ClassMetadata $class) use ($idMapping): bool { return ! $asset->isInDefaultNamespace($schema->getName()); }; + // @phpstan-ignore method.deprecated if (array_filter($schema->getSequences() + $schema->getTables(), $filter) && ! $this->platform->canEmulateSchemas()) { + // @phpstan-ignore method.deprecated, new.deprecated $schema->visit(new RemoveNamespacedAssets()); } } @@ -989,10 +993,12 @@ public function getUpdateSchemaSql(array $classes, $saveMode = false) $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); if ($saveMode) { + // @phpstan-ignore method.deprecated return $schemaDiff->toSaveSql($this->platform); } if (! method_exists(AbstractPlatform::class, 'getAlterSchemaSQL')) { + // @phpstan-ignore method.deprecated return $schemaDiff->toSql($this->platform); } From d80a83115745df300ff093f225dde946de36d180 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 9 Oct 2024 14:48:42 +0200 Subject: [PATCH 7/7] Stop recommending vendor-prefixed PHPDoc (#11640) --- docs/en/reference/metadata-drivers.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/en/reference/metadata-drivers.rst b/docs/en/reference/metadata-drivers.rst index 98897bd86f8..a3718cbc838 100644 --- a/docs/en/reference/metadata-drivers.rst +++ b/docs/en/reference/metadata-drivers.rst @@ -81,8 +81,8 @@ implements the ``MappingDriver`` interface: /** * Loads the metadata for the specified class into the provided container. * - * @psalm-param class-string $className - * @psalm-param ClassMetadata $metadata + * @param class-string $className + * @param ClassMetadata $metadata * * @return void * @@ -93,8 +93,7 @@ implements the ``MappingDriver`` interface: /** * Gets the names of all mapped classes known to this driver. * - * @return array The names of all mapped classes known to this driver. - * @psalm-return list + * @return list The names of all mapped classes known to this driver. */ public function getAllClassNames(); @@ -102,7 +101,7 @@ implements the ``MappingDriver`` interface: * Returns whether the class with the specified name should have its metadata loaded. * This is only the case if it is either mapped as an Entity or a MappedSuperclass. * - * @psalm-param class-string $className + * @param class-string $className * * @return bool */