Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to doctrine/coding-standard 9 #8617

Merged
merged 1 commit into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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
6 changes: 2 additions & 4 deletions lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,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 @@ -402,10 +401,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
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 @@ -746,12 +746,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
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/EntityManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,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 @@ -160,7 +160,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 @@ -183,9 +182,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 @@ -198,10 +197,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 @@ -214,9 +213,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 @@ -228,13 +228,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 @@ -307,12 +306,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
16 changes: 7 additions & 9 deletions lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ public function __construct(EntityManagerInterface $em)
*
* @param object $stmt
* @param object $resultSetMapping
* @psalm-param array<string, mixed> $hints
*
* @return IterableResult
*
* @psalm-param array<string, mixed> $hints
*/
public function iterate($stmt, $resultSetMapping, array $hints = [])
{
Expand All @@ -151,9 +150,9 @@ public function iterate($stmt, $resultSetMapping, array $hints = [])
/**
* Initiates a row-by-row hydration.
*
* @return iterable<mixed>
*
* @psalm-param array<string, mixed> $hints
*
* @return iterable<mixed>
*/
public function toIterable(ResultStatement $stmt, ResultSetMapping $resultSetMapping, array $hints = []): iterable
{
Expand Down Expand Up @@ -195,10 +194,9 @@ public function toIterable(ResultStatement $stmt, ResultSetMapping $resultSetMap
*
* @param object $stmt
* @param object $resultSetMapping
* @psalm-param array<string, string> $hints
*
* @return mixed[]
*
* @psalm-param array<string, string> $hints
*/
public function hydrateAll($stmt, $resultSetMapping, array $hints = [])
{
Expand Down Expand Up @@ -322,14 +320,13 @@ abstract protected function hydrateAllData();
* the values applied. Scalar values are kept in a specific key 'scalars'.
*
* @param mixed[] $data SQL Result Row.
* @psalm-param array<string, string> $id Dql-Alias => ID-Hash.
* @psalm-param array<string, bool> $nonemptyComponents Does this DQL-Alias has at least one non NULL value?
*
* @return array<string, array<string, mixed>> An array with all the fields
* (name => value) of the data
* row, grouped by their
* component alias.
*
* @psalm-param array<string, string> $id Dql-Alias => ID-Hash.
* @psalm-param array<string, bool> $nonemptyComponents Does this DQL-Alias has at least one non NULL value?
* @psalm-return array{
* data: array<array-key, array>,
* newObjects?: array<array-key, array{
Expand Down Expand Up @@ -415,6 +412,7 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon
* of elements as before.
*
* @psalm-param array<string, mixed> $data
*
* @psalm-return array<string, mixed> The processed row.
*/
protected function gatherScalarRowData(&$data)
Expand Down
Loading