diff --git a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php index 7d6b203baf9..090487b8605 100644 --- a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php @@ -23,11 +23,10 @@ class PreUpdateEventArgs extends LifecycleEventArgs private array $entityChangeSet; /** - * @param object $entity * @param mixed[][] $changeSet * @psalm-param array $changeSet */ - public function __construct($entity, EntityManagerInterface $em, array &$changeSet) + public function __construct(object $entity, EntityManagerInterface $em, array &$changeSet) { parent::__construct($entity, $em); @@ -55,10 +54,8 @@ public function hasChangedField(string $field): bool /** * Gets the old value of the changeset of the changed field. - * - * @return mixed */ - public function getOldValue(string $field) + public function getOldValue(string $field): mixed { $this->assertValidField($field); @@ -67,10 +64,8 @@ public function getOldValue(string $field) /** * Gets the new value of the changeset of the changed field. - * - * @return mixed */ - public function getNewValue(string $field) + public function getNewValue(string $field): mixed { $this->assertValidField($field); diff --git a/lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php b/lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php index 8c244cac78f..06ddd5dce20 100644 --- a/lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php +++ b/lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php @@ -11,11 +11,7 @@ final class EntityIdentityCollisionException extends Exception implements ORMException { - /** - * @param object $existingEntity - * @param object $newEntity - */ - public static function create($existingEntity, $newEntity, string $idHash): self + public static function create(object $existingEntity, object $newEntity, string $idHash): self { return new self( sprintf( diff --git a/lib/Doctrine/ORM/Internal/TopologicalSort.php b/lib/Doctrine/ORM/Internal/TopologicalSort.php index 2bf1624ced8..798d9202779 100644 --- a/lib/Doctrine/ORM/Internal/TopologicalSort.php +++ b/lib/Doctrine/ORM/Internal/TopologicalSort.php @@ -31,7 +31,7 @@ final class TopologicalSort * * @var array */ - private $nodes = []; + private array $nodes = []; /** * DFS state for the different nodes, indexed by node object id and using one of @@ -39,7 +39,7 @@ final class TopologicalSort * * @var array */ - private $states = []; + private array $states = []; /** * Edges between the nodes. The first-level key is the object id of the outgoing @@ -48,17 +48,16 @@ final class TopologicalSort * * @var array> */ - private $edges = []; + private array $edges = []; /** * Builds up the result during the DFS. * * @var list */ - private $sortResult = []; + private array $sortResult = []; - /** @param object $node */ - public function addNode($node): void + public function addNode(object $node): void { $id = spl_object_id($node); $this->nodes[$id] = $node; @@ -66,8 +65,7 @@ public function addNode($node): void $this->edges[$id] = []; } - /** @param object $node */ - public function hasNode($node): bool + public function hasNode(object $node): bool { return isset($this->nodes[spl_object_id($node)]); } @@ -75,11 +73,9 @@ public function hasNode($node): bool /** * Adds a new edge between two nodes to the graph * - * @param object $from - * @param object $to - * @param bool $optional This indicates whether the edge may be ignored during the topological sort if it is necessary to break cycles. + * @param bool $optional This indicates whether the edge may be ignored during the topological sort if it is necessary to break cycles. */ - public function addEdge($from, $to, bool $optional): void + public function addEdge(object $from, object $to, bool $optional): void { $fromId = spl_object_id($from); $toId = spl_object_id($to); diff --git a/lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php b/lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php index a2d93b954bf..c28ce561dce 100644 --- a/lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php +++ b/lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php @@ -11,17 +11,14 @@ class CycleDetectedException extends RuntimeException { /** @var list */ - private $cycle; + private array $cycle; /** * Do we have the complete cycle collected? - * - * @var bool */ - private $cycleCollected = false; + private bool $cycleCollected = false; - /** @param object $startNode */ - public function __construct(private $startNode) + public function __construct(private object $startNode) { parent::__construct('A cycle has been detected, so a topological sort is not possible. The getCycle() method provides the list of nodes that form the cycle.'); @@ -34,8 +31,7 @@ public function getCycle(): array return $this->cycle; } - /** @param object $node */ - public function addToCycle($node): void + public function addToCycle(object $node): void { array_unshift($this->cycle, $node); diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index e3a899661dc..ea78bbd6764 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -231,7 +231,7 @@ public function offsetExists(mixed $offset): bool return isset($this->$offset) || in_array($offset, ['isOwningSide', 'type'], true); } - final public function offsetGet($offset): mixed + final public function offsetGet(mixed $offset): mixed { return match ($offset) { 'isOwningSide' => $this->isOwningSide(), diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 9dd91851a7e..5a80fa67893 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -544,7 +544,7 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable * @param string $name The name of the entity class the new instance is used for. * @psalm-param class-string $name */ - public function __construct(public $name, NamingStrategy|null $namingStrategy = null, TypedFieldMapper|null $typedFieldMapper = null) + public function __construct(public string $name, NamingStrategy|null $namingStrategy = null, TypedFieldMapper|null $typedFieldMapper = null) { $this->rootEntityName = $name; $this->namingStrategy = $namingStrategy ?? new DefaultNamingStrategy(); @@ -591,11 +591,9 @@ public function getSingleIdReflectionProperty(): ReflectionProperty|null * For composite identifiers, the identifier values are returned as an array * with the same order as the field order in {@link identifier}. * - * @param object $entity - * * @return array */ - public function getIdentifierValues($entity): array + public function getIdentifierValues(object $entity): array { if ($this->isIdentifierComposite) { $id = []; @@ -676,7 +674,7 @@ public function __toString(): string * * @return string[] The names of all the fields that should be serialized. */ - public function __sleep() + public function __sleep(): array { // This metadata is always serialized/cached. $serialized = [ diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index 810eb1a020e..fe07a2ad464 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -145,8 +145,7 @@ public static function invalidAssociation(ClassMetadata $targetClass, Associatio )); } - /** @param mixed $value */ - public static function invalidAutoGenerateMode($value): self + public static function invalidAutoGenerateMode(mixed $value): self { return new self(sprintf('Invalid auto generate mode "%s" given.', is_scalar($value) ? (string) $value : get_debug_type($value))); } diff --git a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php index cd42340ff2b..03d053b220c 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php +++ b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php @@ -21,32 +21,26 @@ class CachedPersisterContext /** * The SELECT column list SQL fragment used for querying entities by this persister. * This SQL fragment is only generated once per request, if at all. - * - * @var string|null */ - public $selectColumnListSql; + public string|null $selectColumnListSql = null; /** * The JOIN SQL fragment used to eagerly load all many-to-one and one-to-one * associations configured as FETCH_EAGER, as well as all inverse one-to-one associations. - * - * @var string */ - public $selectJoinSql; + public string|null $selectJoinSql = null; /** * Counter for creating unique SQL table and column aliases. - * - * @var int */ - public $sqlAliasCounter = 0; + public int $sqlAliasCounter = 0; /** * Map from class names (FQCN) to the corresponding generated SQL table aliases. * * @var array */ - public $sqlTableAliases = []; + public array $sqlTableAliases = []; public function __construct( /** diff --git a/lib/Doctrine/ORM/Persisters/PersisterException.php b/lib/Doctrine/ORM/Persisters/PersisterException.php index 0f8fe84f54c..00164720d06 100644 --- a/lib/Doctrine/ORM/Persisters/PersisterException.php +++ b/lib/Doctrine/ORM/Persisters/PersisterException.php @@ -11,8 +11,7 @@ class PersisterException extends Exception implements ORMException { - /** @return PersisterException */ - public static function matchingAssocationFieldRequiresObject(string $class, string $associationName) + public static function matchingAssocationFieldRequiresObject(string $class, string $associationName): PersisterException { return new self(sprintf( 'Cannot match on %s::%s with a non-object value. Matching objects by id is ' . diff --git a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php index 79c495b87cc..7f987ad9815 100644 --- a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php +++ b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php @@ -73,10 +73,8 @@ public function getParamsAndTypes(): array /** * Returns the value from a Comparison. In case of a CONTAINS comparison, * the value is wrapped in %-signs, because it will be used in a LIKE clause. - * - * @return mixed */ - protected function getValueFromComparison(Comparison $comparison) + protected function getValueFromComparison(Comparison $comparison): mixed { $value = $comparison->getValue()->getValue(); diff --git a/lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php b/lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php index a9d0a3dba93..6a6fd1c9579 100644 --- a/lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php +++ b/lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php @@ -28,12 +28,8 @@ public function resolveClassName(string $className): string return substr($className, $pos + Proxy::MARKER_LENGTH + 2); } - /** - * @param object $object - * - * @return class-string - */ - public static function getClass($object): string + /** @return class-string */ + public static function getClass(object $object): string { return (new self())->resolveClassName(get_class($object)); } diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index f04bd8c6625..44f5eff70e1 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -118,9 +118,6 @@ public function __serialize(): array /** The UnitOfWork this factory uses to retrieve persisters */ private readonly UnitOfWork $uow; - /** @var string */ - private $proxyDir; - /** @var self::AUTOGENERATE_* */ private $autoGenerate; @@ -128,7 +125,7 @@ public function __serialize(): array private readonly IdentifierFlattener $identifierFlattener; /** @var array */ - private $proxyFactories = []; + private array $proxyFactories = []; /** * Initializes a new instance of the ProxyFactory class that is @@ -141,7 +138,7 @@ public function __serialize(): array */ public function __construct( private readonly EntityManagerInterface $em, - string $proxyDir, + private string $proxyDir, private readonly string $proxyNs, bool|int $autoGenerate = self::AUTOGENERATE_NEVER, ) { @@ -158,7 +155,6 @@ public function __construct( } $this->uow = $em->getUnitOfWork(); - $this->proxyDir = $proxyDir; $this->autoGenerate = (int) $autoGenerate; $this->identifierFlattener = new IdentifierFlattener($this->uow, $em->getMetadataFactory()); } @@ -186,7 +182,7 @@ public function getProxy(string $className, array $identifier) * * @return int Number of generated proxies. */ - public function generateProxyClasses(array $classes, $proxyDir = null): int + public function generateProxyClasses(array $classes, string|null $proxyDir = null): int { $generated = 0; diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php index 9268414e85f..a819e058282 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php @@ -15,8 +15,7 @@ class ArithmeticExpression extends Node { public Node|string|null $simpleArithmeticExpression = null; - /** @var Subselect|null */ - public $subselect; + public Subselect|null $subselect = null; public function isSimpleArithmeticExpression(): bool { diff --git a/lib/Doctrine/ORM/Query/AST/BetweenExpression.php b/lib/Doctrine/ORM/Query/AST/BetweenExpression.php index 24f351cbc25..c13292b741f 100644 --- a/lib/Doctrine/ORM/Query/AST/BetweenExpression.php +++ b/lib/Doctrine/ORM/Query/AST/BetweenExpression.php @@ -8,15 +8,10 @@ class BetweenExpression extends Node { - /** - * @param ArithmeticExpression $expression - * @param ArithmeticExpression $leftBetweenExpression - * @param ArithmeticExpression $rightBetweenExpression - */ public function __construct( - public $expression, - public $leftBetweenExpression, - public $rightBetweenExpression, + public ArithmeticExpression $expression, + public ArithmeticExpression $leftBetweenExpression, + public ArithmeticExpression $rightBetweenExpression, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php b/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php index b926003e21c..a62a191a712 100644 --- a/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php +++ b/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php @@ -13,10 +13,9 @@ */ class CollectionMemberExpression extends Node { - /** @param PathExpression $collectionValuedPathExpression */ public function __construct( public mixed $entityExpression, - public $collectionValuedPathExpression, + public PathExpression $collectionValuedPathExpression, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php index 2c28c461b92..a7d91f94a85 100644 --- a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php @@ -18,14 +18,10 @@ */ class ComparisonExpression extends Node { - /** - * @param Node|string $leftExpression - * @param Node|string $rightExpression - */ public function __construct( - public $leftExpression, + public Node|string $leftExpression, public string $operator, - public $rightExpression, + public Node|string $rightExpression, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php b/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php index af662cc09b2..788174340ab 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php @@ -13,9 +13,8 @@ */ class ConditionalFactor extends Node implements Phase2OptimizableConditional { - /** @param ConditionalPrimary $conditionalPrimary */ public function __construct( - public $conditionalPrimary, + public ConditionalPrimary $conditionalPrimary, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php index 2a2664bd40f..9344cd9c6e9 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php @@ -13,11 +13,9 @@ */ class ConditionalPrimary extends Node implements Phase2OptimizableConditional { - /** @var Node|null */ - public $simpleConditionalExpression; + public Node|null $simpleConditionalExpression = null; - /** @var ConditionalExpression|Phase2OptimizableConditional|null */ - public $conditionalExpression; + public ConditionalExpression|Phase2OptimizableConditional|null $conditionalExpression = null; public function isSimpleConditionalExpression(): bool { diff --git a/lib/Doctrine/ORM/Query/AST/DeleteStatement.php b/lib/Doctrine/ORM/Query/AST/DeleteStatement.php index ff3b8869c40..f367d097c7a 100644 --- a/lib/Doctrine/ORM/Query/AST/DeleteStatement.php +++ b/lib/Doctrine/ORM/Query/AST/DeleteStatement.php @@ -13,11 +13,9 @@ */ class DeleteStatement extends Node { - /** @var WhereClause|null */ - public $whereClause; + public WhereClause|null $whereClause = null; - /** @param DeleteClause $deleteClause */ - public function __construct(public $deleteClause) + public function __construct(public DeleteClause $deleteClause) { } diff --git a/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php index 6f3b5cd050b..99788007e20 100644 --- a/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php @@ -13,9 +13,8 @@ */ class EmptyCollectionComparisonExpression extends Node { - /** @param PathExpression $expression */ public function __construct( - public $expression, + public PathExpression $expression, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/ExistsExpression.php b/lib/Doctrine/ORM/Query/AST/ExistsExpression.php index d93f5ce52a5..72757f45263 100644 --- a/lib/Doctrine/ORM/Query/AST/ExistsExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ExistsExpression.php @@ -13,9 +13,8 @@ */ class ExistsExpression extends Node { - /** @param Subselect $subselect */ public function __construct( - public $subselect, + public Subselect $subselect, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 22f4744defa..1dd1bf5e621 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -21,8 +21,7 @@ */ class IdentityFunction extends FunctionNode { - /** @var PathExpression */ - public $pathExpression; + public PathExpression $pathExpression; public string|null $fieldMapping = null; diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 9ca9a0ed7ef..87ee7133b4b 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -18,8 +18,7 @@ */ class SizeFunction extends FunctionNode { - /** @var PathExpression */ - public $collectionPathExpression; + public PathExpression $collectionPathExpression; /** * @inheritdoc diff --git a/lib/Doctrine/ORM/Query/AST/HavingClause.php b/lib/Doctrine/ORM/Query/AST/HavingClause.php index 5e5de5caa2a..0d4d821f87d 100644 --- a/lib/Doctrine/ORM/Query/AST/HavingClause.php +++ b/lib/Doctrine/ORM/Query/AST/HavingClause.php @@ -8,8 +8,7 @@ class HavingClause extends Node { - /** @param ConditionalExpression|Phase2OptimizableConditional $conditionalExpression */ - public function __construct(public $conditionalExpression) + public function __construct(public ConditionalExpression|Phase2OptimizableConditional $conditionalExpression) { } diff --git a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php index 5fbc67d88ba..c4c7cca3b56 100644 --- a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php @@ -13,14 +13,10 @@ */ class IdentificationVariableDeclaration extends Node { - /** - * @param RangeVariableDeclaration|null $rangeVariableDeclaration - * @param IndexBy|null $indexBy - * @param mixed[] $joins - */ + /** @param mixed[] $joins */ public function __construct( - public $rangeVariableDeclaration = null, - public $indexBy = null, + public RangeVariableDeclaration|null $rangeVariableDeclaration = null, + public IndexBy|null $indexBy = null, public array $joins = [], ) { } diff --git a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php index ae988224f75..3a4e75f7cb8 100644 --- a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php @@ -14,12 +14,9 @@ */ class InstanceOfExpression extends Node { - /** - * @param string $identificationVariable - * @param non-empty-list $value - */ + /** @param non-empty-list $value */ public function __construct( - public $identificationVariable, + public string $identificationVariable, public array $value, public bool $not = false, ) { diff --git a/lib/Doctrine/ORM/Query/AST/Join.php b/lib/Doctrine/ORM/Query/AST/Join.php index dad8b88ea5a..34ce83088de 100644 --- a/lib/Doctrine/ORM/Query/AST/Join.php +++ b/lib/Doctrine/ORM/Query/AST/Join.php @@ -18,16 +18,12 @@ class Join extends Node final public const JOIN_TYPE_LEFTOUTER = 2; final public const JOIN_TYPE_INNER = 3; - /** @var ConditionalExpression|Phase2OptimizableConditional|null */ - public $conditionalExpression = null; + public ConditionalExpression|Phase2OptimizableConditional|null $conditionalExpression = null; - /** - * @param Node $joinAssociationDeclaration - * @psalm-param self::JOIN_TYPE_* $joinType - */ + /** @psalm-param self::JOIN_TYPE_* $joinType */ public function __construct( public int $joinType, - public $joinAssociationDeclaration = null, + public Node|null $joinAssociationDeclaration = null, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php index 1ac8b863a07..e08d7f51514 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php @@ -13,14 +13,10 @@ */ class JoinAssociationDeclaration extends Node { - /** - * @param JoinAssociationPathExpression $joinAssociationPathExpression - * @param IndexBy|null $indexBy - */ public function __construct( - public $joinAssociationPathExpression, + public JoinAssociationPathExpression $joinAssociationPathExpression, public string $aliasIdentificationVariable, - public $indexBy, + public IndexBy|null $indexBy, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php index 6ac08090f3a..bf766955c5e 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php @@ -13,11 +13,7 @@ */ class JoinVariableDeclaration extends Node { - /** - * @param Join $join - * @param IndexBy|null $indexBy - */ - public function __construct(public $join, public $indexBy) + public function __construct(public Join $join, public IndexBy|null $indexBy) { } diff --git a/lib/Doctrine/ORM/Query/AST/LikeExpression.php b/lib/Doctrine/ORM/Query/AST/LikeExpression.php index 4206f0f1758..e3f67f8c39c 100644 --- a/lib/Doctrine/ORM/Query/AST/LikeExpression.php +++ b/lib/Doctrine/ORM/Query/AST/LikeExpression.php @@ -14,15 +14,10 @@ */ class LikeExpression extends Node { - /** - * @param Node|string $stringExpression - * @param InputParameter|FunctionNode|PathExpression|Literal $stringPattern - * @param Literal|null $escapeChar - */ public function __construct( - public $stringExpression, - public $stringPattern, - public $escapeChar = null, + public Node|string $stringExpression, + public InputParameter|FunctionNode|PathExpression|Literal $stringPattern, + public Literal|null $escapeChar = null, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php index 7994666f741..90331cdd35f 100644 --- a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php +++ b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php @@ -17,8 +17,7 @@ class QuantifiedExpression extends Node { public string $type; - /** @param Subselect $subselect */ - public function __construct(public $subselect) + public function __construct(public Subselect $subselect) { } diff --git a/lib/Doctrine/ORM/Query/AST/SelectStatement.php b/lib/Doctrine/ORM/Query/AST/SelectStatement.php index 5f47ebe262c..399462f2c25 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectStatement.php +++ b/lib/Doctrine/ORM/Query/AST/SelectStatement.php @@ -13,23 +13,15 @@ */ class SelectStatement extends Node { - /** @var WhereClause|null */ - public $whereClause; + public WhereClause|null $whereClause = null; - /** @var GroupByClause|null */ - public $groupByClause; + public GroupByClause|null $groupByClause = null; - /** @var HavingClause|null */ - public $havingClause; + public HavingClause|null $havingClause = null; - /** @var OrderByClause|null */ - public $orderByClause; + public OrderByClause|null $orderByClause = null; - /** - * @param SelectClause $selectClause - * @param FromClause $fromClause - */ - public function __construct(public $selectClause, public $fromClause) + public function __construct(public SelectClause $selectClause, public FromClause $fromClause) { } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php index 5fa21716de2..b3764ba1545 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php @@ -13,12 +13,9 @@ */ class SimpleCaseExpression extends Node { - /** - * @param PathExpression $caseOperand - * @param mixed[] $simpleWhenClauses - */ + /** @param mixed[] $simpleWhenClauses */ public function __construct( - public $caseOperand = null, + public PathExpression|null $caseOperand = null, public array $simpleWhenClauses = [], public mixed $elseScalarExpression = null, ) { diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php index 3631994beb6..0259e3bd162 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php @@ -13,9 +13,8 @@ */ class SimpleSelectClause extends Node { - /** @param SimpleSelectExpression $simpleSelectExpression */ public function __construct( - public $simpleSelectExpression, + public SimpleSelectExpression $simpleSelectExpression, public bool $isDistinct = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php index 9491612f39d..97e8f087e5c 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php @@ -16,8 +16,7 @@ class SimpleSelectExpression extends Node { public string|null $fieldIdentificationVariable = null; - /** @param Node|string $expression */ - public function __construct(public $expression) + public function __construct(public Node|string $expression) { } diff --git a/lib/Doctrine/ORM/Query/AST/Subselect.php b/lib/Doctrine/ORM/Query/AST/Subselect.php index 9a237004c1b..8ff85954fd7 100644 --- a/lib/Doctrine/ORM/Query/AST/Subselect.php +++ b/lib/Doctrine/ORM/Query/AST/Subselect.php @@ -13,23 +13,15 @@ */ class Subselect extends Node { - /** @var WhereClause|null */ - public $whereClause; + public WhereClause|null $whereClause = null; - /** @var GroupByClause|null */ - public $groupByClause; + public GroupByClause|null $groupByClause = null; - /** @var HavingClause|null */ - public $havingClause; + public HavingClause|null $havingClause = null; - /** @var OrderByClause|null */ - public $orderByClause; + public OrderByClause|null $orderByClause = null; - /** - * @param SimpleSelectClause $simpleSelectClause - * @param SubselectFromClause $subselectFromClause - */ - public function __construct(public $simpleSelectClause, public $subselectFromClause) + public function __construct(public SimpleSelectClause $simpleSelectClause, public SubselectFromClause $subselectFromClause) { } diff --git a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php index 051eccee889..eadf6bc41f7 100644 --- a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php @@ -11,9 +11,8 @@ */ class SubselectIdentificationVariableDeclaration { - /** @param PathExpression $associationPathExpression */ public function __construct( - public $associationPathExpression, + public PathExpression $associationPathExpression, public string $aliasIdentificationVariable, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/UpdateItem.php b/lib/Doctrine/ORM/Query/AST/UpdateItem.php index 793603607f9..b540593c724 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateItem.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateItem.php @@ -15,11 +15,7 @@ */ class UpdateItem extends Node { - /** - * @param PathExpression $pathExpression - * @param InputParameter|ArithmeticExpression|null $newValue - */ - public function __construct(public $pathExpression, public $newValue) + public function __construct(public PathExpression $pathExpression, public InputParameter|ArithmeticExpression|null $newValue) { } diff --git a/lib/Doctrine/ORM/Query/AST/UpdateStatement.php b/lib/Doctrine/ORM/Query/AST/UpdateStatement.php index 0f1645e0c4a..7ea50766b70 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateStatement.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateStatement.php @@ -13,11 +13,9 @@ */ class UpdateStatement extends Node { - /** @var WhereClause|null */ - public $whereClause; + public WhereClause|null $whereClause = null; - /** @param UpdateClause $updateClause */ - public function __construct(public $updateClause) + public function __construct(public UpdateClause $updateClause) { } diff --git a/lib/Doctrine/ORM/Query/AST/WhenClause.php b/lib/Doctrine/ORM/Query/AST/WhenClause.php index 71c7147b39e..9bf194e300d 100644 --- a/lib/Doctrine/ORM/Query/AST/WhenClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhenClause.php @@ -13,9 +13,8 @@ */ class WhenClause extends Node { - /** @param ConditionalExpression|Phase2OptimizableConditional $caseConditionExpression */ public function __construct( - public $caseConditionExpression, + public ConditionalExpression|Phase2OptimizableConditional $caseConditionExpression, public mixed $thenScalarExpression = null, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/WhereClause.php b/lib/Doctrine/ORM/Query/AST/WhereClause.php index 25de9fd6594..e4d7b66cc20 100644 --- a/lib/Doctrine/ORM/Query/AST/WhereClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhereClause.php @@ -13,8 +13,7 @@ */ class WhereClause extends Node { - /** @param ConditionalExpression|Phase2OptimizableConditional $conditionalExpression */ - public function __construct(public $conditionalExpression) + public function __construct(public ConditionalExpression|Phase2OptimizableConditional $conditionalExpression) { } diff --git a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php index 7252684f280..66696dbde52 100644 --- a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php @@ -19,8 +19,7 @@ */ class SingleTableDeleteUpdateExecutor extends AbstractSqlExecutor { - /** @param SqlWalker $sqlWalker */ - public function __construct(AST\Node $AST, $sqlWalker) + public function __construct(AST\Node $AST, SqlWalker $sqlWalker) { if ($AST instanceof AST\UpdateStatement) { $this->sqlStatements = $sqlWalker->walkUpdateStatement($AST); diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php index beaec30fca6..0629156d837 100644 --- a/lib/Doctrine/ORM/Query/Expr.php +++ b/lib/Doctrine/ORM/Query/Expr.php @@ -480,7 +480,7 @@ public function concat(mixed ...$x): Expr\Func * @param int $from Initial offset to start cropping string. May accept negative values. * @param int|null $len Length of crop. May accept negative values. */ - public function substring(mixed $x, int $from, $len = null): Expr\Func + public function substring(mixed $x, int $from, int|null $len = null): Expr\Func { $args = [$x, $from]; if ($len !== null) { diff --git a/lib/Doctrine/ORM/Query/Expr/Base.php b/lib/Doctrine/ORM/Query/Expr/Base.php index 6fd5b82b923..a98ea3b8cb3 100644 --- a/lib/Doctrine/ORM/Query/Expr/Base.php +++ b/lib/Doctrine/ORM/Query/Expr/Base.php @@ -42,7 +42,7 @@ public function __construct(mixed $args = []) * * @return $this */ - public function addMultiple($args = []): static + public function addMultiple(array|string|object $args = []): static { foreach ((array) $args as $arg) { $this->add($arg); diff --git a/lib/Doctrine/ORM/Query/Expr/Func.php b/lib/Doctrine/ORM/Query/Expr/Func.php index 1ecb8e25fae..cd9e8e012a9 100644 --- a/lib/Doctrine/ORM/Query/Expr/Func.php +++ b/lib/Doctrine/ORM/Query/Expr/Func.php @@ -21,12 +21,11 @@ class Func implements Stringable /** * Creates a function, with the given argument. * - * @param mixed[]|mixed $arguments * @psalm-param list|mixed $arguments */ public function __construct( protected string $name, - $arguments, + mixed $arguments, ) { $this->arguments = (array) $arguments; } diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 6450badd45f..ade4bf347fe 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -1386,10 +1386,8 @@ public function OrderByItem(): AST\OrderByItem * NewValue ::= SimpleArithmeticExpression | "NULL" * * SimpleArithmeticExpression covers all *Primary grammar rules and also SimpleEntityExpression - * - * @return AST\ArithmeticExpression|AST\InputParameter|null */ - public function NewValue() + public function NewValue(): AST\ArithmeticExpression|AST\InputParameter|null { if ($this->lexer->isNextToken(TokenType::T_NULL)) { $this->match(TokenType::T_NULL); @@ -1660,10 +1658,8 @@ public function NewObjectExpression(): AST\NewObjectExpression /** * NewObjectArg ::= ScalarExpression | "(" Subselect ")" - * - * @return mixed */ - public function NewObjectArg() + public function NewObjectArg(): mixed { assert($this->lexer->lookahead !== null); $token = $this->lexer->lookahead; @@ -1703,7 +1699,7 @@ public function IndexBy(): AST\IndexBy * * @return mixed One of the possible expressions or subexpressions. */ - public function ScalarExpression() + public function ScalarExpression(): mixed { assert($this->lexer->token !== null); assert($this->lexer->lookahead !== null); @@ -1782,7 +1778,7 @@ public function ScalarExpression() * * @return mixed One of the possible expressions or subexpressions. */ - public function CaseExpression() + public function CaseExpression(): mixed { assert($this->lexer->lookahead !== null); $lookahead = $this->lexer->lookahead->type; @@ -2394,10 +2390,8 @@ public function CollectionMemberExpression(): AST\CollectionMemberExpression /** * Literal ::= string | char | integer | float | boolean - * - * @return AST\Literal */ - public function Literal() + public function Literal(): AST\Literal { assert($this->lexer->lookahead !== null); assert($this->lexer->token !== null); @@ -2638,10 +2632,8 @@ public function StringExpression(): AST\Subselect|AST\Node|string /** * StringPrimary ::= StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression | CaseExpression - * - * @return AST\Node */ - public function StringPrimary() + public function StringPrimary(): AST\Node { assert($this->lexer->lookahead !== null); $lookaheadType = $this->lexer->lookahead->type; @@ -3048,10 +3040,8 @@ public function ExistsExpression(): AST\ExistsExpression /** * ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!=" - * - * @return string */ - public function ComparisonOperator() + public function ComparisonOperator(): string { assert($this->lexer->lookahead !== null); switch ($this->lexer->lookahead->value) { @@ -3098,10 +3088,8 @@ public function ComparisonOperator() /** * FunctionDeclaration ::= FunctionsReturningStrings | FunctionsReturningNumerics | FunctionsReturningDatetime - * - * @return Functions\FunctionNode */ - public function FunctionDeclaration() + public function FunctionDeclaration(): Functions\FunctionNode { assert($this->lexer->lookahead !== null); $token = $this->lexer->lookahead; diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 849672f8ea8..351d9617ee8 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -1670,7 +1670,6 @@ public function walkUpdateItem(AST\UpdateItem $updateItem): string $sql .= match (true) { $newValue instanceof AST\Node => $newValue->dispatch($this), $newValue === null => 'NULL', - default => $this->conn->quote((string) $newValue), }; $this->useSqlTableAliases = $useTableAliasesBefore; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php index a8583c6e0c5..9d490b4cb59 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -21,8 +21,7 @@ */ class UpdateCommand extends AbstractCommand { - /** @var string */ - protected $name = 'orm:schema-tool:update'; + protected string $name = 'orm:schema-tool:update'; protected function configure(): void { diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index ed38cb8faf0..d626b7210ca 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1512,7 +1512,7 @@ static function ($value) { * * @return string The entity id hash. */ - public function getIdHashByEntity($entity): string + public function getIdHashByEntity(object $entity): string { $identifier = $this->entityIdentifiers[spl_object_id($entity)]; @@ -2875,11 +2875,9 @@ public function initializeObject(object $obj): void /** * Tests if a value is an uninitialized entity. * - * @param mixed $obj - * * @psalm-assert-if-true InternalProxy $obj */ - public function isUninitializedObject($obj): bool + public function isUninitializedObject(mixed $obj): bool { return $obj instanceof InternalProxy && ! $obj->__isInitialized(); } @@ -2924,7 +2922,7 @@ public function isReadOnly(object $object): bool */ private function afterTransactionComplete(): void { - $this->performCallbackOnCachedPersister(static function (CachedPersister $persister) { + $this->performCallbackOnCachedPersister(static function (CachedPersister $persister): void { $persister->afterTransactionComplete(); }); } @@ -2934,7 +2932,7 @@ private function afterTransactionComplete(): void */ private function afterTransactionRolledBack(): void { - $this->performCallbackOnCachedPersister(static function (CachedPersister $persister) { + $this->performCallbackOnCachedPersister(static function (CachedPersister $persister): void { $persister->afterTransactionRolledBack(); }); } @@ -3071,11 +3069,8 @@ private function normalizeIdentifier(ClassMetadata $targetClass, array $flatIden * This is used by EntityPersisters after they inserted entities into the database. * It will place the assigned ID values in the entity's fields and start tracking * the entity in the identity map. - * - * @param object $entity - * @param mixed $generatedId */ - final public function assignPostInsertId($entity, $generatedId): void + final public function assignPostInsertId(object $entity, mixed $generatedId): void { $class = $this->em->getClassMetadata(get_class($entity)); $idField = $class->getSingleIdentifierFieldName(); diff --git a/phpcs.xml.dist b/phpcs.xml.dist index a096eb099c6..eb9be01ad04 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -19,9 +19,6 @@ */tests/Doctrine/Tests/ORM/Tools/Export/export/* - - - @@ -30,7 +27,6 @@ - */lib/* + lib/Doctrine/ORM/Proxy/ProxyFactory.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a5703c180b4..e5df635e545 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -277,7 +277,7 @@ parameters: - message: "#^Match arm is unreachable because previous comparison is always true\\.$#" - count: 2 + count: 1 path: lib/Doctrine/ORM/Query/SqlWalker.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 90702218022..488480808f7 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -723,11 +723,6 @@ currentPersisterContext->sqlTableAliases]]> - - - $selectJoinSql - - $className @@ -1036,7 +1031,6 @@ - conn->quote((string) $newValue)]]> throw QueryException::invalidLiteral($literal) diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index 8350d60ba52..acd9d22ae32 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -150,7 +150,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void foreach ($dqlAliases as $alias) { $pathExpr = new PathExpression(PathExpression::TYPE_STATE_FIELD, $alias, 'id'); $pathExpr->type = PathExpression::TYPE_STATE_FIELD; - $comparisonExpr = new ComparisonExpression($pathExpr, '=', 1); + $comparisonExpr = new ComparisonExpression($pathExpr, '=', '1'); $condPrimary = new ConditionalPrimary(); $condPrimary->simpleConditionalExpression = $comparisonExpr;