Skip to content

Commit

Permalink
Merge pull request #8620 from greg0ire/2.9.x
Browse files Browse the repository at this point in the history
Manually merge 2.8.x into 2.9.x
  • Loading branch information
greg0ire committed Apr 13, 2021
2 parents 09a7d9f + 6e16ef8 commit ceeea8c
Show file tree
Hide file tree
Showing 52 changed files with 263 additions and 401 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"symfony/console": "^3.0|^4.0|^5.0"
},
"require-dev": {
"doctrine/coding-standard": "^8.0",
"doctrine/coding-standard": "^9.0",
"phpstan/phpstan": "^0.12.18",
"phpunit/phpunit": "^8.5|^9.4",
"squizlabs/php_codesniffer": "3.6.0",
Expand Down
18 changes: 6 additions & 12 deletions lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,9 @@ static function (Query\Parameter $parameter) use ($key): bool {
* Sets a collection of query parameters.
*
* @param ArrayCollection|mixed[] $parameters
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
*
* @return static This query instance.
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
*/
public function setParameters($parameters)
{
Expand Down Expand Up @@ -400,10 +399,9 @@ public function setParameter($key, $value, $type = null)
* @param mixed $value
*
* @return mixed[]|string|int|float|bool
* @psalm-return array|scalar
*
* @throws ORMInvalidArgumentException
*
* @psalm-return array|scalar
*/
public function processParameterValue($value)
{
Expand Down Expand Up @@ -983,10 +981,9 @@ public function iterate($parameters = null, $hydrationMode = null)
*
* @param ArrayCollection|mixed[] $parameters The query parameters.
* @param string|int|null $hydrationMode The hydration mode to use.
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
*
* @return iterable<mixed>
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
*/
public function toIterable(iterable $parameters = [], $hydrationMode = null): iterable
{
Expand Down Expand Up @@ -1017,10 +1014,9 @@ public function toIterable(iterable $parameters = [], $hydrationMode = null): it
*
* @param ArrayCollection|mixed[]|null $parameters Query parameters.
* @param string|int|null $hydrationMode Processing mode to be used during the hydration process.
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*
* @return mixed
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*/
public function execute($parameters = null, $hydrationMode = null)
{
Expand All @@ -1036,10 +1032,9 @@ public function execute($parameters = null, $hydrationMode = null)
*
* @param ArrayCollection|mixed[]|null $parameters
* @param string|int|null $hydrationMode
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*
* @return mixed
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*/
private function executeIgnoreQueryCache($parameters = null, $hydrationMode = null)
{
Expand Down Expand Up @@ -1097,10 +1092,9 @@ private function executeIgnoreQueryCache($parameters = null, $hydrationMode = nu
*
* @param ArrayCollection|mixed[]|null $parameters
* @param string|int|null $hydrationMode
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*
* @return mixed
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*/
private function executeUsingQueryCache($parameters = null, $hydrationMode = null)
{
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Cache/DefaultQueryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $h
* @param mixed $assocValue
*
* @return mixed[]|null
*
* @psalm-return array{targetEntity: string, type: mixed, list?: array[], identifier?: array}|null
*/
private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocValue)
Expand Down
38 changes: 13 additions & 25 deletions lib/Doctrine/ORM/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ public function setMetadataDriverImpl(MappingDriver $driverImpl)
* is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported.
*
* @param bool $useSimpleAnnotationReader
* @psalm-param string|list<string> $paths
*
* @return AnnotationDriver
*
* @psalm-param string|list<string> $paths
*/
public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true)
{
Expand Down Expand Up @@ -209,9 +208,9 @@ public function getEntityNamespace($entityNamespaceAlias)
/**
* Sets the entity alias map.
*
* @return void
*
* @psalm-param array<string, string> $entityNamespaces
*
* @return void
*/
public function setEntityNamespaces(array $entityNamespaces)
{
Expand Down Expand Up @@ -350,13 +349,13 @@ public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm)
*
* @param string $name The name of the query.
*
* @throws ORMException
*
* @psalm-return array{string, ResultSetMapping} A tuple with the first
* element being the SQL
* string and the second
* element being the
* ResultSetMapping.
*
* @throws ORMException
*/
public function getNamedNativeQuery($name)
{
Expand Down Expand Up @@ -426,7 +425,6 @@ public function addCustomStringFunction($name, $className)
* @param string $name
*
* @return string|null
*
* @psalm-return ?class-string
*/
public function getCustomStringFunction($name)
Expand All @@ -444,10 +442,10 @@ public function getCustomStringFunction($name)
*
* Any previously added string functions are discarded.
*
* @return void
*
* @psalm-param array<string, class-string> $functions The map of custom
* DQL string functions.
*
* @return void
*/
public function setCustomStringFunctions(array $functions)
{
Expand Down Expand Up @@ -479,7 +477,6 @@ public function addCustomNumericFunction($name, $className)
* @param string $name
*
* @return string|null
*
* @psalm-return ?class-string
*/
public function getCustomNumericFunction($name)
Expand All @@ -497,10 +494,10 @@ public function getCustomNumericFunction($name)
*
* Any previously added numeric functions are discarded.
*
* @return void
*
* @psalm-param array<string, class-string> $functions The map of custom
* DQL numeric functions.
*
* @return void
*/
public function setCustomNumericFunctions(array $functions)
{
Expand All @@ -518,10 +515,9 @@ public function setCustomNumericFunctions(array $functions)
*
* @param string $name Function name.
* @param string|callable $className Class name or a callable that returns the function.
* @psalm-param class-string|callable $className
*
* @return void
*
* @psalm-param class-string|callable $className
*/
public function addCustomDatetimeFunction($name, $className)
{
Expand All @@ -534,7 +530,6 @@ public function addCustomDatetimeFunction($name, $className)
* @param string $name
*
* @return string|null
*
* @psalm-return ?class-string $name
*/
public function getCustomDatetimeFunction($name)
Expand All @@ -553,10 +548,9 @@ public function getCustomDatetimeFunction($name)
* Any previously added date/time functions are discarded.
*
* @param array $functions The map of custom DQL date/time functions.
* @psalm-param array<string, string> $functions
*
* @return void
*
* @psalm-param array<string, string> $functions
*/
public function setCustomDatetimeFunctions(array $functions)
{
Expand Down Expand Up @@ -587,7 +581,6 @@ public function setCustomHydrationModes($modes)
* @param string $modeName The hydration mode name.
*
* @return string|null The hydrator class name.
*
* @psalm-return ?class-string
*/
public function getCustomHydrationMode($modeName)
Expand All @@ -599,10 +592,9 @@ public function getCustomHydrationMode($modeName)
* Adds a custom hydration mode.
*
* @param string $modeName The hydration mode name.
* @psalm-param class-string $hydrator The hydrator class name.
*
* @return void
*
* @psalm-param class-string $hydrator The hydrator class name.
*/
public function addCustomHydrationMode($modeName, $hydrator)
{
Expand All @@ -613,10 +605,9 @@ public function addCustomHydrationMode($modeName, $hydrator)
* Sets a class metadata factory.
*
* @param string $cmfName
* @psalm-param class-string $cmfName
*
* @return void
*
* @psalm-param class-string $cmfName
*/
public function setClassMetadataFactoryName($cmfName)
{
Expand All @@ -625,7 +616,6 @@ public function setClassMetadataFactoryName($cmfName)

/**
* @return string
*
* @psalm-return class-string
*/
public function getClassMetadataFactoryName()
Expand Down Expand Up @@ -655,7 +645,6 @@ public function addFilter($name, $className)
*
* @return string|null The class name of the filter, or null if it is not
* defined.
*
* @psalm-return ?class-string
*/
public function getFilterClassName($name)
Expand Down Expand Up @@ -687,7 +676,6 @@ public function setDefaultRepositoryClassName($className)
* Get default repository class.
*
* @return string
*
* @psalm-return class-string
*/
public function getDefaultRepositoryClassName()
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,17 @@ public function flush($entity = null)
* during the search.
* @param int|null $lockVersion The version of the entity to find when using
* optimistic locking.
* @psalm-param class-string<T> $className
*
* @return object|null The entity instance or NULL if the entity can not be found.
* @psalm-return ?T
*
* @throws OptimisticLockException
* @throws ORMInvalidArgumentException
* @throws TransactionRequiredException
* @throws ORMException
*
* @template T
* @psalm-param class-string<T> $className
* @psalm-return ?T
*/
public function find($className, $id, $lockMode = null, $lockVersion = null)
{
Expand Down Expand Up @@ -754,12 +754,12 @@ 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<T> $entityName
*
* @return ObjectRepository|EntityRepository The repository class.
* @psalm-return EntityRepository<T>
*
* @template T
* @psalm-param class-string<T> $entityName
* @psalm-return EntityRepository<T>
*/
public function getRepository($entityName)
{
Expand Down
8 changes: 5 additions & 3 deletions lib/Doctrine/ORM/EntityManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ interface EntityManagerInterface extends ObjectManager
/**
* {@inheritdoc}
*
* @template T
* @psalm-param class-string<T> $className
*
* @psalm-return EntityRepository<T>
*
* @template T
*/
public function getRepository($className);

Expand Down Expand Up @@ -164,14 +166,14 @@ public function createQueryBuilder();
*
* @param string $entityName The name of the entity type.
* @param mixed $id The entity identifier.
* @psalm-param class-string<T> $entityName
*
* @return object|null The entity reference.
* @psalm-return ?T
*
* @throws ORMException
*
* @template T
* @psalm-param class-string<T> $entityName
* @psalm-return ?T
*/
public function getReference($entityName, $id);

Expand Down
16 changes: 7 additions & 9 deletions lib/Doctrine/ORM/EntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public function clear()
* @param int|null $lockVersion The lock version.
*
* @return object|null The entity instance or NULL if the entity can not be found.
*
* @psalm-return ?T
*/
public function find($id, $lockMode = null, $lockVersion = null)
Expand All @@ -206,9 +205,9 @@ public function findAll()
*
* @param int|null $limit
* @param int|null $offset
*
* @psalm-param array<string, mixed> $criteria
* @psalm-param array<string, string>|null $orderBy
*
* @psalm-return list<T> The objects.
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
Expand All @@ -221,10 +220,10 @@ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $
/**
* Finds a single entity by a set of criteria.
*
* @return object|null The entity instance or NULL if the entity can not be found.
*
* @psalm-param array<string, mixed> $criteria
* @psalm-param array<string, string>|null $orderBy
*
* @return object|null The entity instance or NULL if the entity can not be found.
* @psalm-return ?T
*/
public function findOneBy(array $criteria, ?array $orderBy = null)
Expand All @@ -237,9 +236,10 @@ public function findOneBy(array $criteria, ?array $orderBy = null)
/**
* Counts entities by a set of criteria.
*
* @psalm-param array<string, mixed> $criteria
*
* @return int The cardinality of the objects that match the given criteria.
*
* @psalm-param array<string, mixed> $criteria
* @todo Add this method to `ObjectRepository` interface in the next major release
*/
public function count(array $criteria)
Expand All @@ -251,13 +251,12 @@ public function count(array $criteria)
* Adds support for magic method calls.
*
* @param string $method
* @psalm-param list<mixed> $arguments
*
* @return mixed The returned value from the resolved method.
*
* @throws ORMException
* @throws BadMethodCallException If the method called is invalid.
*
* @psalm-param list<mixed> $arguments
*/
public function __call($method, $arguments)
{
Expand Down Expand Up @@ -330,12 +329,11 @@ public function matching(Criteria $criteria)
*
* @param string $method The method to call
* @param string $by The property name used as condition
* @psalm-param list<mixed> $arguments The arguments to pass at method call
*
* @return mixed
*
* @throws ORMException If the method called is invalid or the requested field/association does not exist.
*
* @psalm-param list<mixed> $arguments The arguments to pass at method call
*/
private function resolveMagicCall(string $method, string $by, array $arguments)
{
Expand Down

0 comments on commit ceeea8c

Please sign in to comment.