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

Fix issues detected by psalm on 2.7 #7989

Merged
merged 1 commit into from
May 18, 2020
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
20 changes: 19 additions & 1 deletion lib/Doctrine/ORM/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ public function addCustomStringFunction($name, $className)
* @param string $name
*
* @return string|null
* @psalm-return ?class-string
greg0ire marked this conversation as resolved.
Show resolved Hide resolved
*/
public function getCustomStringFunction($name)
{
Expand Down Expand Up @@ -494,6 +495,7 @@ public function addCustomNumericFunction($name, $className)
* @param string $name
*
* @return string|null
* @psalm-return ?class-string
*/
public function getCustomNumericFunction($name)
{
Expand Down Expand Up @@ -534,6 +536,8 @@ public function setCustomNumericFunctions(array $functions)
* @param string|callable $className Class name or a callable that returns the function.
*
* @return void
*
* @psalm-param class-string|callable $className
*/
public function addCustomDatetimeFunction($name, $className)
{
Expand All @@ -546,6 +550,8 @@ public function addCustomDatetimeFunction($name, $className)
* @param string $name
*
* @return string|null
*
* @psalm-return ?class-string $name
*/
public function getCustomDatetimeFunction($name)
{
Expand All @@ -567,6 +573,8 @@ public function getCustomDatetimeFunction($name)
* @param array $functions The map of custom DQL date/time functions.
*
* @return void
*
* @psalm-param array<string, string> $functions
*/
public function setCustomDatetimeFunctions(array $functions)
{
Expand Down Expand Up @@ -597,6 +605,8 @@ 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 Down Expand Up @@ -624,6 +634,8 @@ public function addCustomHydrationMode($modeName, $hydrator)
* @param string $cmfName
*
* @return void
*
* @psalm-param class-string $cmfName
*/
public function setClassMetadataFactoryName($cmfName)
{
Expand All @@ -632,6 +644,8 @@ public function setClassMetadataFactoryName($cmfName)

/**
* @return string
*
* @psalm-return class-string
*/
public function getClassMetadataFactoryName()
{
Expand All @@ -658,8 +672,10 @@ public function addFilter($name, $className)
*
* @param string $name The name of the filter.
*
* @return string The class name of the filter, or null if it is not
* @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 @@ -696,6 +712,8 @@ public function setDefaultRepositoryClassName($className)
* @since 2.2
*
* @return string
*
* @psalm-return class-string
*/
public function getDefaultRepositoryClassName()
{
Expand Down
7 changes: 6 additions & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ class ClassMetadataInfo implements ClassMetadata
* The name of the custom repository class used for the entity class.
* (Optional).
*
* @var string
* @var string|null
* @psalm-var ?class-string
*/
public $customRepositoryClassName;

Expand Down Expand Up @@ -2626,6 +2627,8 @@ protected function _storeAssociationMapping(array $assocMapping)
* @param string $repositoryClassName The class name of the custom mapper.
*
* @return void
*
* @psalm-param class-string $repositoryClassName
*/
public function setCustomRepositoryClass($repositoryClassName)
{
Expand Down Expand Up @@ -3254,6 +3257,8 @@ public function getAssociationsByTargetClass($targetClass)
* @param string|null $className
*
* @return string|null null if the input value is null
*
* @psalm-param ?class-string $className
*/
public function fullyQualifiedClassName($className)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class DefaultEntityListenerResolver implements EntityListenerResolver
{
/**
* @var array Map to store entity listener instances.
*
* @psalm-var array<class-string, object>
*/
private $instances = [];

Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Mapping/EntityListenerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ interface EntityListenerResolver
* @param string $className The fully-qualified class name
*
* @return void
*
* @psalm-param class-string $className
*/
function clear($className = null);

Expand All @@ -43,6 +45,8 @@ function clear($className = null);
* @param string $className The fully-qualified class name
*
* @return object An entity listener
*
* @psalm-param class-string $className
*/
function resolve($className);

Expand Down
3 changes: 3 additions & 0 deletions lib/Doctrine/ORM/Query/FilterCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace Doctrine\ORM\Query;

use Doctrine\ORM\EntityManagerInterface;
use function assert;

/**
* Collection class for all the query filters.
Expand Down Expand Up @@ -110,6 +111,8 @@ public function enable($name)
if ( ! $this->isEnabled($name)) {
$filterClass = $this->config->getFilterClassName($name);

assert($filterClass !== null);

$this->enabledFilters[$name] = new $filterClass($this->em);

// Keep the enabled filters sorted for the hash
Expand Down
6 changes: 6 additions & 0 deletions lib/Doctrine/ORM/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Parser
* READ-ONLY: Maps BUILT-IN string function names to AST class names.
*
* @var array
*
* @psalm-var class-string<Functions\FunctionNode>
*/
private static $_STRING_FUNCTIONS = [
'concat' => Functions\ConcatFunction::class,
Expand All @@ -56,6 +58,8 @@ class Parser
* READ-ONLY: Maps BUILT-IN numeric function names to AST class names.
*
* @var array
*
* @psalm-var class-string<Functions\FunctionNode>
*/
private static $_NUMERIC_FUNCTIONS = [
'length' => Functions\LengthFunction::class,
Expand All @@ -80,6 +84,8 @@ class Parser
* READ-ONLY: Maps BUILT-IN datetime function names to AST class names.
*
* @var array
*
* @psalm-var class-string<Functions\FunctionNode>
*/
private static $_DATETIME_FUNCTIONS = [
'current_date' => Functions\CurrentDateFunction::class,
Expand Down
8 changes: 6 additions & 2 deletions lib/Doctrine/ORM/Query/SqlWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class SqlWalker implements TreeWalker
* Map of all components/classes that appear in the DQL query.
*
* @var array
*
* @psalm-var array<string, array{metadata: ClassMetadata}>
*/
private $queryComponents;

Expand Down Expand Up @@ -199,7 +201,7 @@ public function __construct($query, $parserResult, array $queryComponents)
/**
* Gets the Query instance used by the walker.
*
* @return Query.
* @return Query
*/
public function getQuery()
{
Expand Down Expand Up @@ -232,6 +234,8 @@ public function getEntityManager()
* @param string $dqlAlias The DQL alias.
*
* @return array
*
* @psalm-return array{metadata: ClassMetadata}
*/
public function getQueryComponent($dqlAlias)
{
Expand Down Expand Up @@ -1522,7 +1526,7 @@ public function walkSimpleSelectClause($simpleSelectClause)
/**
* @param \Doctrine\ORM\Query\AST\ParenthesisExpression $parenthesisExpression
*
* @return string.
* @return string
*/
public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesisExpression)
{
Expand Down
8 changes: 5 additions & 3 deletions lib/Doctrine/ORM/Tools/Console/MetadataFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Doctrine\ORM\Tools\Console;

use Doctrine\Common\Persistence\Mapping\ClassMetadata;

/**
* Used by CLI Tools to restrict entity-based commands to given patterns.
*
Expand All @@ -40,10 +42,10 @@ class MetadataFilter extends \FilterIterator implements \Countable
/**
* Filter Metadatas by one or more filter options.
*
* @param array $metadatas
* @param array|string $filter
* @param ClassMetadata[] $metadatas
* @param string[]|string $filter
*
* @return array
* @return ClassMetadata[]
*/
static public function filter(array $metadatas, $filter)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class EntityGenerator
/**
* Whether or not to make generated embeddables immutable.
*
* @var boolean.
* @var bool
*/
protected $embeddablesImmutable = false;

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ public function merge($entity)
* @param object $entity
* @param array $visited
* @param object|null $prevManagedCopy
* @param array|null $assoc
* @param string[] $assoc
*
* @return object The managed copy of the entity.
*
Expand Down