Skip to content

Commit

Permalink
add psalm types
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Jan 25, 2020
1 parent a236a83 commit 38eb578
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 9 deletions.
20 changes: 19 additions & 1 deletion lib/Doctrine/ORM/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ public function addCustomStringFunction($name, $className)
* @param string $name
*
* @return string|null
* @psalm-return ?class-string
*/
public function getCustomStringFunction($name)
{
Expand Down Expand Up @@ -493,6 +494,7 @@ public function addCustomNumericFunction($name, $className)
* @param string $name
*
* @return string|null
* @psalm-return ?class-string
*/
public function getCustomNumericFunction($name)
{
Expand Down Expand Up @@ -533,6 +535,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 @@ -545,6 +549,8 @@ public function addCustomDatetimeFunction($name, $className)
* @param string $name
*
* @return string|null
*
* @psalm-return ?class-string $name
*/
public function getCustomDatetimeFunction($name)
{
Expand All @@ -566,6 +572,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 @@ -596,6 +604,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 @@ -623,6 +633,8 @@ public function addCustomHydrationMode($modeName, $hydrator)
* @param string $cmfName
*
* @return void
*
* @psalm-param class-string $cmfName
*/
public function setClassMetadataFactoryName($cmfName)
{
Expand All @@ -631,6 +643,8 @@ public function setClassMetadataFactoryName($cmfName)

/**
* @return string
*
* @psalm-return class-string
*/
public function getClassMetadataFactoryName()
{
Expand All @@ -657,8 +671,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 @@ -695,6 +711,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 @@ -251,7 +251,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 @@ -2625,6 +2626,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 @@ -3253,6 +3256,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
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 @@ -136,6 +136,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, mixed}>
*/
private $queryComponents;

Expand Down Expand Up @@ -193,7 +195,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 @@ -226,6 +228,8 @@ public function getEntityManager()
* @param string $dqlAlias The DQL alias.
*
* @return array
*
* @psalm-return array{metadata: ClassMetadata, mixed}
*/
public function getQueryComponent($dqlAlias)
{
Expand Down Expand Up @@ -1524,7 +1528,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

0 comments on commit 38eb578

Please sign in to comment.