Skip to content

Commit

Permalink
Merge branch '3.3.x' into GH-8471-RevertPartialObjects2
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Oct 12, 2024
2 parents f5fb400 + 5f39343 commit e2b971d
Show file tree
Hide file tree
Showing 39 changed files with 164 additions and 138 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
dbal-version:
- "default"
- "3.7"
Expand Down Expand Up @@ -107,6 +108,7 @@ jobs:
php-version:
- "8.2"
- "8.3"
- "8.4"
dbal-version:
- "default"
- "3.7"
Expand Down Expand Up @@ -180,6 +182,7 @@ jobs:
php-version:
- "8.2"
- "8.3"
- "8.4"
dbal-version:
- "default"
- "3.7"
Expand Down Expand Up @@ -246,6 +249,7 @@ jobs:
php-version:
- "8.2"
- "8.3"
- "8.4"
dbal-version:
- "default"
- "3.7"
Expand Down
14 changes: 14 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,11 +733,25 @@ Use `toIterable()` instead.

# 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
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
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -39,7 +40,9 @@
"doctrine/coding-standard": "^12.0",
"phpbench/phpbench": "^1.0",
"phpdocumentor/guides-cli": "^1.4",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "1.12.6",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpunit/phpunit": "^10.4.0",
"psr/log": "^1 || ^2 || ^3",
"squizlabs/php_codesniffer": "3.7.2",
Expand Down
9 changes: 4 additions & 5 deletions docs/en/reference/metadata-drivers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ implements the ``MappingDriver`` interface:
/**
* Loads the metadata for the specified class into the provided container.
*
* @psalm-param class-string<T> $className
* @psalm-param ClassMetadata<T> $metadata
* @param class-string<T> $className
* @param ClassMetadata<T> $metadata
*
* @return void
*
Expand All @@ -82,16 +82,15 @@ implements the ``MappingDriver`` interface:
/**
* Gets the names of all mapped classes known to this driver.
*
* @return array<int, string> The names of all mapped classes known to this driver.
* @psalm-return list<class-string>
* @return list<class-string> The names of all mapped classes known to this driver.
*/
public function getAllClassNames();
/**
* 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
*/
Expand Down
7 changes: 7 additions & 0 deletions phpstan-dbal3.neon
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ parameters:
message: '#Negated boolean expression is always false\.#'
paths:
- src/Mapping/Driver/AttributeDriver.php

-
message: '~^Call to deprecated method getEventManager\(\) of class Doctrine\\DBAL\\Connection\.$~'
path: src/EntityManager.php
-
message: '~deprecated class Doctrine\\DBAL\\Tools\\Console\\Command\\ReservedWordsCommand\:~'
path: src/Tools/Console/ConsoleRunner.php
2 changes: 1 addition & 1 deletion src/Cache/CollectionCacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class CollectionCacheKey extends CacheKey
public readonly array $ownerIdentifier;

/**
* @param class-string $entityClass The owner entity class.
* @param array<string, mixed> $ownerIdentifier The identifier of the owning entity.
* @param class-string $entityClass The owner entity class
*/
public function __construct(
public readonly string $entityClass,
Expand Down
4 changes: 2 additions & 2 deletions src/Cache/EntityCacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class EntityCacheEntry implements CacheEntry
{
/**
* @param array<string,mixed> $data The entity map data
* @psalm-param class-string $class The entity class name
* @param class-string $class The entity class name
* @param array<string,mixed> $data The entity map data
*/
public function __construct(
public readonly string $class,
Expand Down
26 changes: 12 additions & 14 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ public function getCustomNumericFunction(string $name): string|callable|null
*
* Any previously added numeric functions are discarded.
*
* @psalm-param array<string, class-string> $functions The map of custom
* DQL numeric functions.
* @param array<string, class-string> $functions The map of custom
* DQL numeric functions.
*/
public function setCustomNumericFunctions(array $functions): void
{
Expand All @@ -291,7 +291,7 @@ public function addCustomDatetimeFunction(string $name, string|callable $classNa
/**
* Gets the implementation class name of a registered custom date/time DQL function.
*
* @psalm-return class-string|callable|null
* @return class-string|callable|null
*/
public function getCustomDatetimeFunction(string $name): string|callable|null
{
Expand Down Expand Up @@ -351,7 +351,7 @@ public function setCustomHydrationModes(array $modes): void
/**
* Gets the hydrator class for the given hydration mode name.
*
* @psalm-return class-string<AbstractHydrator>|null
* @return class-string<AbstractHydrator>|null
*/
public function getCustomHydrationMode(string $modeName): string|null
{
Expand All @@ -361,7 +361,7 @@ public function getCustomHydrationMode(string $modeName): string|null
/**
* Adds a custom hydration mode.
*
* @psalm-param class-string<AbstractHydrator> $hydrator
* @param class-string<AbstractHydrator> $hydrator
*/
public function addCustomHydrationMode(string $modeName, string $hydrator): void
{
Expand All @@ -371,14 +371,14 @@ public function addCustomHydrationMode(string $modeName, string $hydrator): void
/**
* Sets a class metadata factory.
*
* @psalm-param class-string $cmfName
* @param class-string $cmfName
*/
public function setClassMetadataFactoryName(string $cmfName): void
{
$this->attributes['classMetadataFactoryName'] = $cmfName;
}

/** @psalm-return class-string */
/** @return class-string */
public function getClassMetadataFactoryName(): string
{
if (! isset($this->attributes['classMetadataFactoryName'])) {
Expand All @@ -391,8 +391,7 @@ public function getClassMetadataFactoryName(): string
/**
* Adds a filter to the list of possible filters.
*
* @param string $className The class name of the filter.
* @psalm-param class-string<SQLFilter> $className
* @param class-string<SQLFilter> $className The class name of the filter.
*/
public function addFilter(string $name, string $className): void
{
Expand All @@ -402,9 +401,8 @@ public function addFilter(string $name, string $className): void
/**
* Gets the class name for a given filter name.
*
* @return string|null The class name of the filter, or null if it is not
* defined.
* @psalm-return class-string<SQLFilter>|null
* @return class-string<SQLFilter>|null The class name of the filter,
* or null if it is not defined.
*/
public function getFilterClassName(string $name): string|null
{
Expand All @@ -414,7 +412,7 @@ public function getFilterClassName(string $name): string|null
/**
* Sets default repository class.
*
* @psalm-param class-string<EntityRepository> $className
* @param class-string<EntityRepository> $className
*
* @throws InvalidEntityRepository If $classname is not an ObjectRepository.
*/
Expand All @@ -430,7 +428,7 @@ public function setDefaultRepositoryClassName(string $className): void
/**
* Get default repository class.
*
* @psalm-return class-string<EntityRepository>
* @return class-string<EntityRepository>
*/
public function getDefaultRepositoryClassName(): string
{
Expand Down
4 changes: 2 additions & 2 deletions src/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ public function lock(object $entity, LockMode|int $lockMode, DateTimeInterface|i
/**
* Gets the repository for an entity class.
*
* @psalm-param class-string<T> $className
* @param class-string<T> $className The name of the entity.
*
* @psalm-return EntityRepository<T>
* @return EntityRepository<T> The repository class.
*
* @template T of object
*/
Expand Down
13 changes: 6 additions & 7 deletions src/EntityManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ interface EntityManagerInterface extends ObjectManager
/**
* {@inheritDoc}
*
* @psalm-param class-string<T> $className
* @param class-string<T> $className
*
* @psalm-return EntityRepository<T>
* @return EntityRepository<T>
*
* @template T of object
*/
Expand Down Expand Up @@ -151,11 +151,10 @@ public function refresh(object $object, LockMode|int|null $lockMode = null): voi
* 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<T> $entityName
* @param class-string<T> $entityName The name of the entity type.
* @param mixed $id The entity identifier.
*
* @psalm-return T|null
* @return T|null The entity reference.
*
* @throws ORMException
*
Expand Down Expand Up @@ -232,7 +231,7 @@ public function hasFilters(): bool;
/**
* {@inheritDoc}
*
* @psalm-param string|class-string<T> $className
* @param string|class-string<T> $className
*
* @psalm-return ($className is class-string<T> ? Mapping\ClassMetadata<T> : Mapping\ClassMetadata<object>)
*
Expand Down
6 changes: 3 additions & 3 deletions src/EntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
*/
class EntityRepository implements ObjectRepository, Selectable
{
/** @psalm-var class-string<T> */
/** @var class-string<T> */
private readonly string $entityName;
private static Inflector|null $inflector = null;

/** @psalm-param ClassMetadata<T> $class */
/** @param ClassMetadata<T> $class */
public function __construct(
private readonly EntityManagerInterface $em,
private readonly ClassMetadata $class,
Expand Down Expand Up @@ -169,7 +169,7 @@ public function __call(string $method, array $arguments): mixed
));
}

/** @psalm-return class-string<T> */
/** @return class-string<T> */
protected function getEntityName(): string
{
return $this->entityName;
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Hydration/ObjectHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private function getEntity(array $data, string $dqlAlias): object
}

/**
* @psalm-param class-string $className
* @param class-string $className
* @psalm-param array<string, mixed> $data
*/
private function getEntityFromIdentityMap(string $className, array $data): object|bool
Expand Down
4 changes: 2 additions & 2 deletions src/Mapping/Builder/ClassMetadataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public function setSingleTableInheritance(): static
/**
* Sets the discriminator column details.
*
* @psalm-param class-string<BackedEnum>|null $enumType
* @psalm-param array<string, mixed> $options
* @param class-string<BackedEnum>|null $enumType
* @param array<string, mixed> $options
*
* @return $this
*/
Expand Down
8 changes: 6 additions & 2 deletions src/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ public function isNullable(string $fieldName): bool
*/
public function getColumnName(string $fieldName): string
{
// @phpstan-ignore property.deprecated
return $this->columnNames[$fieldName] ?? $fieldName;
}

Expand Down Expand Up @@ -1188,6 +1189,7 @@ protected function validateAndCompleteFieldMapping(array $mapping): FieldMapping
$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)) {
Expand Down Expand Up @@ -1768,6 +1770,7 @@ public function setAttributeOverride(string $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);
Expand Down Expand Up @@ -1918,8 +1921,9 @@ public function addInheritedAssociationMapping(AssociationMapping $mapping/*, $o
public function addInheritedFieldMapping(FieldMapping $fieldMapping): void
{
$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;
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/DefaultEntityListenerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class DefaultEntityListenerResolver implements EntityListenerResolver
{
/** @psalm-var array<class-string, object> Map to store entity listener instances. */
/** @var array<class-string, object> Map to store entity listener instances. */
private array $instances = [];

public function clear(string|null $className = null): void
Expand Down
4 changes: 2 additions & 2 deletions src/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public function isTransient(string $className): bool
/**
* {@inheritDoc}
*
* @psalm-param class-string<T> $className
* @psalm-param ClassMetadata<T> $metadata
* @param class-string<T> $className
* @param ClassMetadata<T> $metadata
*
* @template T of object
*/
Expand Down
Loading

0 comments on commit e2b971d

Please sign in to comment.