From 91709c12751598bb44afe132ebe4620a0e207792 Mon Sep 17 00:00:00 2001 From: Max Mustermann Date: Sat, 5 Oct 2024 13:40:04 +0200 Subject: [PATCH 1/9] 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 04be655188..2c17ca33c9 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 c37841210f..c3193686c5 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/9] 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 c6c3cb752a..e5e887a583 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/9] 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 eb2db60674..5b8ec4048f 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/9] 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 6f0a73dd5a..3905f4fc1f 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 b9473bebb6..0d2d23f6ae 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 3780a5d44a..881fabe28d 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/9] 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 e20a8fef89..9ffc7d0f3e 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/9] 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 5d2272ad0d..68d8961f52 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 98cba7badc..b6ad21dc1e 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 931876129c..9cf17979fb 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 7532681580..731e6b621b 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 46b0624f5e..a87afb9b95 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 3a452a6e82..8100b2d692 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 a6c932724f..32adbd16bd 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 c8007e40ae..889479aa32 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 f7d47d7b12..0e52f1934e 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 6365f360db..466bd019e0 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 49773f8b79..f7074f5f22 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 8e105a5743..d6b2afa728 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 927f3c3487..448292b609 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 5554ef3d75..96c7f82fde 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 042b737983..b2fb51bd99 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 716a82cc7b..153f69cbfb 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 55962b515c..5e54fa372c 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 2da3766f38..809697e825 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 249b0c6f66..af02ca2b77 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 652db84129..cce88a1588 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 4134ca097c..63bcecec7a 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 881fabe28d..b0da6e31f4 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 f2c2aad4fa..78404e88dd 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 1e14836833..f1537522e8 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 30f3348c19..c1fb4bd538 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 c993a2ba79..036b2f35d0 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 979d503174..48b491c0bd 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 1d6a47855f..2b2b842ea4 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 dc8a72bfce..aaf51e19fe 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 a9be33b4da..2654e04b0c 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 10fda3adbf..5139fefba1 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 735b3d3c6a..12d3aa61df 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 fa4c85eacf..0f0eb6a531 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 ec8ad481d7..45277413e2 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 69c329fe59..0c6050c3b5 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 3f4dee0096..0de508279c 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 a76cd4e45a..8852c8eef8 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 4d9776ccd7..c705c52bf2 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 deb67b6b29..b99c05b44e 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 bdce5adfe4..8468251b14 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 b79916bfab..b61a55e0fe 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 63543c7980..f45dc2163c 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 a543f2b26c..1facd6735d 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 db7f205c6b..8838011fe1 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 2c5bc05e48..e6b7a35c72 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 3d7285c615..4b633f6dfb 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 9090a80345..173e65236b 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 532d40d82a..262d077259 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/9] 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 98897bd86f..a3718cbc83 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 */ From 896c65504d8bfba1cdcf58ee9a9946f171400baa Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 9 Oct 2024 16:12:41 +0200 Subject: [PATCH 8/9] Deprecate the `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()` method (#11641) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We use this method only from within one of our own test cases, and I don't see how it would be useful to anybody else outside – it has to be called on the `Parser` instance which exists internally in the `Query` only. Deprecating and removing it in 3.x allows for a slight simplification in the `Parser` there, since we do no longer need the field (it can be a local variable). --- UPGRADE.md | 6 ++++++ src/Query/Parser.php | 7 +++++++ tests/Tests/ORM/Query/LanguageRecognitionTest.php | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 9ffc7d0f3e..a42be6a437 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -13,6 +13,12 @@ Progress on this is tracked at https://github.com/doctrine/orm/issues/11624 . Use of the PARTIAL keyword is not deprecated anymore in DQL when used with a hydrator that is not creating entities, such as the ArrayHydrator. +## Deprecate `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()` + +Use the `\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER` query hint to set the output walker +class instead of setting it through the `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()` method +on the parser instance. + # Upgrade to 2.19 ## Deprecate calling `ClassMetadata::getAssociationMappedByTargetField()` with the owning side of an association diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 8852c8eef8..7d0a0176f4 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -200,6 +200,13 @@ public function __construct(Query $query) */ public function setCustomOutputTreeWalker($className) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11641', + '%s is deprecated, set the output walker class with the \Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER query hint instead', + __METHOD__ + ); + $this->customOutputWalker = $className; } diff --git a/tests/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Tests/ORM/Query/LanguageRecognitionTest.php index a2e0e60096..37aac27f26 100644 --- a/tests/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Tests/ORM/Query/LanguageRecognitionTest.php @@ -51,7 +51,7 @@ public function parseDql(string $dql, array $hints = []): ParserResult $parser = new Query\Parser($query); // We do NOT test SQL output here. That only unnecessarily slows down the tests! - $parser->setCustomOutputTreeWalker(NullSqlWalker::class); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, NullSqlWalker::class); return $parser->parse(); } From 488a5dd3bf53be0531e6db2093cfe9e937455946 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 9 Oct 2024 21:58:37 +0200 Subject: [PATCH 9/9] Remove vendor prefix of PHPDoc referencing class-string (#11643) --- psalm-baseline.xml | 2 +- src/Cache/AssociationCacheEntry.php | 6 +-- src/Cache/CollectionCacheKey.php | 6 +-- src/Cache/EntityCacheEntry.php | 6 +-- src/Cache/EntityCacheKey.php | 6 +-- .../AbstractCollectionPersister.php | 5 +-- src/Configuration.php | 40 ++++++----------- src/Decorator/EntityManagerDecorator.php | 2 +- src/EntityManager.php | 27 +++++------ src/EntityManagerInterface.php | 22 ++++----- src/EntityRepository.php | 8 +--- src/Internal/Hydration/ObjectHydrator.php | 2 +- src/Mapping/Builder/ClassMetadataBuilder.php | 10 ++--- src/Mapping/ClassMetadataFactory.php | 8 ++-- src/Mapping/ClassMetadataInfo.php | 30 +++++-------- src/Mapping/DefaultEntityListenerResolver.php | 2 +- src/Mapping/Driver/AnnotationDriver.php | 9 ++-- src/Mapping/Driver/AttributeDriver.php | 4 +- src/Mapping/Driver/DatabaseDriver.php | 6 +-- src/Mapping/Driver/XmlDriver.php | 10 ++--- src/Mapping/Driver/YamlDriver.php | 4 +- src/Mapping/Entity.php | 3 +- src/Mapping/MappedSuperclass.php | 5 +-- .../Reflection/ReflectionPropertiesGetter.php | 5 +-- src/Query/Parser.php | 14 +++--- src/Query/ResultSetMapping.php | 45 +++++++++---------- src/Query/ResultSetMappingBuilder.php | 29 +++++------- src/Query/TreeWalkerChain.php | 6 +-- src/Query/TreeWalkerChainIterator.php | 5 +-- .../Command/MappingDescribeCommand.php | 3 +- src/Tools/ConvertDoctrine1Schema.php | 4 +- src/Tools/EntityRepositoryGenerator.php | 8 ++-- src/Tools/Pagination/Paginator.php | 2 +- src/UnitOfWork.php | 25 +++++------ .../Mapping/class-metadata-constructor.php | 4 +- tests/StaticAnalysis/get-metadata.php | 11 ++--- .../ORM/Functional/DatabaseDriverTestCase.php | 2 +- .../ORM/Functional/PostLoadEventTest.php | 2 +- .../ORM/Functional/Ticket/DDC1884Test.php | 4 +- .../ORM/Mapping/AnnotationDriverTest.php | 4 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 8 ++-- .../ORM/Mapping/MappingDriverTestCase.php | 2 +- .../DefaultRepositoryFactoryTest.php | 5 +-- .../MockBuilderCompatibilityTools.php | 6 +-- tests/Tests/TestUtil.php | 4 +- 45 files changed, 175 insertions(+), 246 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 0d2d23f6ae..2d96702abe 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -305,7 +305,7 @@ loadById($sortedId)]]> - + diff --git a/src/Cache/AssociationCacheEntry.php b/src/Cache/AssociationCacheEntry.php index f10618fb2b..2e4fc61491 100644 --- a/src/Cache/AssociationCacheEntry.php +++ b/src/Cache/AssociationCacheEntry.php @@ -21,15 +21,13 @@ class AssociationCacheEntry implements CacheEntry * The entity class name * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string - * @psalm-var class-string + * @var class-string */ public $class; /** - * @param string $class The entity class. + * @param class-string $class The entity class. * @param array $identifier The entity identifier. - * @psalm-param class-string $class */ public function __construct($class, array $identifier) { diff --git a/src/Cache/CollectionCacheKey.php b/src/Cache/CollectionCacheKey.php index 4475bfd393..56bf8df722 100644 --- a/src/Cache/CollectionCacheKey.php +++ b/src/Cache/CollectionCacheKey.php @@ -26,8 +26,7 @@ class CollectionCacheKey extends CacheKey * The owner entity class * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string - * @psalm-var class-string + * @var class-string */ public $entityClass; @@ -40,10 +39,9 @@ class CollectionCacheKey extends CacheKey public $association; /** - * @param string $entityClass The entity class. + * @param class-string $entityClass The entity class. * @param string $association The field name that represents the association. * @param array $ownerIdentifier The identifier of the owning entity. - * @psalm-param class-string $entityClass */ public function __construct($entityClass, $association, array $ownerIdentifier) { diff --git a/src/Cache/EntityCacheEntry.php b/src/Cache/EntityCacheEntry.php index 6a769111c4..4038227055 100644 --- a/src/Cache/EntityCacheEntry.php +++ b/src/Cache/EntityCacheEntry.php @@ -25,15 +25,13 @@ class EntityCacheEntry implements CacheEntry * The entity class name * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string - * @psalm-var class-string + * @var class-string */ public $class; /** - * @param string $class The entity class. + * @param class-string $class The entity class. * @param array $data The entity data. - * @psalm-param class-string $class */ public function __construct($class, array $data) { diff --git a/src/Cache/EntityCacheKey.php b/src/Cache/EntityCacheKey.php index 3f22f4b391..3087286401 100644 --- a/src/Cache/EntityCacheKey.php +++ b/src/Cache/EntityCacheKey.php @@ -26,15 +26,13 @@ class EntityCacheKey extends CacheKey * The entity class name * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string - * @psalm-var class-string + * @var class-string */ public $entityClass; /** - * @param string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class. + * @param class-string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class. * @param array $identifier The entity identifier - * @psalm-param class-string $entityClass */ public function __construct($entityClass, array $identifier) { diff --git a/src/Cache/Persister/Collection/AbstractCollectionPersister.php b/src/Cache/Persister/Collection/AbstractCollectionPersister.php index ad81823b84..4eb1895bbc 100644 --- a/src/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/src/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -254,9 +254,8 @@ protected function evictCollectionCache(PersistentCollection $collection) /** * @deprecated This method is not used anymore. * - * @param string $targetEntity - * @param object $element - * @psalm-param class-string $targetEntity + * @param class-string $targetEntity + * @param object $element * * @return void */ diff --git a/src/Configuration.php b/src/Configuration.php index 32adbd16bd..7e05c461d8 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -687,8 +687,7 @@ public function addCustomNumericFunction($name, $className) * * @param string $name * - * @return string|callable|null - * @psalm-return class-string|callable|null + * @return class-string|callable|null */ public function getCustomNumericFunction($name) { @@ -705,7 +704,7 @@ public function getCustomNumericFunction($name) * * Any previously added numeric functions are discarded. * - * @psalm-param array $functions The map of custom + * @param array $functions The map of custom * DQL numeric functions. * * @return void @@ -740,8 +739,7 @@ public function addCustomDatetimeFunction($name, $className) * * @param string $name * - * @return string|callable|null - * @psalm-return class-string|callable|null + * @return class-string|callable|null */ public function getCustomDatetimeFunction($name) { @@ -807,8 +805,7 @@ public function setCustomHydrationModes($modes) * * @param string $modeName The hydration mode name. * - * @return string|null The hydrator class name. - * @psalm-return class-string|null + * @return class-string|null The hydrator class name. */ public function getCustomHydrationMode($modeName) { @@ -818,9 +815,8 @@ public function getCustomHydrationMode($modeName) /** * Adds a custom hydration mode. * - * @param string $modeName The hydration mode name. - * @param string $hydrator The hydrator class name. - * @psalm-param class-string $hydrator + * @param string $modeName The hydration mode name. + * @param class-string $hydrator The hydrator class name. * * @return void */ @@ -832,8 +828,7 @@ public function addCustomHydrationMode($modeName, $hydrator) /** * Sets a class metadata factory. * - * @param string $cmfName - * @psalm-param class-string $cmfName + * @param class-string $cmfName * * @return void */ @@ -842,10 +837,7 @@ public function setClassMetadataFactoryName($cmfName) $this->_attributes['classMetadataFactoryName'] = $cmfName; } - /** - * @return string - * @psalm-return class-string - */ + /** @return class-string */ public function getClassMetadataFactoryName() { if (! isset($this->_attributes['classMetadataFactoryName'])) { @@ -858,9 +850,8 @@ public function getClassMetadataFactoryName() /** * Adds a filter to the list of possible filters. * - * @param string $name The name of the filter. - * @param string $className The class name of the filter. - * @psalm-param class-string $className + * @param string $name The name of the filter. + * @param class-string $className The class name of the filter. * * @return void */ @@ -874,9 +865,8 @@ public function addFilter($name, $className) * * @param string $name The name of the filter. * - * @return string|null The class name of the filter, or null if it is not - * defined. - * @psalm-return class-string|null + * @return class-string|null The class name of the filter, + * or null if it is not defined. */ public function getFilterClassName($name) { @@ -886,8 +876,7 @@ public function getFilterClassName($name) /** * Sets default repository class. * - * @param string $className - * @psalm-param class-string $className + * @param class-string $className * * @return void * @@ -915,8 +904,7 @@ public function setDefaultRepositoryClassName($className) /** * Get default repository class. * - * @return string - * @psalm-return class-string + * @return class-string */ public function getDefaultRepositoryClassName() { diff --git a/src/Decorator/EntityManagerDecorator.php b/src/Decorator/EntityManagerDecorator.php index 889479aa32..179d5386dd 100644 --- a/src/Decorator/EntityManagerDecorator.php +++ b/src/Decorator/EntityManagerDecorator.php @@ -50,7 +50,7 @@ public function getExpressionBuilder() /** * {@inheritDoc} * - * @psalm-param class-string $className + * @param class-string $className * * @psalm-return EntityRepository * diff --git a/src/EntityManager.php b/src/EntityManager.php index 0e52f1934e..38b2ee3ce1 100644 --- a/src/EntityManager.php +++ b/src/EntityManager.php @@ -30,7 +30,6 @@ use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Repository\RepositoryFactory; use Doctrine\Persistence\Mapping\MappingException; -use Doctrine\Persistence\ObjectRepository; use InvalidArgumentException; use Throwable; @@ -407,25 +406,23 @@ public function flush($entity = null) /** * Finds an Entity by its identifier. * - * @param string $className The class name of the entity to find. - * @param mixed $id The identity of the entity to find. - * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants - * or NULL if no specific lock mode should be used - * during the search. - * @param int|null $lockVersion The version of the entity to find when using - * optimistic locking. - * @psalm-param class-string $className + * @param class-string $className The class name of the entity to find. + * @param mixed $id The identity of the entity to find. + * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants + * or NULL if no specific lock mode should be used + * during the search. + * @param int|null $lockVersion The version of the entity to find when using + * optimistic locking. * @psalm-param LockMode::*|null $lockMode * - * @return object|null The entity instance or NULL if the entity can not be found. - * @psalm-return ?T + * @return T|null The entity instance or NULL if the entity can not be found. * * @throws OptimisticLockException * @throws ORMInvalidArgumentException * @throws TransactionRequiredException * @throws ORMException * - * @template T + * @template T of object */ public function find($className, $id, $lockMode = null, $lockVersion = null) { @@ -803,11 +800,9 @@ public function lock($entity, $lockMode, $lockVersion = null) /** * Gets the repository for an entity class. * - * @param string $entityName The name of the entity. - * @psalm-param class-string $entityName + * @param class-string $entityName The name of the entity. * - * @return ObjectRepository|EntityRepository The repository class. - * @psalm-return EntityRepository + * @return EntityRepository The repository class. * * @template T of object */ diff --git a/src/EntityManagerInterface.php b/src/EntityManagerInterface.php index b3b5ddf9e1..5155d1a2a0 100644 --- a/src/EntityManagerInterface.php +++ b/src/EntityManagerInterface.php @@ -29,9 +29,9 @@ interface EntityManagerInterface extends ObjectManager /** * {@inheritDoc} * - * @psalm-param class-string $className + * @param class-string $className * - * @psalm-return EntityRepository + * @return EntityRepository * * @template T of object */ @@ -172,12 +172,10 @@ public function createQueryBuilder(); * Gets a reference to the entity identified by the given type and identifier * without actually loading it, if the entity is not yet loaded. * - * @param string $entityName The name of the entity type. - * @param mixed $id The entity identifier. - * @psalm-param class-string $entityName + * @param class-string $entityName The name of the entity type. + * @param mixed $id The entity identifier. * - * @return object|null The entity reference. - * @psalm-return T|null + * @return T|null The entity reference. * * @throws ORMException * @@ -202,12 +200,10 @@ public function getReference($entityName, $id); * * @deprecated 2.7 This method is being removed from the ORM and won't have any replacement * - * @param string $entityName The name of the entity type. - * @param mixed $identifier The entity identifier. - * @psalm-param class-string $entityName + * @param class-string $entityName The name of the entity type. + * @param mixed $identifier The entity identifier. * - * @return object|null The (partial) entity reference - * @psalm-return T|null + * @return T|null The (partial) entity reference * * @template T */ @@ -337,7 +333,7 @@ public function hasFilters(); /** * {@inheritDoc} * - * @psalm-param string|class-string $className + * @param string|class-string $className * * @return Mapping\ClassMetadata * @psalm-return ($className is class-string ? Mapping\ClassMetadata : Mapping\ClassMetadata) diff --git a/src/EntityRepository.php b/src/EntityRepository.php index 5889b5285e..b6db64f22d 100644 --- a/src/EntityRepository.php +++ b/src/EntityRepository.php @@ -42,8 +42,7 @@ class EntityRepository implements ObjectRepository, Selectable /** * @internal This property will be private in 3.0, call {@see getEntityName()} instead. * - * @var string - * @psalm-var class-string + * @var class-string */ protected $_entityName; @@ -287,10 +286,7 @@ public function __call($method, $arguments) )); } - /** - * @return string - * @psalm-return class-string - */ + /** @return class-string */ protected function getEntityName() { return $this->_entityName; diff --git a/src/Internal/Hydration/ObjectHydrator.php b/src/Internal/Hydration/ObjectHydrator.php index c01496a5ca..6c3a6594cf 100644 --- a/src/Internal/Hydration/ObjectHydrator.php +++ b/src/Internal/Hydration/ObjectHydrator.php @@ -273,7 +273,7 @@ private function getEntity(array $data, string $dqlAlias) } /** - * @psalm-param class-string $className + * @param class-string $className * @psalm-param array $data * * @return mixed diff --git a/src/Mapping/Builder/ClassMetadataBuilder.php b/src/Mapping/Builder/ClassMetadataBuilder.php index cce88a1588..182a106bda 100644 --- a/src/Mapping/Builder/ClassMetadataBuilder.php +++ b/src/Mapping/Builder/ClassMetadataBuilder.php @@ -218,11 +218,11 @@ public function setSingleTableInheritance() /** * Sets the discriminator column details. * - * @param string $name - * @param string $type - * @param int $length - * @psalm-param class-string|null $enumType - * @psalm-param array $options + * @param string $name + * @param string $type + * @param int $length + * @param class-string|null $enumType + * @param array $options * * @return $this */ diff --git a/src/Mapping/ClassMetadataFactory.php b/src/Mapping/ClassMetadataFactory.php index 63bcecec7a..d739fc7b22 100644 --- a/src/Mapping/ClassMetadataFactory.php +++ b/src/Mapping/ClassMetadataFactory.php @@ -420,7 +420,7 @@ private function peekIfIsMappedSuperclass(string $className): bool /** * Gets the lower-case short name of a class. * - * @psalm-param class-string $className + * @param class-string $className */ private function getShortName(string $className): string { @@ -850,8 +850,10 @@ protected function initializeReflection(ClassMetadataInterface $class, Reflectio */ protected function getFqcnFromAlias($namespaceAlias, $simpleClassName) { - /** @psalm-var class-string */ - return $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; + /** @var class-string $classString */ + $classString = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; + + return $classString; } /** diff --git a/src/Mapping/ClassMetadataInfo.php b/src/Mapping/ClassMetadataInfo.php index b0da6e31f4..cb17b8983d 100644 --- a/src/Mapping/ClassMetadataInfo.php +++ b/src/Mapping/ClassMetadataInfo.php @@ -257,8 +257,7 @@ class ClassMetadataInfo implements ClassMetadata /** * READ-ONLY: The name of the entity class. * - * @var string - * @psalm-var class-string + * @var class-string */ public $name; @@ -275,8 +274,7 @@ class ClassMetadataInfo implements ClassMetadata * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same * as {@link $name}. * - * @var string - * @psalm-var class-string + * @var class-string */ public $rootEntityName; @@ -300,8 +298,7 @@ class ClassMetadataInfo implements ClassMetadata * The name of the custom repository class used for the entity class. * (Optional). * - * @var string|null - * @psalm-var ?class-string + * @var class-string|null */ public $customRepositoryClassName; @@ -323,7 +320,7 @@ class ClassMetadataInfo implements ClassMetadata * READ-ONLY: The names of the parent entity classes (ancestors), starting with the * nearest one and ending with the root entity class. * - * @psalm-var list + * @var list */ public $parentClasses = []; @@ -350,7 +347,7 @@ class ClassMetadataInfo implements ClassMetadata * For subclasses of such root entities, the list can be reused/passed downwards, it only needs to * be filtered accordingly (only keep remaining subclasses) * - * @psalm-var list + * @var list */ public $subClasses = []; @@ -548,9 +545,7 @@ class ClassMetadataInfo implements ClassMetadata * * @see discriminatorColumn * - * @var array - * - * @psalm-var array + * @var array */ public $discriminatorMap = []; @@ -811,8 +806,7 @@ class ClassMetadataInfo implements ClassMetadata * Initializes a new ClassMetadata instance that will hold the object-relational mapping * metadata of the class with the given name. * - * @param string $entityName The name of the entity class the new instance is used for. - * @psalm-param class-string $entityName + * @param class-string $entityName The name of the entity class the new instance is used for. */ public function __construct($entityName, ?NamingStrategy $namingStrategy = null, ?TypedFieldMapper $typedFieldMapper = null) { @@ -2426,7 +2420,7 @@ public function setSubclasses(array $subclasses) * Assumes that the class names in the passed array are in the order: * directParent -> directParentParent -> directParentParentParent ... -> root. * - * @psalm-param list $classNames + * @param list $classNames * * @return void */ @@ -3024,8 +3018,7 @@ protected function _storeAssociationMapping(array $assocMapping) /** * Registers a custom repository class for the entity class. * - * @param string|null $repositoryClassName The class name of the custom mapper. - * @psalm-param class-string|null $repositoryClassName + * @param class-string|null $repositoryClassName The class name of the custom mapper. * * @return void */ @@ -3562,8 +3555,7 @@ public function getAssociationNames() * * @param string $assocName * - * @return string - * @psalm-return class-string + * @return class-string * * @throws InvalidArgumentException */ @@ -3883,7 +3875,7 @@ private function assertMappingOrderBy(array $mapping): void } } - /** @psalm-param class-string $class */ + /** @param class-string $class */ private function getAccessibleProperty(ReflectionService $reflService, string $class, string $field): ?ReflectionProperty { $reflectionProperty = $reflService->getAccessibleProperty($class, $field); diff --git a/src/Mapping/DefaultEntityListenerResolver.php b/src/Mapping/DefaultEntityListenerResolver.php index 8f3b409804..2658637a53 100644 --- a/src/Mapping/DefaultEntityListenerResolver.php +++ b/src/Mapping/DefaultEntityListenerResolver.php @@ -17,7 +17,7 @@ */ class DefaultEntityListenerResolver implements EntityListenerResolver { - /** @psalm-var array Map to store entity listener instances. */ + /** @var array Map to store entity listener instances. */ private $instances = []; /** diff --git a/src/Mapping/Driver/AnnotationDriver.php b/src/Mapping/Driver/AnnotationDriver.php index 5e3049f61a..26e9130be7 100644 --- a/src/Mapping/Driver/AnnotationDriver.php +++ b/src/Mapping/Driver/AnnotationDriver.php @@ -47,10 +47,7 @@ class AnnotationDriver extends CompatibilityAnnotationDriver */ protected $reader; - /** - * @var int[] - * @psalm-var array - */ + /** @var array */ protected $entityAnnotationClasses = [ Mapping\Entity::class => 1, Mapping\MappedSuperclass::class => 2, @@ -89,8 +86,8 @@ public function __construct($reader, $paths = null, bool $reportFieldsWhereDecla /** * {@inheritDoc} * - * @psalm-param class-string $className - * @psalm-param ClassMetadata $metadata + * @param class-string $className + * @param ClassMetadata $metadata * * @template T of object */ diff --git a/src/Mapping/Driver/AttributeDriver.php b/src/Mapping/Driver/AttributeDriver.php index f1537522e8..e747eab146 100644 --- a/src/Mapping/Driver/AttributeDriver.php +++ b/src/Mapping/Driver/AttributeDriver.php @@ -127,8 +127,8 @@ public function isTransient($className) /** * {@inheritDoc} * - * @psalm-param class-string $className - * @psalm-param ClassMetadata $metadata + * @param class-string $className + * @param ClassMetadata $metadata * * @template T of object */ diff --git a/src/Mapping/Driver/DatabaseDriver.php b/src/Mapping/Driver/DatabaseDriver.php index 66fadea387..70f4dd1a15 100644 --- a/src/Mapping/Driver/DatabaseDriver.php +++ b/src/Mapping/Driver/DatabaseDriver.php @@ -185,8 +185,8 @@ public function setInflector(Inflector $inflector): void /** * {@inheritDoc} * - * @psalm-param class-string $className - * @psalm-param ClassMetadata $metadata + * @param class-string $className + * @param ClassMetadata $metadata * * @template T of object */ @@ -533,7 +533,7 @@ private function getTablePrimaryKeys(Table $table): array /** * Returns the mapped class name for a table if it exists. Otherwise return "classified" version. * - * @psalm-return class-string + * @return class-string */ private function getClassNameForTable(string $tableName): string { diff --git a/src/Mapping/Driver/XmlDriver.php b/src/Mapping/Driver/XmlDriver.php index 036b2f35d0..8a607676e2 100644 --- a/src/Mapping/Driver/XmlDriver.php +++ b/src/Mapping/Driver/XmlDriver.php @@ -73,8 +73,8 @@ public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENS /** * {@inheritDoc} * - * @psalm-param class-string $className - * @psalm-param ClassMetadata $metadata + * @param class-string $className + * @param ClassMetadata $metadata * * @template T of object */ @@ -971,19 +971,19 @@ protected function loadMappingFile($file) if (isset($xmlElement->entity)) { foreach ($xmlElement->entity as $entityElement) { - /** @psalm-var class-string $entityName */ + /** @var class-string $entityName */ $entityName = (string) $entityElement['name']; $result[$entityName] = $entityElement; } } elseif (isset($xmlElement->{'mapped-superclass'})) { foreach ($xmlElement->{'mapped-superclass'} as $mappedSuperClass) { - /** @psalm-var class-string $className */ + /** @var class-string $className */ $className = (string) $mappedSuperClass['name']; $result[$className] = $mappedSuperClass; } } elseif (isset($xmlElement->embeddable)) { foreach ($xmlElement->embeddable as $embeddableElement) { - /** @psalm-var class-string $embeddableName */ + /** @var class-string $embeddableName */ $embeddableName = (string) $embeddableElement['name']; $result[$embeddableName] = $embeddableElement; } diff --git a/src/Mapping/Driver/YamlDriver.php b/src/Mapping/Driver/YamlDriver.php index 5e24b0b3a4..97aacb2d1c 100644 --- a/src/Mapping/Driver/YamlDriver.php +++ b/src/Mapping/Driver/YamlDriver.php @@ -63,8 +63,8 @@ public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENS /** * {@inheritDoc} * - * @psalm-param class-string $className - * @psalm-param ClassMetadata $metadata + * @param class-string $className + * @param ClassMetadata $metadata * * @template T of object */ diff --git a/src/Mapping/Entity.php b/src/Mapping/Entity.php index 30f9394bfa..8f3617a427 100644 --- a/src/Mapping/Entity.php +++ b/src/Mapping/Entity.php @@ -18,8 +18,7 @@ final class Entity implements MappingAttribute { /** - * @var string|null - * @psalm-var class-string>|null + * @var class-string>|null * @readonly */ public $repositoryClass; diff --git a/src/Mapping/MappedSuperclass.php b/src/Mapping/MappedSuperclass.php index 6f3f7b3020..3a96913dc4 100644 --- a/src/Mapping/MappedSuperclass.php +++ b/src/Mapping/MappedSuperclass.php @@ -17,13 +17,12 @@ final class MappedSuperclass implements MappingAttribute { /** - * @var string|null - * @psalm-var class-string|null + * @var class-string|null * @readonly */ public $repositoryClass; - /** @psalm-param class-string|null $repositoryClass */ + /** @param class-string|null $repositoryClass */ public function __construct(?string $repositoryClass = null) { $this->repositoryClass = $repositoryClass; diff --git a/src/Mapping/Reflection/ReflectionPropertiesGetter.php b/src/Mapping/Reflection/ReflectionPropertiesGetter.php index b6a289d5e7..d787030637 100644 --- a/src/Mapping/Reflection/ReflectionPropertiesGetter.php +++ b/src/Mapping/Reflection/ReflectionPropertiesGetter.php @@ -33,8 +33,7 @@ public function __construct(ReflectionService $reflectionService) } /** - * @param string $className - * @psalm-param class-string $className + * @param class-string $className * * @return ReflectionProperty[] indexed by property internal name */ @@ -57,7 +56,7 @@ public function getProperties($className): array } /** - * @psalm-param class-string $className + * @param class-string $className * * @return ReflectionClass[] * @psalm-return list> diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 7d0a0176f4..2a95297efd 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -51,7 +51,7 @@ class Parser { /** * @readonly Maps BUILT-IN string function names to AST class names. - * @psalm-var array> + * @var array> */ private static $stringFunctions = [ 'concat' => Functions\ConcatFunction::class, @@ -64,7 +64,7 @@ class Parser /** * @readonly Maps BUILT-IN numeric function names to AST class names. - * @psalm-var array> + * @var array> */ private static $numericFunctions = [ 'length' => Functions\LengthFunction::class, @@ -87,7 +87,7 @@ class Parser /** * @readonly Maps BUILT-IN datetime function names to AST class names. - * @psalm-var array> + * @var array> */ private static $datetimeFunctions = [ 'current_date' => Functions\CurrentDateFunction::class, @@ -162,7 +162,7 @@ class Parser /** * Any additional custom tree walkers that modify the AST. * - * @psalm-var list> + * @var list> */ private $customTreeWalkers = []; @@ -193,8 +193,7 @@ public function __construct(Query $query) * Sets a custom tree walker that produces output. * This tree walker will be run last over the AST, after any other walkers. * - * @param string $className - * @psalm-param class-string $className + * @param class-string $className * * @return void */ @@ -213,8 +212,7 @@ public function setCustomOutputTreeWalker($className) /** * Adds a custom tree walker for modifying the AST. * - * @param string $className - * @psalm-param class-string $className + * @param class-string $className * * @return void */ diff --git a/src/Query/ResultSetMapping.php b/src/Query/ResultSetMapping.php index 2131f93e96..92e1d2eedc 100644 --- a/src/Query/ResultSetMapping.php +++ b/src/Query/ResultSetMapping.php @@ -41,7 +41,7 @@ class ResultSetMapping * Maps alias names to class names. * * @ignore - * @psalm-var array + * @var array */ public $aliasMap = []; @@ -137,7 +137,7 @@ class ResultSetMapping * Map from column names to class names that declare the field the column is mapped to. * * @ignore - * @psalm-var array + * @var array */ public $declaringClasses = []; @@ -172,12 +172,11 @@ class ResultSetMapping /** * Adds an entity result to this ResultSetMapping. * - * @param string $class The class name of the entity. - * @param string $alias The alias for the class. The alias must be unique among all entity - * results or joined entity results within this ResultSetMapping. - * @param string|null $resultAlias The result alias with which the entity result should be - * placed in the result structure. - * @psalm-param class-string $class + * @param class-string $class The class name of the entity. + * @param string $alias The alias for the class. The alias must be unique among all entity + * results or joined entity results within this ResultSetMapping. + * @param string|null $resultAlias The result alias with which the entity result should be + * placed in the result structure. * * @return $this * @@ -316,15 +315,14 @@ public function isFieldResult($columnName) /** * Adds a field to the result that belongs to an entity or joined entity. * - * @param string $alias The alias of the root entity or joined entity to which the field belongs. - * @param string $columnName The name of the column in the SQL result set. - * @param string $fieldName The name of the field on the declaring class. - * @param string|null $declaringClass The name of the class that declares/owns the specified field. - * When $alias refers to a superclass in a mapped hierarchy but - * the field $fieldName is defined on a subclass, specify that here. - * If not specified, the field is assumed to belong to the class - * designated by $alias. - * @psalm-param class-string|null $declaringClass + * @param string $alias The alias of the root entity or joined entity to which the field belongs. + * @param string $columnName The name of the column in the SQL result set. + * @param string $fieldName The name of the field on the declaring class. + * @param class-string|null $declaringClass The name of the class that declares/owns the specified field. + * When $alias refers to a superclass in a mapped hierarchy but + * the field $fieldName is defined on a subclass, specify that here. + * If not specified, the field is assumed to belong to the class + * designated by $alias. * * @return $this * @@ -349,12 +347,11 @@ public function addFieldResult($alias, $columnName, $fieldName, $declaringClass /** * Adds a joined entity result. * - * @param string $class The class name of the joined entity. - * @param string $alias The unique alias to use for the joined entity. - * @param string $parentAlias The alias of the entity result that is the parent of this joined result. - * @param string $relation The association field that connects the parent entity result - * with the joined entity result. - * @psalm-param class-string $class + * @param class-string $class The class name of the joined entity. + * @param string $alias The unique alias to use for the joined entity. + * @param string $parentAlias The alias of the entity result that is the parent of this joined result. + * @param string $relation The association field that connects the parent entity result + * with the joined entity result. * * @return $this * @@ -539,7 +536,7 @@ public function getFieldName($columnName) return $this->fieldMappings[$columnName]; } - /** @psalm-return array */ + /** @return array */ public function getAliasMap() { return $this->aliasMap; diff --git a/src/Query/ResultSetMappingBuilder.php b/src/Query/ResultSetMappingBuilder.php index 8002df787b..93bc7dc26d 100644 --- a/src/Query/ResultSetMappingBuilder.php +++ b/src/Query/ResultSetMappingBuilder.php @@ -77,12 +77,10 @@ public function __construct(EntityManagerInterface $em, $defaultRenameMode = sel /** * Adds a root entity and all of its fields to the result set. * - * @param string $class The class name of the root entity. - * @param string $alias The unique alias to use for the root entity. - * @param string[] $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). - * @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). - * @psalm-param class-string $class - * @psalm-param array $renamedColumns + * @param class-string $class The class name of the root entity. + * @param string $alias The unique alias to use for the root entity. + * @param array $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). + * @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). * @psalm-param self::COLUMN_RENAMING_*|null $renameMode * * @return void @@ -99,15 +97,13 @@ public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = /** * Adds a joined entity and all of its fields to the result set. * - * @param string $class The class name of the joined entity. - * @param string $alias The unique alias to use for the joined entity. - * @param string $parentAlias The alias of the entity result that is the parent of this joined result. - * @param string $relation The association field that connects the parent entity result - * with the joined entity result. - * @param string[] $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). - * @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). - * @psalm-param class-string $class - * @psalm-param array $renamedColumns + * @param class-string $class The class name of the joined entity. + * @param string $alias The unique alias to use for the joined entity. + * @param string $parentAlias The alias of the entity result that is the parent of this joined result. + * @param string $relation The association field that connects the parent entity result + * with the joined entity result. + * @param array $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). + * @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). * @psalm-param self::COLUMN_RENAMING_*|null $renameMode * * @return void @@ -228,12 +224,11 @@ private function getColumnAlias(string $columnName, int $mode, array $customRena * * This depends on the renaming mode selected by the user. * - * @psalm-param class-string $className + * @param class-string $className * @psalm-param self::COLUMN_RENAMING_* $mode * @psalm-param array $customRenameColumns * * @return string[] - * @psalm-return array */ private function getColumnAliasMap( string $className, diff --git a/src/Query/TreeWalkerChain.php b/src/Query/TreeWalkerChain.php index c84f4e94d9..22655478b7 100644 --- a/src/Query/TreeWalkerChain.php +++ b/src/Query/TreeWalkerChain.php @@ -23,8 +23,7 @@ class TreeWalkerChain implements TreeWalker /** * The tree walkers. * - * @var string[] - * @psalm-var list> + * @var list> */ private $walkers = []; @@ -81,8 +80,7 @@ public function __construct($query, $parserResult, array $queryComponents) /** * Adds a tree walker to the chain. * - * @param string $walkerClass The class of the walker to instantiate. - * @psalm-param class-string $walkerClass + * @param class-string $walkerClass The class of the walker to instantiate. * * @return void */ diff --git a/src/Query/TreeWalkerChainIterator.php b/src/Query/TreeWalkerChainIterator.php index 6a41c3d477..f38f655e74 100644 --- a/src/Query/TreeWalkerChainIterator.php +++ b/src/Query/TreeWalkerChainIterator.php @@ -49,10 +49,7 @@ public function __construct(TreeWalkerChain $treeWalkerChain, $query, $parserRes $this->parserResult = $parserResult; } - /** - * @return string|false - * @psalm-return class-string|false - */ + /** @return class-string|false */ #[ReturnTypeWillChange] public function rewind() { diff --git a/src/Tools/Console/Command/MappingDescribeCommand.php b/src/Tools/Console/Command/MappingDescribeCommand.php index c467e0e100..babd432b31 100644 --- a/src/Tools/Console/Command/MappingDescribeCommand.php +++ b/src/Tools/Console/Command/MappingDescribeCommand.php @@ -131,8 +131,7 @@ private function displayEntity( /** * Return all mapped entity class names * - * @return string[] - * @psalm-return class-string[] + * @return class-string[] */ private function getMappedEntities(EntityManagerInterface $entityManager): array { diff --git a/src/Tools/ConvertDoctrine1Schema.php b/src/Tools/ConvertDoctrine1Schema.php index f54b4faece..fb89e9598a 100644 --- a/src/Tools/ConvertDoctrine1Schema.php +++ b/src/Tools/ConvertDoctrine1Schema.php @@ -91,8 +91,8 @@ public function getMetadata() } /** - * @param mixed[] $mappingInformation - * @psalm-param class-string $className + * @param class-string $className + * @param mixed[] $mappingInformation */ private function convertToClassMetadataInfo( string $className, diff --git a/src/Tools/EntityRepositoryGenerator.php b/src/Tools/EntityRepositoryGenerator.php index 97abdb3e7a..3e37ac8d00 100644 --- a/src/Tools/EntityRepositoryGenerator.php +++ b/src/Tools/EntityRepositoryGenerator.php @@ -31,7 +31,7 @@ */ class EntityRepositoryGenerator { - /** @psalm-var class-string|null */ + /** @var class-string|null */ private $repositoryName; /** @var string */ @@ -80,7 +80,7 @@ public function generateEntityRepositoryClass($fullClassName) /** * Generates the namespace, if class do not have namespace, return empty string instead. * - * @psalm-param class-string $fullClassName + * @param class-string $fullClassName */ private function getClassNamespace(string $fullClassName): string { @@ -90,7 +90,7 @@ private function getClassNamespace(string $fullClassName): string /** * Generates the class name * - * @psalm-param class-string $fullClassName + * @param class-string $fullClassName */ private function generateClassName(string $fullClassName): string { @@ -108,7 +108,7 @@ private function generateClassName(string $fullClassName): string /** * Generates the namespace statement, if class do not have namespace, return empty string instead. * - * @psalm-param class-string $fullClassName The full repository class name. + * @param class-string $fullClassName The full repository class name. */ private function generateEntityRepositoryNamespace(string $fullClassName): string { diff --git a/src/Tools/Pagination/Paginator.php b/src/Tools/Pagination/Paginator.php index ca41360ec6..6e5e87a10e 100644 --- a/src/Tools/Pagination/Paginator.php +++ b/src/Tools/Pagination/Paginator.php @@ -209,7 +209,7 @@ private function useOutputWalker(Query $query): bool /** * Appends a custom tree walker to the tree walkers hint. * - * @psalm-param class-string $walkerClass + * @param class-string $walkerClass */ private function appendTreeWalker(Query $query, string $walkerClass): void { diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index fa51983e30..b5945ff016 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -127,8 +127,7 @@ class UnitOfWork implements PropertyChangedListener * Since all classes in a hierarchy must share the same identifier set, * we always take the root class name of the hierarchy. * - * @var mixed[] - * @psalm-var array> + * @var array> */ private $identityMap = []; @@ -175,7 +174,7 @@ class UnitOfWork implements PropertyChangedListener * This is only used for entities with a change tracking policy of DEFERRED_EXPLICIT. * Keys are object ids (spl_object_id). * - * @psalm-var array> + * @var array> */ private $scheduledForSynchronization = []; @@ -313,7 +312,7 @@ class UnitOfWork implements PropertyChangedListener /** * Map of Entity Class-Names and corresponding IDs that should eager loaded when requested. * - * @psalm-var array> + * @var array> */ private $eagerLoadingEntities = []; @@ -2907,11 +2906,9 @@ private function newInstance(ClassMetadata $class) * * Internal note: Highly performance-sensitive method. * - * @param string $className The name of the entity class. - * @param mixed[] $data The data for the entity. - * @param mixed[] $hints Any hints to account for during reconstitution/lookup of the entity. - * @psalm-param class-string $className - * @psalm-param array $hints + * @param class-string $className The name of the entity class. + * @param mixed[] $data The data for the entity. + * @param array $hints Any hints to account for during reconstitution/lookup of the entity. * * @return object The managed entity instance. * @@ -3349,7 +3346,7 @@ private function scheduleCollectionForBatchLoading(PersistentCollection $collect /** * Gets the identity map of the UnitOfWork. * - * @psalm-return array> + * @return array> */ public function getIdentityMap() { @@ -3449,9 +3446,8 @@ public function getSingleIdentifierValue($entity) * Tries to find an entity with the given identifier in the identity map of * this UnitOfWork. * - * @param mixed $id The entity identifier to look for. - * @param string $rootClassName The name of the root class of the mapped entity hierarchy. - * @psalm-param class-string $rootClassName + * @param mixed $id The entity identifier to look for. + * @param class-string $rootClassName The name of the root class of the mapped entity hierarchy. * * @return object|false Returns the entity with the specified identifier if it exists in * this UnitOfWork, FALSE otherwise. @@ -3503,8 +3499,7 @@ public function size() /** * Gets the EntityPersister for an Entity. * - * @param string $entityName The name of the Entity. - * @psalm-param class-string $entityName + * @param class-string $entityName The name of the Entity. * * @return EntityPersister */ diff --git a/tests/StaticAnalysis/Mapping/class-metadata-constructor.php b/tests/StaticAnalysis/Mapping/class-metadata-constructor.php index 0d5da39690..684d69f43d 100644 --- a/tests/StaticAnalysis/Mapping/class-metadata-constructor.php +++ b/tests/StaticAnalysis/Mapping/class-metadata-constructor.php @@ -10,9 +10,9 @@ class MetadataGenerator { /** - * @psalm-param class-string $entityName + * @param class-string $entityName * - * @psalm-return ClassMetadata + * @return ClassMetadata */ public function createMetadata(string $entityName): ClassMetadata { diff --git a/tests/StaticAnalysis/get-metadata.php b/tests/StaticAnalysis/get-metadata.php index c9b1103615..e55a438648 100644 --- a/tests/StaticAnalysis/get-metadata.php +++ b/tests/StaticAnalysis/get-metadata.php @@ -15,18 +15,15 @@ */ abstract class GetMetadata { - /** - * @param string|object $class - * @psalm-param class-string|object $class - */ + /** @param class-string|object $class */ abstract public function getEntityManager($class): EntityManagerInterface; /** - * @psalm-param class-string $class + * @param class-string $class * - * @psalm-return ClassMetadata + * @return ClassMetadata * - * @psalm-template TObject of object + * @template TObject of object */ public function __invoke(string $class): ClassMetadata { diff --git a/tests/Tests/ORM/Functional/DatabaseDriverTestCase.php b/tests/Tests/ORM/Functional/DatabaseDriverTestCase.php index 7a9039cfe1..abbf26c3ed 100644 --- a/tests/Tests/ORM/Functional/DatabaseDriverTestCase.php +++ b/tests/Tests/ORM/Functional/DatabaseDriverTestCase.php @@ -40,7 +40,7 @@ protected function convertToClassMetadata(array $entityTables, array $manyTables /** * @param string[] $classNames * - * @psalm-return array + * @return array */ protected function extractClassMetadata(array $classNames): array { diff --git a/tests/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Tests/ORM/Functional/PostLoadEventTest.php index 74518f79a1..7963ee8977 100644 --- a/tests/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Tests/ORM/Functional/PostLoadEventTest.php @@ -296,7 +296,7 @@ public function postLoad(PostLoadEventArgs $event): void class PostLoadListenerLoadEntityInEventHandler { - /** @psalm-var array */ + /** @var array */ private $firedByClasses = []; public function postLoad(PostLoadEventArgs $event): void diff --git a/tests/Tests/ORM/Functional/Ticket/DDC1884Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1884Test.php index 961b89333f..f4b4b13516 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC1884Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC1884Test.php @@ -56,7 +56,7 @@ protected function setUp(): void /** * @psalm-return array{Car, Car, Car, Car} * - * @psalm-var class-string $class + * @var class-string $class */ private function createCars(string $class): array { @@ -87,7 +87,7 @@ private function createCars(string $class): array /** * @psalm-return array{Driver, Driver} * - * @psalm-var class-string $class + * @var class-string $class */ private function createDrivers(string $class): array { diff --git a/tests/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Tests/ORM/Mapping/AnnotationDriverTest.php index 2407d01963..ae8702e915 100644 --- a/tests/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -134,7 +134,7 @@ protected function loadDriver(): MappingDriver return $this->createAnnotationDriver(); } - /** @psalm-var class-string $entityClassName */ + /** @var class-string $entityClassName */ protected function ensureIsLoaded(string $entityClassName): void { new $entityClassName(); @@ -241,7 +241,7 @@ public function testAttributeOverridesMappingWithTrait(): void } /** - * @psalm-param class-string $class + * @param class-string $class * * @dataProvider provideDiscriminatorColumnTestcases */ diff --git a/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index bb9256a776..00f85b01f5 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -561,13 +561,13 @@ final class Cube extends Shape /* Test subject class with overridden factory method for mocking purposes */ class ClassMetadataFactoryTestSubject extends ClassMetadataFactory { - /** @psalm-var array, ClassMetadata> */ + /** @var array, ClassMetadata> */ private $mockMetadata = []; - /** @psalm-var list> */ + /** @var list> */ private $requestedClasses = []; - /** @psalm-param class-string $className */ + /** @param class-string $className */ protected function newClassMetadataInstance($className): ClassMetadata { $this->requestedClasses[] = $className; @@ -581,7 +581,7 @@ protected function newClassMetadataInstance($className): ClassMetadata return $this->mockMetadata[$className]; } - /** @psalm-param class-string $className */ + /** @param class-string $className */ public function setMetadataForClass(string $className, ClassMetadata $metadata): void { $this->mockMetadata[$className] = $metadata; diff --git a/tests/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Tests/ORM/Mapping/MappingDriverTestCase.php index 316bd8a6dc..f7aa97e6a9 100644 --- a/tests/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -94,7 +94,7 @@ abstract class MappingDriverTestCase extends OrmTestCase abstract protected function loadDriver(): MappingDriver; /** - * @psalm-param class-string $entityClassName + * @param class-string $entityClassName */ public function createClassMetadata( string $entityClassName, diff --git a/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index 279cb8586c..cfc2fc4f85 100644 --- a/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -108,10 +108,9 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void } /** - * @psalm-param class-string $className + * @param class-string $className * - * @return ClassMetadata&MockObject - * @psalm-return ClassMetadata&MockObject + * @return ClassMetadata&MockObject * * @template TEntity of object */ diff --git a/tests/Tests/PHPUnitCompatibility/MockBuilderCompatibilityTools.php b/tests/Tests/PHPUnitCompatibility/MockBuilderCompatibilityTools.php index 01cdbe650a..d19d7011f9 100644 --- a/tests/Tests/PHPUnitCompatibility/MockBuilderCompatibilityTools.php +++ b/tests/Tests/PHPUnitCompatibility/MockBuilderCompatibilityTools.php @@ -11,10 +11,10 @@ trait MockBuilderCompatibilityTools { /** - * @param list $onlyMethods - * @psalm-param class-string $className + * @param class-string $className + * @param list $onlyMethods * - * @psalm-return MockBuilder + * @return MockBuilder * * @template TMockedType of object */ diff --git a/tests/Tests/TestUtil.php b/tests/Tests/TestUtil.php index 4eb0afe22c..a772924875 100644 --- a/tests/Tests/TestUtil.php +++ b/tests/Tests/TestUtil.php @@ -170,14 +170,14 @@ private static function addDbEventSubscribers(Connection $conn): void } $evm = $conn->getEventManager(); - /** @psalm-var class-string $subscriberClass */ + /** @var class-string $subscriberClass */ foreach (explode(',', $GLOBALS['db_event_subscribers']) as $subscriberClass) { $subscriberInstance = new $subscriberClass(); $evm->addEventSubscriber($subscriberInstance); } } - /** @psalm-return array */ + /** @return array */ private static function getPrivilegedConnectionParameters(): array { if (isset($GLOBALS['privileged_db_driver'])) {