Skip to content

Commit

Permalink
psalm fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Sep 27, 2020
1 parent 79cdcde commit 55335ec
Show file tree
Hide file tree
Showing 30 changed files with 286 additions and 61 deletions.
5 changes: 4 additions & 1 deletion lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ public function setParameters($parameters)
{
// BC compatibility with 2.3-
if (is_array($parameters)) {
/** @psalm-var ArrayCollection<int, Parameter> $parameterCollection */
$parameterCollection = new ArrayCollection();

foreach ($parameters as $key => $value) {
Expand Down Expand Up @@ -393,9 +394,11 @@ public function setParameter($key, $value, $type = null)
*
* @param mixed $value
*
* @return array|string
* @return mixed[]|string|int|float|bool
*
* @throws \Doctrine\ORM\ORMInvalidArgumentException
*
* @psalm-return array|scalar
*/
public function processParameterValue($value)
{
Expand Down
18 changes: 9 additions & 9 deletions lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
class StatisticsCacheLogger implements CacheLogger
{
/**
* @var array
* @var int[]
*/
private $cacheMissCountMap = [];

/**
* @var array
* @var int[]
*/
private $cacheHitCountMap = [];

/**
* @var array
* @var int[]
*/
private $cachePutCountMap = [];

Expand Down Expand Up @@ -142,7 +142,7 @@ public function queryCachePut($regionName, QueryCacheKey $key)
*
* @param string $regionName The name of the cache region.
*
* @return integer
* @return int
*/
public function getRegionHitCount($regionName)
{
Expand All @@ -154,7 +154,7 @@ public function getRegionHitCount($regionName)
*
* @param string $regionName The name of the cache region.
*
* @return integer
* @return int
*/
public function getRegionMissCount($regionName)
{
Expand All @@ -166,7 +166,7 @@ public function getRegionMissCount($regionName)
*
* @param string $regionName The name of the cache region.
*
* @return integer
* @return int
*/
public function getRegionPutCount($regionName)
{
Expand Down Expand Up @@ -222,7 +222,7 @@ public function clearStats()
/**
* Get the total number of put in cache.
*
* @return integer
* @return int
*/
public function getPutCount()
{
Expand All @@ -232,7 +232,7 @@ public function getPutCount()
/**
* Get the total number of entries successfully retrieved from cache.
*
* @return integer
* @return int
*/
public function getHitCount()
{
Expand All @@ -242,7 +242,7 @@ public function getHitCount()
/**
* Get the total number of cached entries *not* found in cache.
*
* @return integer
* @return int
*/
public function getMissCount()
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Cache/Region/FileLockRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ public function lock(CacheKey $key)

/**
* {@inheritdoc}
*
* @return bool
*/
public function unlock(CacheKey $key, Lock $lock)
{
Expand Down
12 changes: 6 additions & 6 deletions lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getExpressionBuilder()
*/
public function beginTransaction()
{
return $this->wrapped->beginTransaction();
$this->wrapped->beginTransaction();
}

/**
Expand All @@ -81,15 +81,15 @@ public function transactional($func)
*/
public function commit()
{
return $this->wrapped->commit();
$this->wrapped->commit();
}

/**
* {@inheritdoc}
*/
public function rollback()
{
return $this->wrapped->rollback();
$this->wrapped->rollback();
}

/**
Expand Down Expand Up @@ -153,7 +153,7 @@ public function getPartialReference($entityName, $identifier)
*/
public function close()
{
return $this->wrapped->close();
$this->wrapped->close();
}

/**
Expand All @@ -169,7 +169,7 @@ public function copy($entity, $deep = false)
*/
public function lock($entity, $lockMode, $lockVersion = null)
{
return $this->wrapped->lock($entity, $lockMode, $lockVersion);
$this->wrapped->lock($entity, $lockMode, $lockVersion);
}

/**
Expand All @@ -185,7 +185,7 @@ public function find($className, $id, $lockMode = null, $lockVersion = null)
*/
public function flush($entity = null)
{
return $this->wrapped->flush($entity);
$this->wrapped->flush($entity);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ class ClassMetadataInfo implements ClassMetadata
* Whether a unique constraint should be generated for the column.
*
* @var array
*
* @psalm-var array<string, array{type: string, fieldName: string, columnName: string, inherited: class-string}>
*/
public $fieldMappings = [];

Expand Down Expand Up @@ -644,7 +646,7 @@ class ClassMetadataInfo implements ClassMetadata
/**
* The ReflectionProperty instances of the mapped class.
*
* @var ReflectionProperty[]
* @var ReflectionProperty[]|null[]
*/
public $reflFields = [];

Expand All @@ -671,7 +673,9 @@ public function __construct($entityName, NamingStrategy $namingStrategy = null)
/**
* Gets the ReflectionProperties of the mapped class.
*
* @return ReflectionProperty[] An array of ReflectionProperty instances.
* @return ReflectionProperty[]|null[] An array of ReflectionProperty instances.
*
* @psalm-return array<array-key, ReflectionProperty|null>
*/
public function getReflectionProperties()
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
class AnnotationDriver extends AbstractAnnotationDriver
{
/**
* {@inheritDoc}
* @var int[]
* @psalm-var array<class-string, int>
*/
protected $entityAnnotationClasses = [
Mapping\Entity::class => 1,
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/PersistentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ public function setInitialized($bool)

/**
* {@inheritdoc}
*
* @return object
*/
public function remove($key)
{
Expand Down Expand Up @@ -510,6 +512,8 @@ public function offsetSet($offset, $value)

/**
* {@inheritdoc}
*
* @return object
*/
public function offsetUnset($offset)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class OneToManyPersister extends AbstractCollectionPersister
{
/**
* {@inheritdoc}
*
* @return int|null
*/
public function delete(PersistentCollection $collection)
{
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ protected function fetchVersionValue($versionedClass, array $id)
}

/**
* @return Type[]
* @return int[]|null[]|string[]
*
* @psalm-return list<Type>
* @psalm-return list<int|null|string>
*/
private function extractIdentifierTypes(array $id, ClassMetadata $versionedClass) : array
{
Expand Down Expand Up @@ -1917,11 +1917,11 @@ private function expandToManyParameters($criteria)
* @param mixed $value
* @param ClassMetadata $class
*
* @return Type[]
* @return int[]|null[]|string[]
*
* @throws \Doctrine\ORM\Query\QueryException
*
* @psalm-return list<Type>
* @psalm-return list<int|null|string>
*/
private function getTypes($field, $value, ClassMetadata $class)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class SimpleSelectExpression extends Node
{
/**
* @var Node
* @var Node|string
*/
public $expression;

Expand All @@ -42,7 +42,7 @@ class SimpleSelectExpression extends Node
public $fieldIdentificationVariable;

/**
* @param Node $expression
* @param Node|string $expression
*/
public function __construct($expression)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Query/AST/WhereClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class WhereClause extends Node
{
/**
* @var ConditionalExpression
* @var ConditionalExpression|ConditionalTerm
*/
public $conditionalExpression;

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
abstract class AbstractSqlExecutor
{
/**
* @var array
* @var mixed[]|string
*/
protected $_sqlStatements;

Expand All @@ -46,7 +46,7 @@ abstract class AbstractSqlExecutor
/**
* Gets the SQL statements that are executed by the executor.
*
* @return array All the SQL update statements.
* @return mixed[]|string All the SQL update statements.
*/
public function getSqlStatements()
{
Expand Down
8 changes: 6 additions & 2 deletions lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Query\AST;
use Doctrine\ORM\Query\AST\DeleteStatement;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Utility\PersisterHelper;
use Throwable;

Expand Down Expand Up @@ -57,8 +59,8 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
* Internal note: Any SQL construction and preparation takes place in the constructor for
* best performance. With a query cache the executor will be cached.
*
* @param \Doctrine\ORM\Query\AST\Node $AST The root AST node of the DQL query.
* @param \Doctrine\ORM\Query\SqlWalker $sqlWalker The walker used for SQL generation from the AST.
* @param DeleteStatement $AST The root AST node of the DQL query.
* @param SqlWalker $sqlWalker The walker used for SQL generation from the AST.
*/
public function __construct(AST\Node $AST, $sqlWalker)
{
Expand Down Expand Up @@ -116,6 +118,8 @@ public function __construct(AST\Node $AST, $sqlWalker)

/**
* {@inheritDoc}
*
* @return int
*/
public function execute(Connection $conn, array $params, array $types)
{
Expand Down
8 changes: 6 additions & 2 deletions lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Query\AST\UpdateStatement;
use Doctrine\ORM\Query\ParameterTypeInferer;
use Doctrine\ORM\Query\AST;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Utility\PersisterHelper;
use Throwable;

Expand Down Expand Up @@ -66,8 +68,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
* Internal note: Any SQL construction and preparation takes place in the constructor for
* best performance. With a query cache the executor will be cached.
*
* @param \Doctrine\ORM\Query\AST\Node $AST The root AST node of the DQL query.
* @param \Doctrine\ORM\Query\SqlWalker $sqlWalker The walker used for SQL generation from the AST.
* @param UpdateStatement $AST The root AST node of the DQL query.
* @param SqlWalker $sqlWalker The walker used for SQL generation from the AST.
*/
public function __construct(AST\Node $AST, $sqlWalker)
{
Expand Down Expand Up @@ -161,6 +163,8 @@ public function __construct(AST\Node $AST, $sqlWalker)

/**
* {@inheritDoc}
*
* @return int
*/
public function execute(Connection $conn, array $params, array $types)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public function __construct(AST\Node $AST, $sqlWalker)

/**
* {@inheritDoc}
*
* @return int
*/
public function execute(Connection $conn, array $params, array $types)
{
Expand Down
Loading

0 comments on commit 55335ec

Please sign in to comment.