From 6c25c26c92aff0035c38d12de8ecf543bc4d1133 Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Fri, 8 Dec 2023 22:44:45 +0100 Subject: [PATCH] remove phpdoc's phpstan prefix --- src/Bridges/NetteDI/IRepositoryFinder.php | 2 +- src/Bridges/NetteDI/OrmExtension.php | 13 +-- .../NetteDI/PhpDocRepositoryFinder.php | 12 +-- src/Bridges/NetteDI/RepositoryLoader.php | 8 +- src/Collection/ArrayCollection.php | 39 +++------ src/Collection/DbalCollection.php | 36 +++------ src/Collection/EmptyCollection.php | 3 - src/Collection/EntityIterator.php | 13 +-- .../Functions/BaseCompareFunction.php | 2 +- .../Functions/CollectionFunction.php | 6 +- .../Functions/FetchPropertyFunction.php | 6 +- .../Functions/JunctionFunctionTrait.php | 8 +- .../Functions/Result/DbalExpressionResult.php | 35 ++++---- .../Functions/Result/DbalTableJoin.php | 12 +-- src/Collection/HasManyCollection.php | 31 ++------ .../Helpers/ArrayCollectionHelper.php | 14 ++-- .../Helpers/DbalQueryBuilderHelper.php | 6 +- src/Collection/Helpers/FetchPairsHelper.php | 8 +- src/Collection/ICollection.php | 30 ++++--- src/Collection/IEntityPreloadContainer.php | 2 +- src/Collection/MultiEntityIterator.php | 17 +--- src/Collection/MutableArrayCollection.php | 2 +- src/Entity/Embeddable/EmbeddableContainer.php | 5 +- src/Entity/IEntityAwareProperty.php | 4 +- src/Entity/ImmutableDataTrait.php | 10 +-- src/Entity/Reflection/EntityMetadata.php | 17 ++-- src/Entity/Reflection/IMetadataParser.php | 4 +- .../Reflection/IMetadataParserFactory.php | 2 +- src/Entity/Reflection/MetadataParser.php | 66 ++++++---------- src/Entity/Reflection/ModifierParser.php | 15 ++-- .../PropertyRelationshipMetadata.php | 14 +--- src/Mapper/Dbal/Conventions/Conventions.php | 18 ++--- src/Mapper/Dbal/Conventions/IConventions.php | 9 +-- src/Mapper/Dbal/DbalMapper.php | 29 +++---- src/Mapper/Dbal/IPersistAutoupdateMapper.php | 2 +- .../Dbal/RelationshipMapperManyHasMany.php | 37 ++++----- .../Dbal/RelationshipMapperManyHasOne.php | 9 +-- .../Dbal/RelationshipMapperOneHasMany.php | 31 +++----- src/Mapper/IMapper.php | 20 ++--- src/Mapper/IRelationshipMapper.php | 4 +- src/Mapper/IRelationshipMapperManyHasMany.php | 6 +- src/Mapper/Memory/ArrayMapper.php | 24 +++--- src/Mapper/Memory/Conventions/Conventions.php | 8 +- .../Memory/Conventions/IConventions.php | 2 +- src/Model/IModel.php | 29 ++++--- src/Model/IRepositoryLoader.php | 12 +-- src/Model/MetadataStorage.php | 3 +- src/Model/Model.php | 31 +++----- src/Model/SimpleModelFactory.php | 15 +--- src/Model/SimpleRepositoryLoader.php | 15 ++-- src/Relationships/HasMany.php | 51 ++++-------- src/Relationships/HasOne.php | 41 +++------- src/Relationships/IRelationshipCollection.php | 23 +++--- src/Relationships/IRelationshipContainer.php | 8 +- src/Repository/IRepository.php | 79 +++++++++---------- src/Repository/IdentityMap.php | 34 +++----- src/Repository/RemovalHelper.php | 2 +- src/Repository/Repository.php | 79 +++++-------------- src/TestHelper/EntityCreator.php | 6 +- src/TestHelper/TestCaseEntityTrait.php | 4 +- src/TestHelper/TestMapper.php | 2 +- 61 files changed, 401 insertions(+), 674 deletions(-) diff --git a/src/Bridges/NetteDI/IRepositoryFinder.php b/src/Bridges/NetteDI/IRepositoryFinder.php index 9aee0f36..525bf3ef 100644 --- a/src/Bridges/NetteDI/IRepositoryFinder.php +++ b/src/Bridges/NetteDI/IRepositoryFinder.php @@ -12,7 +12,7 @@ interface IRepositoryFinder { /** - * @phpstan-param class-string $modelClass + * @param class-string $modelClass */ public function __construct(string $modelClass, ContainerBuilder $containerBuilder, OrmExtension $extension); diff --git a/src/Bridges/NetteDI/OrmExtension.php b/src/Bridges/NetteDI/OrmExtension.php index b8be5d00..a758ea43 100644 --- a/src/Bridges/NetteDI/OrmExtension.php +++ b/src/Bridges/NetteDI/OrmExtension.php @@ -6,7 +6,6 @@ use Nette\Caching\Cache; use Nette\DI\CompilerExtension; use Nette\DI\ContainerBuilder; -use Nette\PhpGenerator\ClassType; use Nette\Schema\Expect; use Nette\Schema\Schema; use Nextras\Dbal\IConnection; @@ -20,7 +19,6 @@ use Nextras\Orm\Repository\IRepository; use stdClass; use function is_subclass_of; -use function method_exists; /** @@ -47,6 +45,7 @@ public function getConfigSchema(): Schema ]); } + public function loadConfiguration(): void { $this->builder = $this->getContainerBuilder(); @@ -89,6 +88,7 @@ public function beforeCompile(): void $this->setupDbalMapperDependencies(); } + protected function setupCache(): void { $cacheName = $this->prefix('cache'); @@ -168,10 +168,10 @@ protected function setupMetadataStorage(array $entityClassMap): void /** - * @phpstan-param array{ - * array>, true>, - * array>>, - * array, class-string<\Nextras\Orm\Repository\IRepository<\Nextras\Orm\Entity\IEntity>>> + * @param array{ + * array>, true>, + * array>>, + * array, class-string>> * } $repositoriesConfig */ protected function setupModel(string $modelClass, array $repositoriesConfig): void @@ -190,6 +190,7 @@ protected function setupModel(string $modelClass, array $repositoriesConfig): vo ]); } + protected function initializeMetadata(bool $init): void { if (!$init) { diff --git a/src/Bridges/NetteDI/PhpDocRepositoryFinder.php b/src/Bridges/NetteDI/PhpDocRepositoryFinder.php index 475877e8..c52e405b 100644 --- a/src/Bridges/NetteDI/PhpDocRepositoryFinder.php +++ b/src/Bridges/NetteDI/PhpDocRepositoryFinder.php @@ -16,10 +16,7 @@ class PhpDocRepositoryFinder implements IRepositoryFinder { - /** - * @var string - * @phpstan-var class-string - */ + /** @var class-string */ protected $modelClass; /** @var ContainerBuilder */ @@ -60,9 +57,8 @@ public function beforeCompile(): ?array /** - * @return array - * @phpstan-param class-string $modelClass - * @phpstan-return array>> + * @param class-string $modelClass + * @return array>> */ protected function findRepositories(string $modelClass): array { @@ -86,7 +82,7 @@ protected function findRepositories(string $modelClass): array * @var string $name */ foreach ($matches as [, $type, $name]) { - /** @phpstan-var class-string> $type */ + /** @var class-string> $type */ $type = Reflection::expandClassName($type, $modelReflection); if (!class_exists($type)) { throw new RuntimeException("Repository '{$type}' does not exist."); diff --git a/src/Bridges/NetteDI/RepositoryLoader.php b/src/Bridges/NetteDI/RepositoryLoader.php index b3876da6..1d6a9a8e 100644 --- a/src/Bridges/NetteDI/RepositoryLoader.php +++ b/src/Bridges/NetteDI/RepositoryLoader.php @@ -36,13 +36,13 @@ public function hasRepository(string $className): bool /** * Returns instance of repository. - * @template R of IRepository<\Nextras\Orm\Entity\IEntity> - * @phpstan-param class-string $className - * @phpstan-return R + * @template R of IRepository + * @param class-string $className + * @return R */ public function getRepository(string $className): IRepository { - /** @phpstan-var R */ + /** @var R */ return $this->container->getService($this->repositoryNamesMap[$className]); } diff --git a/src/Collection/ArrayCollection.php b/src/Collection/ArrayCollection.php index ca55bc72..3e4ba3e0 100644 --- a/src/Collection/ArrayCollection.php +++ b/src/Collection/ArrayCollection.php @@ -26,16 +26,10 @@ */ class ArrayCollection implements ICollection, MemoryCollection { - /** - * @var callable[] - * @phpstan-var list $entities): void> - */ + /** @var list $entities): void> */ public $onEntityFetch = []; - /** - * @var IEntity[] - * @phpstan-var list - */ + /** @var list */ protected $data; /** @var IRelationshipMapper|null */ @@ -44,31 +38,19 @@ class ArrayCollection implements ICollection, MemoryCollection /** @var IEntity|null */ protected $relationshipParent; - /** - * @var Iterator|null - * @phpstan-var Iterator|null - */ + /** @var Iterator|null */ protected $fetchIterator; - /** - * @var IRepository - * @phpstan-var IRepository - */ + /** @var IRepository */ protected $repository; /** @var ArrayCollectionHelper */ protected $helper; - /** - * @var Closure[] - * @phpstan-var array - */ + /** @var array */ protected $collectionFilter = []; - /** - * @var array - * @phpstan-var list - */ + /** @var list */ protected $collectionSorter = []; /** @var null|array{int, int|null} */ @@ -79,9 +61,8 @@ class ArrayCollection implements ICollection, MemoryCollection /** - * @param IEntity[] $entities - * @phpstan-param IRepository $repository - * @phpstan-param list $entities + * @param list $entities + * @param IRepository $repository */ public function __construct(array $entities, IRepository $repository) { @@ -199,7 +180,7 @@ public function fetchPairs(string $key = null, string $value = null): array /** * @param mixed[] $args - * @phpstan-return never + * @return never * @throws MemberAccessException */ public function __call(string $name, array $args) @@ -210,7 +191,7 @@ public function __call(string $name, array $args) /** - * @phpstan-return Iterator + * @return Iterator */ public function getIterator(): Iterator { diff --git a/src/Collection/DbalCollection.php b/src/Collection/DbalCollection.php index 78a1bad6..213cf0c8 100644 --- a/src/Collection/DbalCollection.php +++ b/src/Collection/DbalCollection.php @@ -25,10 +25,7 @@ */ class DbalCollection implements ICollection { - /** - * @var callable[] - * @phpstan-var list $entities): void> - */ + /** @var list $entities): void> */ public $onEntityFetch = []; /** @var IRelationshipMapper|null */ @@ -37,16 +34,10 @@ class DbalCollection implements ICollection /** @var IEntity|null */ protected $relationshipParent; - /** - * @var Iterator|null - * @phpstan-var Iterator|null - */ + /** @var Iterator|null */ protected $fetchIterator; - /** - * @var DbalMapper - * @phpstan-var DbalMapper - */ + /** @var DbalMapper */ protected $mapper; /** @var IConnection */ @@ -64,10 +55,7 @@ class DbalCollection implements ICollection /** @var DbalQueryBuilderHelper */ protected $helper; - /** - * @var IEntity[]|null - * @phpstan-var list|null - */ + /** @var list|null */ protected $result; /** @var int|null */ @@ -78,7 +66,7 @@ class DbalCollection implements ICollection /** - * @phpstan-param DbalMapper $mapper + * @param DbalMapper $mapper */ public function __construct(DbalMapper $mapper, IConnection $connection, QueryBuilder $queryBuilder) { @@ -129,7 +117,7 @@ public function orderBy($expression, string $direction = ICollection::ASC): ICol $collection = clone $this; $helper = $collection->getHelper(); if (is_array($expression) && !isset($expression[0])) { - /** @phpstan-var array $expression */ + /** @var array $expression */ $expression = $expression; // no-op for PHPStan foreach ($expression as $subExpression => $subDirection) { @@ -164,10 +152,6 @@ public function limitBy(int $limit, int $offset = null): ICollection } - /** - * @inheritDoc - * @phpstan-return E|null - */ public function fetch(): ?IEntity { if ($this->fetchIterator === null) { @@ -208,7 +192,7 @@ public function fetchPairs(string $key = null, string $value = null): array /** * @param mixed[] $args - * @phpstan-return never + * @return never * @throws MemberAccessException */ public function __call(string $name, array $args) @@ -219,12 +203,12 @@ public function __call(string $name, array $args) /** - * @phpstan-return Iterator + * @return Iterator */ public function getIterator(): Iterator { if ($this->relationshipParent !== null && $this->relationshipMapper !== null) { - /** @phpstan-var Iterator */ + /** @var Iterator $entityIterator */ $entityIterator = $this->relationshipMapper->getIterator($this->relationshipParent, $this); } else { if ($this->result === null) { @@ -232,7 +216,7 @@ public function getIterator(): Iterator } assert(is_array($this->result)); - /** @phpstan-var Iterator */ + /** @var Iterator $entityIterator */ $entityIterator = new EntityIterator($this->result); } diff --git a/src/Collection/EmptyCollection.php b/src/Collection/EmptyCollection.php index 23b7b5a6..34dbd2c4 100644 --- a/src/Collection/EmptyCollection.php +++ b/src/Collection/EmptyCollection.php @@ -93,9 +93,6 @@ public function fetchPairs(string $key = null, string $value = null): array } - /** - * @phpstan-return Iterator - */ public function getIterator(): Iterator { return new EmptyIterator(); diff --git a/src/Collection/EntityIterator.php b/src/Collection/EntityIterator.php index 4e60291c..f81dcf71 100644 --- a/src/Collection/EntityIterator.php +++ b/src/Collection/EntityIterator.php @@ -19,22 +19,15 @@ class EntityIterator implements IEntityPreloadContainer, Iterator, Countable /** @var int */ private $position = 0; - /** - * @var IEntity[] - * @phpstan-var list - */ + /** @var list */ private $iteratable; - /** - * @var array - * @phpstan-var array> - */ + /** @var array> */ private $preloadCache; /** - * @param IEntity[] $data - * @phpstan-param list $data + * @param list $data */ public function __construct(array $data) { diff --git a/src/Collection/Functions/BaseCompareFunction.php b/src/Collection/Functions/BaseCompareFunction.php index f2abf958..490148c0 100644 --- a/src/Collection/Functions/BaseCompareFunction.php +++ b/src/Collection/Functions/BaseCompareFunction.php @@ -81,7 +81,7 @@ abstract protected function evaluateInPhp(mixed $sourceValue, mixed $targetValue /** - * @phpstan-param literal-string $modifier + * @param literal-string $modifier */ abstract protected function evaluateInDb( DbalExpressionResult $expression, diff --git a/src/Collection/Functions/CollectionFunction.php b/src/Collection/Functions/CollectionFunction.php index 7519d285..62af6fef 100644 --- a/src/Collection/Functions/CollectionFunction.php +++ b/src/Collection/Functions/CollectionFunction.php @@ -25,8 +25,8 @@ interface CollectionFunction * Returns a value depending on values of entity; the expression passed by args is evaluated during this method * execution. * Usually returns a boolean for filtering evaluation. - * @phpstan-param array $args - * @phpstan-param IArrayAggregator|null $aggregator + * @param array $args + * @param IArrayAggregator|null $aggregator */ public function processArrayExpression( ArrayCollectionHelper $helper, @@ -39,7 +39,7 @@ public function processArrayExpression( /** * Returns true if entity should stay in the result collection; the condition is evaluated in database and this * method just returns appropriate Nextras Dbal's filtering expression for passed args. - * @phpstan-param array $args + * @param array $args */ public function processDbalExpression( DbalQueryBuilderHelper $helper, diff --git a/src/Collection/Functions/FetchPropertyFunction.php b/src/Collection/Functions/FetchPropertyFunction.php index 2d453da6..0b35d4b3 100644 --- a/src/Collection/Functions/FetchPropertyFunction.php +++ b/src/Collection/Functions/FetchPropertyFunction.php @@ -73,7 +73,7 @@ public function processArrayExpression( /** * @param string[] $expressionTokens - * @phpstan-param IArrayAggregator|null $aggregator + * @param IArrayAggregator|null $aggregator */ private function getValueByTokens( ArrayCollectionHelper $helper, @@ -327,7 +327,7 @@ private function processRelationship( $targetMapper->getManyHasManyParameters($sourceProperty, $currentMapper); } - /** @phpstan-var literal-string $joinAlias */ + /** @var literal-string $joinAlias */ $joinAlias = DbalQueryBuilderHelper::getAlias($joinTable, array_slice($tokens, 0, $tokenIndex)); $joins[] = new DbalTableJoin( toExpression: "%table", @@ -346,7 +346,7 @@ private function processRelationship( } $targetTable = $targetMapper->getTableName(); - /** @phpstan-var literal-string $targetAlias */ + /** @var literal-string $targetAlias */ $targetAlias = DbalQueryBuilderHelper::getAlias($tokens[$tokenIndex], array_slice($tokens, 0, $tokenIndex)); if ($makeDistinct) { $aggregator = $aggregator ?? new AnyAggregator(); diff --git a/src/Collection/Functions/JunctionFunctionTrait.php b/src/Collection/Functions/JunctionFunctionTrait.php index c1fdfb01..4c13c4aa 100644 --- a/src/Collection/Functions/JunctionFunctionTrait.php +++ b/src/Collection/Functions/JunctionFunctionTrait.php @@ -20,8 +20,8 @@ trait JunctionFunctionTrait { /** * Normalizes directly entered column => value expression to expression array. - * @phpstan-param array $args - * @phpstan-return array{list, IAggregator|null} + * @param array $args + * @return array{list, IAggregator|null} */ protected function normalizeFunctions(array $args): array { @@ -34,14 +34,14 @@ protected function normalizeFunctions(array $args): array // Originally called as [ICollection::AND, ['id' => 1], ['name' => John]] // Currency passed as [['id' => 1], ['name' => John] if (isset($args[0])) { - /** @phpstan-var list $args */ + /** @var list $args */ return [$args, $aggregator]; } // Args passed as keys // Originally called as [ICollection::AND, 'id' => 1, 'name!=' => John] // Currency passed as ['id' => 1, 'name' => John] - /** @phpstan-var array $args */ + /** @var array $args */ $processedArgs = []; foreach ($args as $argName => $argValue) { $functionCall = $this->conditionParser->parsePropertyOperator($argName); diff --git a/src/Collection/Functions/Result/DbalExpressionResult.php b/src/Collection/Functions/Result/DbalExpressionResult.php index 466ab062..20fc1edb 100644 --- a/src/Collection/Functions/Result/DbalExpressionResult.php +++ b/src/Collection/Functions/Result/DbalExpressionResult.php @@ -20,14 +20,13 @@ class DbalExpressionResult { /** * Holds expression separately from its arguments. - * @phpstan-var literal-string + * @var literal-string */ public readonly string $expression; /** * Expression's arguments. - * @var mixed[] - * @phpstan-var list + * @var list */ public readonly mixed $args; @@ -61,26 +60,17 @@ class DbalExpressionResult /** * Dbal modifier for particular column. Null if expression is a general expression. - * @phpstan-var literal-string|null + * @var literal-string|null */ public readonly ?string $dbalModifier; /** - * Value normalizer callback for proper matching backing property type. - * @var callable|null - * @phpstan-var (callable(mixed): mixed)|null - */ - public readonly mixed $valueNormalizer; - - - /** - * @param mixed[] $args + * @param literal-string $expression + * @param list $args * @param DbalTableJoin[] $joins * @param array> $groupBy * @param bool $isHavingClause - * @phpstan-param literal-string $expression - * @phpstan-param list $args - * @phpstan-param literal-string $dbalModifier + * @param literal-string $dbalModifier */ public function __construct( string $expression, @@ -110,11 +100,18 @@ public function __construct( } + /** + * Value normalizer callback for proper matching backing property type. + * @var (callable(mixed): mixed)|null + */ + public readonly mixed $valueNormalizer; + + /** * Appends SQL expression to the original expression. * If you need prepend or other complex expression, create new instance of DbalExpressionResult. - * @phpstan-param literal-string $expression - * @phpstan-param mixed ...$args + * @param literal-string $expression + * @param mixed ...$args */ public function append(string $expression, ...$args): DbalExpressionResult { @@ -139,7 +136,7 @@ public function getArgumentsForExpansion(): array /** * Creates a new DbalExpression from the passed $args and keeps the original expression * properties (joins, aggregator, ...). - * @phpstan-param literal-string $expression + * @param literal-string $expression * @param list $args */ public function withArgs(string $expression, array $args): DbalExpressionResult diff --git a/src/Collection/Functions/Result/DbalTableJoin.php b/src/Collection/Functions/Result/DbalTableJoin.php index 0547ad09..6d6e60d5 100644 --- a/src/Collection/Functions/Result/DbalTableJoin.php +++ b/src/Collection/Functions/Result/DbalTableJoin.php @@ -12,16 +12,16 @@ */ class DbalTableJoin { - /** @phpstan-var literal-string */ + /** @var literal-string */ public readonly string $toExpression; /** @var array */ public readonly array $toArgs; - /** @phpstan-var literal-string */ + /** @var literal-string */ public readonly string $toAlias; - /** @phpstan-var literal-string */ + /** @var literal-string */ public readonly string $onExpression; /** @var array */ @@ -33,9 +33,9 @@ class DbalTableJoin /** * @param array $toArgs * @param array $onArgs - * @phpstan-param literal-string $toExpression - * @phpstan-param literal-string $toAlias - * @phpstan-param literal-string $onExpression + * @param literal-string $toExpression + * @param literal-string $toAlias + * @param literal-string $onExpression */ public function __construct( string $toExpression, diff --git a/src/Collection/HasManyCollection.php b/src/Collection/HasManyCollection.php index aa72b2af..a32d1ab4 100644 --- a/src/Collection/HasManyCollection.php +++ b/src/Collection/HasManyCollection.php @@ -24,31 +24,19 @@ */ class HasManyCollection implements ICollection { - /** - * @var array of callbacks with $entities argument - * @phpstan-var array):void> - */ + /** @var array):void> */ public $onEntityFetch = []; /** @var IRepository */ private $repository; - /** - * @var ICollection - * @phpstan-var ICollection - */ + /** @var ICollection */ private $storageCollection; - /** - * @var MutableArrayCollection - * @phpstan-var MutableArrayCollection - */ + /** @var MutableArrayCollection */ private $inMemoryCollection; - /** - * @var callable A callback returning a list entities to add & remove. - * @phpstan-var callable(): array{array, array} - */ + /** @var callable(): array{array, array} */ private $diffCallback; /** @var Iterator|null */ @@ -56,9 +44,9 @@ class HasManyCollection implements ICollection /** - * @phpstan-param IRepository $repository - * @phpstan-param ICollection $innerCollection - * @phpstan-param callable():array{array, array} $diffCallback + * @param IRepository $repository + * @param ICollection $innerCollection + * @param callable():array{array, array} $diffCallback */ public function __construct( IRepository $repository, @@ -175,9 +163,6 @@ public function fetchPairs(string $key = null, string $value = null): array } - /** - * @phpstan-return Iterator - */ public function getIterator(): Iterator { [$toAdd, $toRemove] = ($this->diffCallback)(); @@ -263,7 +248,7 @@ public function subscribeOnEntityFetch(callable $callback): void /** * @param mixed[] $args - * @phpstan-return never + * @return never * @throws MemberAccessException */ public function __call(string $name, array $args) diff --git a/src/Collection/Helpers/ArrayCollectionHelper.php b/src/Collection/Helpers/ArrayCollectionHelper.php index 85c750e5..1cb00a65 100644 --- a/src/Collection/Helpers/ArrayCollectionHelper.php +++ b/src/Collection/Helpers/ArrayCollectionHelper.php @@ -34,9 +34,9 @@ public function __construct( /** - * @phpstan-param array $expr - * @phpstan-param IArrayAggregator|null $aggregator - * @phpstan-return Closure(IEntity): ArrayExpressionResult + * @param array $expr + * @param IArrayAggregator|null $aggregator + * @return Closure(IEntity): ArrayExpressionResult */ public function createFilter(array $expr, ?IArrayAggregator $aggregator): Closure { @@ -49,8 +49,8 @@ public function createFilter(array $expr, ?IArrayAggregator $aggregator): Closur /** - * @phpstan-param array|list> $expressions - * @phpstan-return Closure(IEntity, IEntity): int + * @param array|list> $expressions + * @return Closure(IEntity, IEntity): int */ public function createSorter(array $expressions): Closure { @@ -98,8 +98,8 @@ public function createSorter(array $expressions): Closure /** - * @phpstan-param string|array|list $expression - * @phpstan-param IArrayAggregator|null $aggregator + * @param string|array|list $expression + * @param IArrayAggregator|null $aggregator */ public function getValue( IEntity $entity, diff --git a/src/Collection/Helpers/DbalQueryBuilderHelper.php b/src/Collection/Helpers/DbalQueryBuilderHelper.php index ef6fced6..26d94a5b 100644 --- a/src/Collection/Helpers/DbalQueryBuilderHelper.php +++ b/src/Collection/Helpers/DbalQueryBuilderHelper.php @@ -33,7 +33,7 @@ class DbalQueryBuilderHelper { /** * Returns suitable table alias, strips db/schema name and prepends expression $tokens as part of the table name. - * @phpstan-param array $tokens + * @param array $tokens */ public static function getAlias(string|Fqn $name, array $tokens = []): string { @@ -68,7 +68,7 @@ public function __construct( * and the rest are function argument. If the function name is not present, an implicit * {@link ConjunctionOperatorFunction} is used. * - * @phpstan-param array|array|list|string $expression + * @param array|array|list|string $expression */ public function processExpression( QueryBuilder $builder, @@ -90,7 +90,7 @@ public function processExpression( /** - * @phpstan-return list + * @return list */ public function processOrderDirection(DbalExpressionResult $expression, string $direction): array { diff --git a/src/Collection/Helpers/FetchPairsHelper.php b/src/Collection/Helpers/FetchPairsHelper.php index 181054e9..261875d9 100644 --- a/src/Collection/Helpers/FetchPairsHelper.php +++ b/src/Collection/Helpers/FetchPairsHelper.php @@ -16,8 +16,7 @@ class FetchPairsHelper { /** * @param Traversable $collection - * @return mixed[] - * @phpstan-return array + * @return array */ public static function process(Traversable $collection, ?string $key, ?string $value): array { @@ -62,7 +61,7 @@ public static function process(Traversable $collection, ?string $key, ?string $v /** - * @phpstan-return list + * @return list */ private static function parseExpr(ConditionParser $conditionParser, string $expr): array { @@ -72,8 +71,7 @@ private static function parseExpr(ConditionParser $conditionParser, string $expr /** - * @phpstan-param list $chain - * @return mixed + * @param list $chain */ private static function getProperty(IEntity $row, array $chain): mixed { diff --git a/src/Collection/ICollection.php b/src/Collection/ICollection.php index 71aec9e4..404fd4fc 100644 --- a/src/Collection/ICollection.php +++ b/src/Collection/ICollection.php @@ -43,8 +43,8 @@ interface ICollection extends IteratorAggregate, Countable * * Limits collection via {@see ICollection::findBy()} and returns the first entity (or null). * - * @phpstan-param array|array $conds - * @phpstan-return E|null + * @param array|array $conds + * @return E|null */ public function getBy(array $conds): ?IEntity; @@ -54,9 +54,9 @@ public function getBy(array $conds): ?IEntity; * * Limits collection via {@see ICollection::findBy()} and returns the first entity (or throw). * - * @phpstan-param array|array $conds + * @param array|array $conds * @throws NoResultException - * @phpstan-return E + * @return E */ public function getByChecked(array $conds): IEntity; @@ -64,7 +64,7 @@ public function getByChecked(array $conds): IEntity; /** * Returns entity by primary value, null if none found. * @param mixed $id - * @phpstan-return E|null + * @return E|null */ public function getById($id): ?IEntity; @@ -73,7 +73,7 @@ public function getById($id): ?IEntity; * Returns entity by primary value, throws if none found. * @param mixed $id * @throws NoResultException - * @phpstan-return E + * @return E */ public function getByIdChecked($id): IEntity; @@ -108,7 +108,7 @@ public function getByIdChecked($id): IEntity; * ['property' => 'value2'], * ] * - * @phpstan-param array $conds + * @param array $conds * @return static */ public function findBy(array $conds): ICollection; @@ -140,9 +140,8 @@ public function findBy(array $conds): ICollection; * ICollection::DESC * ) * - * @param string|array $expression property name or property path expression (property->property) or "collection function" array expression. + * @param string|array|list $expression property name or property path expression (property->property) or "collection function" array expression. * @param string $direction the sorting direction self::ASC or self::DESC, etc. - * @phpstan-param string|array|list $expression * @return static */ public function orderBy($expression, string $direction = self::ASC): ICollection; @@ -164,7 +163,7 @@ public function limitBy(int $limit, int $offset = null): ICollection; /** * Fetches the first row. - * @phpstan-return E|null + * @return E|null */ public function fetch(): ?IEntity; @@ -172,7 +171,7 @@ public function fetch(): ?IEntity; /** * Fetches the first row., throw if none found. * @throws NoResultException - * @phpstan-return E + * @return E */ public function fetchChecked(): IEntity; @@ -180,7 +179,7 @@ public function fetchChecked(): IEntity; /** * Fetches all records. * @return IEntity[] - * @phpstan-return list + * @return list */ public function fetchAll(); @@ -189,14 +188,13 @@ public function fetchAll(); * Fetches all records like $key => $value pairs. * @param string|null $key associative key * @param string|null $value value - * @phpstan-return array + * @return array */ public function fetchPairs(?string $key = null, ?string $value = null): array; /** - * @return Iterator - * @phpstan-return Iterator + * @return Iterator */ public function getIterator(): Iterator; @@ -236,7 +234,7 @@ public function countStored(): int; /** - * @phpstan-param callable(\Traversable):void $callback + * @param callable(\Traversable):void $callback */ public function subscribeOnEntityFetch(callable $callback): void; } diff --git a/src/Collection/IEntityPreloadContainer.php b/src/Collection/IEntityPreloadContainer.php index 3bc4032e..7009d485 100644 --- a/src/Collection/IEntityPreloadContainer.php +++ b/src/Collection/IEntityPreloadContainer.php @@ -7,7 +7,7 @@ interface IEntityPreloadContainer { /** * Returns array of $property values for preloading. - * @phpstan-return list + * @return list */ public function getPreloadValues(string $property): array; } diff --git a/src/Collection/MultiEntityIterator.php b/src/Collection/MultiEntityIterator.php index d3311e93..b04b3434 100644 --- a/src/Collection/MultiEntityIterator.php +++ b/src/Collection/MultiEntityIterator.php @@ -19,27 +19,18 @@ class MultiEntityIterator implements IEntityPreloadContainer, Iterator, Countabl /** @var int */ private $position = 0; - /** - * @var IEntity[][] - * @phpstan-var array> - */ + /** @var array> */ private $data; - /** - * @var IEntity[] - * @phpstan-var list - */ + /** @var list */ private $iterable; - /** - * @var array - * @phpstan-var array> - */ + /** @var array> */ private $preloadCache; /** - * @phpstan-param array> $data + * @param array> $data */ public function __construct(array $data) { diff --git a/src/Collection/MutableArrayCollection.php b/src/Collection/MutableArrayCollection.php index 03412102..a1a64fee 100644 --- a/src/Collection/MutableArrayCollection.php +++ b/src/Collection/MutableArrayCollection.php @@ -11,7 +11,7 @@ class MutableArrayCollection extends ArrayCollection { /** - * @phpstan-param list $data + * @param list $data * @return static */ public function withData(array $data): ICollection diff --git a/src/Entity/Embeddable/EmbeddableContainer.php b/src/Entity/Embeddable/EmbeddableContainer.php index 281069a8..d6d4a543 100644 --- a/src/Entity/Embeddable/EmbeddableContainer.php +++ b/src/Entity/Embeddable/EmbeddableContainer.php @@ -34,10 +34,7 @@ class EmbeddableContainer implements IPropertyContainer, IEntityAwareProperty /** @var IEmbeddable|null */ private $value; - /** - * @var PropertyMetadata[] - * @phpstan-var array - */ + /** @var array */ private $propertiesMetadata = []; /** @var string */ diff --git a/src/Entity/IEntityAwareProperty.php b/src/Entity/IEntityAwareProperty.php index 02bfb72c..4c667f10 100644 --- a/src/Entity/IEntityAwareProperty.php +++ b/src/Entity/IEntityAwareProperty.php @@ -11,14 +11,14 @@ interface IEntityAwareProperty extends IProperty { /** * Executed when the IProperty is attached to an entity. - * @phpstan-param E $entity + * @param E $entity */ public function onEntityAttach(IEntity $entity): void; /** * Executed when the entity is attached to the repository. - * @phpstan-param E $entity + * @param E $entity */ public function onEntityRepositoryAttach(IEntity $entity): void; } diff --git a/src/Entity/ImmutableDataTrait.php b/src/Entity/ImmutableDataTrait.php index c99430df..9ec400ad 100644 --- a/src/Entity/ImmutableDataTrait.php +++ b/src/Entity/ImmutableDataTrait.php @@ -15,16 +15,10 @@ trait ImmutableDataTrait /** @var EntityMetadata */ protected $metadata; - /** - * @var array - * @phpstan-var array - */ + /** @var array */ private $data = []; - /** - * @var array - * @phpstan-var array - */ + /** @var array */ private $validated = []; diff --git a/src/Entity/Reflection/EntityMetadata.php b/src/Entity/Reflection/EntityMetadata.php index ed3e4983..1605f86a 100644 --- a/src/Entity/Reflection/EntityMetadata.php +++ b/src/Entity/Reflection/EntityMetadata.php @@ -19,16 +19,10 @@ class EntityMetadata /** @var class-string */ private $className; - /** - * @var array Primary key. - * @phpstan-var list - */ + /** @var list */ private $primaryKey = []; - /** - * @var PropertyMetadata[] - * @phpstan-var array - */ + /** @var array */ private $properties = []; @@ -48,7 +42,7 @@ public function getClassName(): string /** - * @phpstan-param list $primaryKey + * @param list $primaryKey * @return static */ public function setPrimaryKey(array $primaryKey): EntityMetadata @@ -59,7 +53,7 @@ public function setPrimaryKey(array $primaryKey): EntityMetadata /** - * @phpstan-return list + * @return list */ public function getPrimaryKey(): array { @@ -94,8 +88,7 @@ public function setProperty(string $name, PropertyMetadata $property): void /** - * @return PropertyMetadata[] - * @phpstan-return array + * @return array */ public function getProperties(): array { diff --git a/src/Entity/Reflection/IMetadataParser.php b/src/Entity/Reflection/IMetadataParser.php index e8aaefe9..293cfb8f 100644 --- a/src/Entity/Reflection/IMetadataParser.php +++ b/src/Entity/Reflection/IMetadataParser.php @@ -7,8 +7,8 @@ interface IMetadataParser { /** * Parses metadata for entity. - * @phpstan-param class-string $entityClass - * @phpstan-param list|null $fileDependencies + * @param class-string $entityClass + * @param list|null $fileDependencies */ public function parseMetadata(string $entityClass, ?array &$fileDependencies): EntityMetadata; } diff --git a/src/Entity/Reflection/IMetadataParserFactory.php b/src/Entity/Reflection/IMetadataParserFactory.php index 371b37c8..221eb7c2 100644 --- a/src/Entity/Reflection/IMetadataParserFactory.php +++ b/src/Entity/Reflection/IMetadataParserFactory.php @@ -12,7 +12,7 @@ interface IMetadataParserFactory /** * Creates metadata parser. * @param array $entityClassesMap - * @phpstan-param array, class-string>> $entityClassesMap + * @param array, class-string>> $entityClassesMap */ public function create(array $entityClassesMap): IMetadataParser; } diff --git a/src/Entity/Reflection/MetadataParser.php b/src/Entity/Reflection/MetadataParser.php index b3b6ae6d..bc1afe38 100644 --- a/src/Entity/Reflection/MetadataParser.php +++ b/src/Entity/Reflection/MetadataParser.php @@ -34,10 +34,7 @@ class MetadataParser implements IMetadataParser { - /** - * @var array - * @phpstan-var array - */ + /** @var array */ protected $modifiers = [ '1:1' => 'parseOneHasOneModifier', '1:m' => 'parseOneHasManyModifier', @@ -53,40 +50,28 @@ class MetadataParser implements IMetadataParser 'embeddable' => 'parseEmbeddableModifier', ]; - /** - * @var ReflectionClass - * @phpstan-var ReflectionClass - */ + /** @var ReflectionClass */ protected $reflection; - /** - * @var ReflectionClass - * @phpstan-var ReflectionClass - */ + /** @var ReflectionClass */ protected $currentReflection; /** @var EntityMetadata */ protected $metadata; - /** - * @var array - * @phpstan-var array, class-string>> - */ + /** @var array, class-string>> */ protected $entityClassesMap; /** @var ModifierParser */ protected $modifierParser; - /** - * @var array - * @phpstan-var array - */ + /** @var array */ protected $classPropertiesCache = []; /** * @param array $entityClassesMap - * @phpstan-param array, class-string>> $entityClassesMap + * @param array, class-string>> $entityClassesMap */ public function __construct(array $entityClassesMap) { @@ -121,7 +106,7 @@ public function parseMetadata(string $entityClass, ?array &$fileDependencies): E /** * @param string[] $fileDependencies - * @phpstan-param list $fileDependencies + * @param list $fileDependencies */ protected function loadProperties(?array &$fileDependencies): void { @@ -167,10 +152,9 @@ protected function loadProperties(?array &$fileDependencies): void /** - * @phpstan-param ReflectionClass $reflection - * @phpstan-param array $methods - * @return PropertyMetadata[] - * @phpstan-return array + * @param ReflectionClass $reflection + * @param array $methods + * @return array */ protected function parseAnnotations(ReflectionClass $reflection, array $methods): array { @@ -282,7 +266,7 @@ protected function parseAnnotationValue(PropertyMetadata $property, string $prop /** - * @phpstan-param array $methods + * @param array $methods */ protected function processPropertyGettersSetters(PropertyMetadata $property, array $methods): void { @@ -298,7 +282,7 @@ protected function processPropertyGettersSetters(PropertyMetadata $property, arr /** - * @phpstan-param array $args + * @param array $args */ protected function processPropertyModifier(PropertyMetadata $property, string $modifier, array $args): void { @@ -332,7 +316,7 @@ protected function processPropertyModifier(PropertyMetadata $property, string $m /** - * @phpstan-param array $args + * @param array $args */ protected function parseOneHasOneModifier(PropertyMetadata $property, array &$args): void { @@ -348,7 +332,7 @@ protected function parseOneHasOneModifier(PropertyMetadata $property, array &$ar /** - * @phpstan-param array $args + * @param array $args */ protected function parseOneHasManyModifier(PropertyMetadata $property, array &$args): void { @@ -364,7 +348,7 @@ protected function parseOneHasManyModifier(PropertyMetadata $property, array &$a /** - * @phpstan-param array $args + * @param array $args */ protected function parseManyHasOneModifier(PropertyMetadata $property, array &$args): void { @@ -377,7 +361,7 @@ protected function parseManyHasOneModifier(PropertyMetadata $property, array &$a /** - * @phpstan-param array $args + * @param array $args */ protected function parseManyHasManyModifier(PropertyMetadata $property, array &$args): void { @@ -394,7 +378,7 @@ protected function parseManyHasManyModifier(PropertyMetadata $property, array &$ /** - * @phpstan-param array $args + * @param array $args */ protected function parseEnumModifier(PropertyMetadata $property, array &$args): void { @@ -410,7 +394,7 @@ protected function parseVirtualModifier(PropertyMetadata $property): void /** - * @phpstan-param array $args + * @param array $args */ protected function parseContainerModifier(PropertyMetadata $property, array &$args): void { @@ -420,7 +404,7 @@ protected function parseContainerModifier(PropertyMetadata $property, array &$ar /** - * @phpstan-param array $args + * @param array $args */ protected function parseWrapperModifier(PropertyMetadata $property, array &$args): void { @@ -437,7 +421,7 @@ protected function parseWrapperModifier(PropertyMetadata $property, array &$args /** - * @phpstan-param array $args + * @param array $args */ protected function parseDefaultModifier(PropertyMetadata $property, array &$args): void { @@ -504,7 +488,7 @@ protected function initPrimaryKey(): void /** - * @phpstan-param array $args + * @param array $args */ protected function processRelationshipEntityProperty(PropertyMetadata $property, array &$args): void { @@ -555,7 +539,7 @@ protected function processRelationshipEntityProperty(PropertyMetadata $property, /** - * @phpstan-param array $args + * @param array $args */ protected function processRelationshipCascade(PropertyMetadata $property, array &$args): void { @@ -581,7 +565,7 @@ protected function processRelationshipCascade(PropertyMetadata $property, array /** - * @phpstan-param array $args + * @param array $args */ protected function processRelationshipOrder(PropertyMetadata $property, array &$args): void { @@ -606,7 +590,7 @@ protected function processRelationshipOrder(PropertyMetadata $property, array &$ /** - * @phpstan-param array $args + * @param array $args */ protected function processRelationshipExposeCollection(PropertyMetadata $property, array &$args): void { @@ -618,7 +602,7 @@ protected function processRelationshipExposeCollection(PropertyMetadata $propert /** - * @phpstan-param array $args + * @param array $args */ protected function processRelationshipIsMain(PropertyMetadata $property, array &$args): void { diff --git a/src/Entity/Reflection/ModifierParser.php b/src/Entity/Reflection/ModifierParser.php index 7cc0a7d7..7415c066 100644 --- a/src/Entity/Reflection/ModifierParser.php +++ b/src/Entity/Reflection/ModifierParser.php @@ -23,8 +23,7 @@ public function __construct() /** - * @return string[] - * @phpstan-return list + * @return list */ public function matchModifiers(string $input): array { @@ -40,8 +39,8 @@ public function matchModifiers(string $input): array /** - * @phpstan-param ReflectionClass $reflectionClass - * @phpstan-return array{string, array} + * @param ReflectionClass $reflectionClass + * @return array{string, array} * @throws InvalidModifierDefinitionException */ public function parse(string $string, ReflectionClass $reflectionClass): array @@ -75,8 +74,8 @@ private function processName(TokenStream $iterator): string /** - * @phpstan-param ReflectionClass $reflectionClass - * @phpstan-return array + * @param ReflectionClass $reflectionClass + * @return array */ private function processArgs( TokenStream $iterator, @@ -153,7 +152,7 @@ private function processArgs( /** - * @phpstan-param ReflectionClass $reflectionClass + * @param ReflectionClass $reflectionClass */ private function processValue(Token $token, ReflectionClass $reflectionClass): mixed { @@ -168,7 +167,7 @@ private function processValue(Token $token, ReflectionClass $reflectionClass): m /** - * @phpstan-param ReflectionClass $reflectionClass + * @param ReflectionClass $reflectionClass */ private function processKeyword(string $value, ReflectionClass $reflectionClass): mixed { diff --git a/src/Entity/Reflection/PropertyRelationshipMetadata.php b/src/Entity/Reflection/PropertyRelationshipMetadata.php index 15a10f9a..db51275d 100644 --- a/src/Entity/Reflection/PropertyRelationshipMetadata.php +++ b/src/Entity/Reflection/PropertyRelationshipMetadata.php @@ -14,15 +14,10 @@ class PropertyRelationshipMetadata public const MANY_HAS_ONE = 3; public const MANY_HAS_MANY = 4; - /** - * @var string - * @phpstan-var class-string> - */ + /** @var class-string> */ public $repository; - /** - * @var class-string - */ + /** @var class-string */ public $entity; /** @var EntityMetadata */ @@ -37,10 +32,7 @@ class PropertyRelationshipMetadata /** @var int */ public $type; - /** - * @var array|null - * @phpstan-var array|null - */ + /** @var array|null */ public $order; /** @var bool[] */ diff --git a/src/Mapper/Dbal/Conventions/Conventions.php b/src/Mapper/Dbal/Conventions/Conventions.php index e7e381a7..efcb08bd 100644 --- a/src/Mapper/Dbal/Conventions/Conventions.php +++ b/src/Mapper/Dbal/Conventions/Conventions.php @@ -57,8 +57,7 @@ class Conventions implements IConventions protected $entityMetadata; /** - * @var array - * @phpstan-var array{ + * @var array{ * array, * array, * array>, @@ -69,10 +68,7 @@ class Conventions implements IConventions /** @var array */ protected $modifiers; - /** - * @var array - * @phpstan-var list - */ + /** @var list */ protected $storagePrimaryKey = []; /** @var CachedPlatform */ @@ -328,8 +324,8 @@ public function getModifier(string $storageKey): ?string /** - * @phpstan-param string|Fqn $joinTable - * @phpstan-return array{string,string} + * @param string|Fqn $joinTable + * @return array{string,string} */ protected function findManyHasManyPrimaryColumns(string|Fqn $joinTable, Table $targetTable): array { @@ -371,7 +367,7 @@ protected function findManyHasManyPrimaryColumns(string|Fqn $joinTable, Table $t /** - * @phpstan-return array{ + * @return array{ * array, * array, * array>, @@ -397,7 +393,7 @@ protected function getDefaultMappings(): array $mappings[self::TO_STORAGE][$entityKey] = [$storageKey]; } - /** @phpstan-var list}> $toProcess */ + /** @var list}> $toProcess */ $toProcess = [[$this->entityMetadata, []]]; while (($entry = array_shift($toProcess)) !== null) { [$metadata, $tokens] = $entry; @@ -413,7 +409,7 @@ protected function getDefaultMappings(): array $baseTokens[] = $property->name; foreach ($subMetadata->getProperties() as $subProperty) { - /** @phpstan-var list $propertyTokens */ + /** @var list $propertyTokens */ $propertyTokens = $baseTokens; $propertyTokens[] = $subProperty->name; diff --git a/src/Mapper/Dbal/Conventions/IConventions.php b/src/Mapper/Dbal/Conventions/IConventions.php index 3873e4d9..37f8516c 100644 --- a/src/Mapper/Dbal/Conventions/IConventions.php +++ b/src/Mapper/Dbal/Conventions/IConventions.php @@ -18,7 +18,7 @@ public function getStorageTable(): Table; /** * Returns storage primary key name. - * @phpstan-return list + * @return list */ public function getStoragePrimaryKey(): array; @@ -66,7 +66,7 @@ public function getManyHasManyStorageName(IConventions $targetConventions): stri /** * Returns storage primary columns for m:m storage. * The first column leads to primary (main) table, the second column to secondary table. - * @phpstan-return array{string, string} + * @return array{string, string} */ public function getManyHasManyStoragePrimaryKeys(IConventions $targetConventions): array; @@ -100,7 +100,7 @@ public function setMapping( /** * Sets column modifier for data transformation to Nextras Dbal layer. - * @phpstan-param literal-string $saveModifier + * @param literal-string $saveModifier * @return static */ public function setModifier(string $storageKey, string $saveModifier): IConventions; @@ -108,8 +108,7 @@ public function setModifier(string $storageKey, string $saveModifier): IConventi /** * Returns column's modifier for Nextras Dbal layer. - * @return string|null - * @phpstan-return literal-string|null + * @return literal-string|null */ public function getModifier(string $storageKey): ?string; } diff --git a/src/Mapper/Dbal/DbalMapper.php b/src/Mapper/Dbal/DbalMapper.php index 76de1221..76fe87fd 100644 --- a/src/Mapper/Dbal/DbalMapper.php +++ b/src/Mapper/Dbal/DbalMapper.php @@ -45,7 +45,7 @@ abstract class DbalMapper implements IMapper * The must be in unescaped raw form. If you need to pass a database name/schema name, * define this property with Fqn instance. Use null for autodetection. * - * @phpstan-var literal-string|Fqn|null + * @var literal-string|Fqn|null */ protected string|Fqn|null $tableName = null; @@ -55,10 +55,7 @@ abstract class DbalMapper implements IMapper /** @var IRepository|null */ private $repository; - /** - * @var IRelationshipMapper[] - * @phpstan-var array - */ + /** @var array */ private $cacheRM = []; /** @var DbalMapperCoordinator */ @@ -110,7 +107,7 @@ public function findAll(): ICollection public function builder(): QueryBuilder { $tableName = $this->getTableName(); - /** @phpstan-var literal-string $alias */ + /** @var literal-string $alias */ $alias = DbalQueryBuilderHelper::getAlias($tableName); $builder = $this->connection->createQueryBuilder(); $builder->from("%table", $alias, $tableName); @@ -145,8 +142,7 @@ public function getTableName(): string|Fqn /** * Transforms value from mapper, which is not a collection. - * @param QueryBuilder|array|Result $data - * @phpstan-param QueryBuilder|list>|Result $data + * @param QueryBuilder|list>|Result $data * @return ICollection */ public function toCollection($data): ICollection @@ -183,8 +179,7 @@ public function toCollection($data): ICollection /** - * @param QueryBuilder|Result|Row|array $data - * @phpstan-param QueryBuilder|Result|Row|array $data + * @param QueryBuilder|Result|Row|array $data * @return E|null */ public function toEntity($data): ?IEntity @@ -227,7 +222,7 @@ public function clearCache(): void /** * @param DbalMapper $targetMapper - * @phpstan-return array{string|Fqn, array{string, string}} + * @return array{string|Fqn, array{string, string}} */ public function getManyHasManyParameters(PropertyMetadata $sourceProperty, DbalMapper $targetMapper): array { @@ -370,7 +365,7 @@ public function persist(IEntity $entity): void /** - * @phpstan-param array $data + * @param array $data */ protected function processInsert(IEntity $entity, array $data): void { @@ -389,8 +384,8 @@ protected function processInsert(IEntity $entity, array $data): void /** - * @phpstan-param array $data - * @phpstan-param array $primary + * @param array $data + * @param array $primary */ protected function processUpdate(IEntity $entity, array $data, array $primary): void { @@ -409,7 +404,7 @@ protected function processUpdate(IEntity $entity, array $data, array $primary): /** - * @phpstan-param list $args + * @param list $args */ protected function processAutoupdate(IEntity $entity, array $args): void { @@ -425,7 +420,7 @@ protected function processAutoupdate(IEntity $entity, array $args): void /** - * @phpstan-param list $args + * @param list $args */ protected function processPostgreAutoupdate(IEntity $entity, array $args): void { @@ -449,7 +444,7 @@ protected function processPostgreAutoupdate(IEntity $entity, array $args): void /** - * @phpstan-param list $args + * @param list $args */ protected function processMySQLAutoupdate(IEntity $entity, array $args): void { diff --git a/src/Mapper/Dbal/IPersistAutoupdateMapper.php b/src/Mapper/Dbal/IPersistAutoupdateMapper.php index 290bdae6..25988bab 100644 --- a/src/Mapper/Dbal/IPersistAutoupdateMapper.php +++ b/src/Mapper/Dbal/IPersistAutoupdateMapper.php @@ -7,7 +7,7 @@ interface IPersistAutoupdateMapper { /** * Returns re-selecting columns as expandable expression for Dbal's %ex modifier. - * @phpstan-return list + * @return list */ public function getAutoupdateReselectExpression(): array; } diff --git a/src/Mapper/Dbal/RelationshipMapperManyHasMany.php b/src/Mapper/Dbal/RelationshipMapperManyHasMany.php index c03f9e12..1fa33e7b 100644 --- a/src/Mapper/Dbal/RelationshipMapperManyHasMany.php +++ b/src/Mapper/Dbal/RelationshipMapperManyHasMany.php @@ -7,6 +7,7 @@ use Nextras\Dbal\IConnection; use Nextras\Dbal\Platforms\Data\Fqn; use Nextras\Dbal\QueryBuilder\QueryBuilder; +use Nextras\Dbal\Result\Row; use Nextras\Orm\Collection\DbalCollection; use Nextras\Orm\Collection\Helpers\DbalQueryBuilderHelper; use Nextras\Orm\Collection\ICollection; @@ -45,16 +46,10 @@ class RelationshipMapperManyHasMany implements IRelationshipMapperManyHasMany /** @var DbalMapper */ protected $targetMapper; - /** - * @var MultiEntityIterator[] - * @phpstan-var array - */ + /** @var array */ protected $cacheEntityIterators; - /** - * @var array - * @phpstan-var array> - */ + /** @var array> */ protected $cacheCounts; /** @var DbalMapperCoordinator */ @@ -135,12 +130,12 @@ protected function execute(DbalCollection $collection, IEntity $parent): MultiEn /** - * @phpstan-param list $values + * @param list $values */ private function fetchByTwoPassStrategy(QueryBuilder $builder, array $values): MultiEntityIterator { $sourceTable = $builder->getFromAlias(); - /** @phpstan-var literal-string $targetTable */ + /** @var literal-string $targetTable */ $targetTable = DbalQueryBuilderHelper::getAlias($this->joinTable); $builder = clone $builder; @@ -207,7 +202,7 @@ public function getIteratorCount(IEntity $parent, ICollection $collection): int /** * @param DbalCollection $collection - * @phpstan-return array + * @return array */ protected function executeCounts(DbalCollection $collection, IEntity $parent): array { @@ -229,13 +224,13 @@ protected function executeCounts(DbalCollection $collection, IEntity $parent): a /** - * @phpstan-param list $values - * @phpstan-return array + * @param list $values + * @return array */ private function fetchCounts(QueryBuilder $builder, array $values): array { $sourceTable = $builder->getFromAlias(); - /** @phpstan-var literal-string $targetTable */ + /** @var literal-string $targetTable */ $targetTable = DbalQueryBuilderHelper::getAlias($this->joinTable); $builder = clone $builder; @@ -300,8 +295,8 @@ public function remove(IEntity $parent, array $removeIds): void /** - * @phpstan-param list $entries - * @phpstan-return list> + * @param list $entries + * @return list> */ protected function buildList(IEntity $parent, array $entries): array { @@ -324,8 +319,8 @@ protected function buildList(IEntity $parent, array $entries): array /** - * @phpstan-param list $values - * @phpstan-return iterable<\Nextras\Dbal\Result\Row> + * @param list $values + * @return iterable */ protected function processMultiResult(QueryBuilder $builder, array $values, string $targetTable): iterable { @@ -354,8 +349,8 @@ protected function processMultiResult(QueryBuilder $builder, array $values, stri /** - * @phpstan-param list $values - * @phpstan-return iterable<\Nextras\Dbal\Result\Row> + * @param list $values + * @return iterable */ protected function processMultiCountResult(QueryBuilder $builder, array $values): iterable { @@ -392,7 +387,7 @@ protected function processMultiCountResult(QueryBuilder $builder, array $values) /** - * @phpstan-param list $values + * @param list $values */ protected function calculateCacheKey(QueryBuilder $builder, array $values): string { diff --git a/src/Mapper/Dbal/RelationshipMapperManyHasOne.php b/src/Mapper/Dbal/RelationshipMapperManyHasOne.php index eb805ab7..fe54f929 100644 --- a/src/Mapper/Dbal/RelationshipMapperManyHasOne.php +++ b/src/Mapper/Dbal/RelationshipMapperManyHasOne.php @@ -25,10 +25,7 @@ class RelationshipMapperManyHasOne implements IRelationshipMapper /** @var PropertyMetadata */ protected $metadata; - /** - * @var MultiEntityIterator[] - * @phpstan-var array - */ + /** @var array */ protected $cacheEntityIterators; /** @var DbalMapper */ @@ -89,7 +86,7 @@ protected function execute(DbalCollection $collection, IEntity $parent): MultiEn /** - * @phpstan-param list $values + * @param list $values */ protected function fetch(QueryBuilder $builder, array $values): MultiEntityIterator { @@ -119,7 +116,7 @@ protected function fetch(QueryBuilder $builder, array $values): MultiEntityItera /** - * @phpstan-param list $values + * @param list $values */ protected function calculateCacheKey(QueryBuilder $builder, array $values): string { diff --git a/src/Mapper/Dbal/RelationshipMapperOneHasMany.php b/src/Mapper/Dbal/RelationshipMapperOneHasMany.php index 15b86c50..094c8997 100644 --- a/src/Mapper/Dbal/RelationshipMapperOneHasMany.php +++ b/src/Mapper/Dbal/RelationshipMapperOneHasMany.php @@ -6,6 +6,7 @@ use Iterator; use Nextras\Dbal\IConnection; use Nextras\Dbal\QueryBuilder\QueryBuilder; +use Nextras\Dbal\Result\Row; use Nextras\Orm\Collection\DbalCollection; use Nextras\Orm\Collection\ICollection; use Nextras\Orm\Collection\MultiEntityIterator; @@ -43,16 +44,10 @@ class RelationshipMapperOneHasMany implements IRelationshipMapper /** @var string */ protected $joinStorageKey; - /** - * @var MultiEntityIterator[] - * @phpstan-var array - */ + /** @var array */ protected $cacheEntityIterators; - /** - * @var array - * @phpstan-var array> - */ + /** @var array> */ protected $cacheCounts; @@ -122,7 +117,7 @@ protected function execute(DbalCollection $collection, IEntity $parent): MultiEn /** - * @phpstan-param list $values + * @param list $values */ protected function fetchByOnePassStrategy(QueryBuilder $builder, array $values): MultiEntityIterator { @@ -147,7 +142,7 @@ protected function fetchByOnePassStrategy(QueryBuilder $builder, array $values): /** - * @phpstan-param list $values + * @param list $values */ protected function fetchByTwoPassStrategy(QueryBuilder $builder, array $values): MultiEntityIterator { @@ -226,7 +221,7 @@ public function getIteratorCount(IEntity $parent, ICollection $collection): int /** * @param DbalCollection $collection - * @phpstan-return array + * @return array */ protected function executeCounts(DbalCollection $collection, IEntity $parent): array { @@ -248,8 +243,8 @@ protected function executeCounts(DbalCollection $collection, IEntity $parent): a /** - * @phpstan-param list $values - * @phpstan-return array + * @param list $values + * @return array */ private function fetchCounts(QueryBuilder $builder, array $values): array { @@ -300,8 +295,8 @@ private function fetchCounts(QueryBuilder $builder, array $values): array /** - * @phpstan-param list $values - * @phpstan-return iterable<\Nextras\Dbal\Result\Row> + * @param list $values + * @return iterable */ protected function processMultiResult(QueryBuilder $builder, array $values): iterable { @@ -330,8 +325,8 @@ protected function processMultiResult(QueryBuilder $builder, array $values): ite /** - * @phpstan-param list $values - * @return iterable<\Nextras\Dbal\Result\Row> + * @param list $values + * @return iterable */ protected function processMultiCountResult(QueryBuilder $builder, array $values): iterable { @@ -370,7 +365,7 @@ protected function processMultiCountResult(QueryBuilder $builder, array $values) /** - * @phpstan-param list $values + * @param list $values */ protected function calculateCacheKey(QueryBuilder $builder, array $values): string { diff --git a/src/Mapper/IMapper.php b/src/Mapper/IMapper.php index 0d9a1d0e..95ed0c0b 100644 --- a/src/Mapper/IMapper.php +++ b/src/Mapper/IMapper.php @@ -16,55 +16,55 @@ interface IMapper { /** * Returns all entities. - * @phpstan-return ICollection + * @return ICollection */ public function findAll(): ICollection; /** * Creates collection with HasOne mapper. - * @phpstan-return ICollection + * @return ICollection */ public function createCollectionManyHasOne(PropertyMetadata $metadata): ICollection; /** * Creates collection with OneHasOneDirected mapper. - * @phpstan-return ICollection + * @return ICollection */ public function createCollectionOneHasOne(PropertyMetadata $metadata): ICollection; /** * Creates collection with ManyHasMany mapper. - * @phpstan-param IMapper $sourceMapper - * @phpstan-return ICollection + * @param IMapper $sourceMapper + * @return ICollection */ public function createCollectionManyHasMany(IMapper $sourceMapper, PropertyMetadata $metadata): ICollection; /** * Creates collection with OneHasMany mapper. - * @phpstan-return ICollection + * @return ICollection */ public function createCollectionOneHasMany(PropertyMetadata $metadata): ICollection; /** - * @phpstan-param IRepository $repository + * @param IRepository $repository */ public function setRepository(IRepository $repository): void; /** - * @phpstan-return IRepository + * @return IRepository */ public function getRepository(): IRepository; /** * Persist entity and return new id. - * @phpstan-param E $entity + * @param E $entity * @internal * @see IRepository::persist() */ @@ -72,7 +72,7 @@ public function persist(IEntity $entity): void; /** - * @phpstan-param E $entity + * @param E $entity * @see IRepository::remove() */ public function remove(IEntity $entity): void; diff --git a/src/Mapper/IRelationshipMapper.php b/src/Mapper/IRelationshipMapper.php index 72251861..9f2c5571 100644 --- a/src/Mapper/IRelationshipMapper.php +++ b/src/Mapper/IRelationshipMapper.php @@ -12,7 +12,7 @@ interface IRelationshipMapper { /** * Returns iterator. - * @phpstan-param ICollection $collection + * @param ICollection $collection * @return Iterator */ public function getIterator(IEntity $parent, ICollection $collection): Iterator; @@ -20,7 +20,7 @@ public function getIterator(IEntity $parent, ICollection $collection): Iterator; /** * Returns iterator's counts. - * @phpstan-param ICollection $collection + * @param ICollection $collection */ public function getIteratorCount(IEntity $parent, ICollection $collection): int; diff --git a/src/Mapper/IRelationshipMapperManyHasMany.php b/src/Mapper/IRelationshipMapperManyHasMany.php index a7ced56a..c1defe6d 100644 --- a/src/Mapper/IRelationshipMapperManyHasMany.php +++ b/src/Mapper/IRelationshipMapperManyHasMany.php @@ -10,16 +10,14 @@ interface IRelationshipMapperManyHasMany extends IRelationshipMapper { /** * Adds entity relationships with passed ids. - * @param mixed[] $addIds array of ids (part of composite PK) to be inserted - * @phpstan-param list $addIds + * @param list $addIds array of ids (part of composite PK) to be inserted */ public function add(IEntity $parent, array $addIds): void; /** * Removes entity relationships with passed ids. - * @param mixed[] $removeIds array of ids (part of composite PK) to be removed - * @phpstan-param list $removeIds + * @param list $removeIds array of ids (part of composite PK) to be removed */ public function remove(IEntity $parent, array $removeIds): void; } diff --git a/src/Mapper/Memory/ArrayMapper.php b/src/Mapper/Memory/ArrayMapper.php index cb9654ea..92744266 100644 --- a/src/Mapper/Memory/ArrayMapper.php +++ b/src/Mapper/Memory/ArrayMapper.php @@ -26,16 +26,10 @@ */ abstract class ArrayMapper implements IMapper { - /** - * @var array - * @phpstan-var array|null - */ + /** @var array|null */ protected $data; - /** - * @var array - * @phpstan-var array> - */ + /** @var array> */ protected $relationshipData = []; /** @var IConventions */ @@ -65,7 +59,7 @@ public function getRepository(): IRepository $name = get_class($this); throw new InvalidStateException("Mapper '$name' is not attached to repository."); } - /** @phpstan-var IRepository */ + /** @var IRepository */ return $this->repository; } @@ -77,8 +71,8 @@ public function findAll(): ICollection /** - * @phpstan-param list $data - * @phpstan-return ICollection + * @param list $data + * @return ICollection */ public function toCollection(array $data): ICollection { @@ -131,7 +125,7 @@ public function clearCache(): void /** - * @phpstan-return array + * @return array */ public function &getRelationshipDataStorage(string $key): array { @@ -230,7 +224,7 @@ protected function initializeData(): void /** - * @phpstan-return list + * @return list */ protected function getData(): array { @@ -319,7 +313,7 @@ function ($id): string { /** * Reads stored data - * @phpstan-return array{ + * @return array{ * 0?: array, * 1?: array> * } @@ -329,7 +323,7 @@ abstract protected function readData(): array; /** * Stores data - * @phpstan-param array{ + * @param array{ * 0?: array, * 1?: array> * } $data diff --git a/src/Mapper/Memory/Conventions/Conventions.php b/src/Mapper/Memory/Conventions/Conventions.php index 0a291e2a..fba91bcf 100644 --- a/src/Mapper/Memory/Conventions/Conventions.php +++ b/src/Mapper/Memory/Conventions/Conventions.php @@ -11,16 +11,12 @@ class Conventions implements IConventions use SmartObject; - /** - * @var string[] - * @phpstan-var list - */ + /** @var list */ private $primaryKeys; /** - * @param string[] $primaryKeys - * @phpstan-param list $primaryKeys + * @param list $primaryKeys */ public function __construct(array $primaryKeys) { diff --git a/src/Mapper/Memory/Conventions/IConventions.php b/src/Mapper/Memory/Conventions/IConventions.php index 1bb63218..a1b55349 100644 --- a/src/Mapper/Memory/Conventions/IConventions.php +++ b/src/Mapper/Memory/Conventions/IConventions.php @@ -7,7 +7,7 @@ interface IConventions { /** * Returns storage primary key name. - * @phpstan-return list + * @return list */ public function getStoragePrimaryKey(): array; diff --git a/src/Model/IModel.php b/src/Model/IModel.php index a9c9ee19..0858c279 100644 --- a/src/Model/IModel.php +++ b/src/Model/IModel.php @@ -17,7 +17,7 @@ public function hasRepositoryByName(string $name): bool; /** * Returns repository by repository name. - * @phpstan-return IRepository + * @return IRepository */ public function getRepositoryByName(string $name): IRepository; @@ -25,7 +25,7 @@ public function getRepositoryByName(string $name): IRepository; /** * Returns true if repository class is attached to model. * @template T of IRepository - * @phpstan-param class-string $className + * @param class-string $className */ public function hasRepository(string $className): bool; @@ -34,18 +34,17 @@ public function hasRepository(string $className): bool; * Returns repository by repository class. * @template E of IEntity * @template T of IRepository - * @phpstan-param class-string $className - * @phpstan-return T + * @param class-string $className + * @return T */ public function getRepository(string $className): IRepository; /** * Returns repository associated for entity type. - * @param IEntity|string $entity * @template E of IEntity - * @phpstan-param E|class-string $entity - * @phpstan-return IRepository + * @param E|class-string $entity + * @return IRepository */ public function getRepositoryForEntity($entity): IRepository; @@ -59,8 +58,8 @@ public function getMetadataStorage(): MetadataStorage; /** * Persist the entity with cascade. * @template E of IEntity - * @phpstan-param E $entity - * @phpstan-return E + * @param E $entity + * @return E */ public function persist(IEntity $entity, bool $withCascade = true): IEntity; @@ -68,8 +67,8 @@ public function persist(IEntity $entity, bool $withCascade = true): IEntity; /** * Persist the entity with cascade and flushes the model. * @template E of IEntity - * @phpstan-param E $entity - * @phpstan-return E + * @param E $entity + * @return E */ public function persistAndFlush(IEntity $entity): IEntity; @@ -77,8 +76,8 @@ public function persistAndFlush(IEntity $entity): IEntity; /** * Removes the entity with cascade. * @template E of IEntity - * @phpstan-param E $entity - * @phpstan-return E + * @param E $entity + * @return E */ public function remove(IEntity $entity, bool $withCascade = true): IEntity; @@ -86,8 +85,8 @@ public function remove(IEntity $entity, bool $withCascade = true): IEntity; /** * Removes the entity with cascade and flushes the model. * @template E of IEntity - * @phpstan-param E $entity - * @phpstan-return E + * @param E $entity + * @return E */ public function removeAndFlush(IEntity $entity, bool $withCascade = true): IEntity; diff --git a/src/Model/IRepositoryLoader.php b/src/Model/IRepositoryLoader.php index 28ebb156..9768c81b 100644 --- a/src/Model/IRepositoryLoader.php +++ b/src/Model/IRepositoryLoader.php @@ -11,24 +11,24 @@ interface IRepositoryLoader { /** * Returns true if repository exists. - * @phpstan-param class-string> $className + * @param class-string> $className */ public function hasRepository(string $className): bool; /** * Returns instance of repository. - * @template T of IRepository<\Nextras\Orm\Entity\IEntity> - * @phpstan-param class-string $className - * @phpstan-return T + * @template T of IRepository + * @param class-string $className + * @return T */ public function getRepository(string $className): IRepository; /** * Checks, if repository has been already created. - * @template T of IRepository<\Nextras\Orm\Entity\IEntity> - * @phpstan-param class-string $className + * @template T of IRepository + * @param class-string $className */ public function isCreated(string $className): bool; } diff --git a/src/Model/MetadataStorage.php b/src/Model/MetadataStorage.php index 1b4badd6..e170e6b7 100644 --- a/src/Model/MetadataStorage.php +++ b/src/Model/MetadataStorage.php @@ -37,8 +37,7 @@ public static function get(string $className): EntityMetadata /** - * @param array $entityClassesMap - * @phpstan-param array, class-string>> $entityClassesMap + * @param array, class-string>> $entityClassesMap */ public function __construct( array $entityClassesMap, diff --git a/src/Model/Model.php b/src/Model/Model.php index c2deec9e..c1103dff 100644 --- a/src/Model/Model.php +++ b/src/Model/Model.php @@ -23,10 +23,7 @@ class Model implements IModel use SmartObject; - /** - * @var callable[] - * @phpstan-var list - */ + /** @var list */ public $onFlush = []; /** @var IRepositoryLoader */ @@ -36,8 +33,7 @@ class Model implements IModel private $metadataStorage; /** - * @var array - * @phpstan-var array{ + * @var array{ * array>, true>, * array>>, * array, class-string>> @@ -48,9 +44,8 @@ class Model implements IModel /** * Creates repository list configuration. - * @param IRepository[]|string[] $repositories - * @phpstan-param array>|IRepository> $repositories - * @phpstan-return array{ + * @param array>|IRepository> $repositories + * @return array{ * array>, true>, * array>>, * array, class-string>> @@ -61,8 +56,7 @@ public static function getConfiguration(array $repositories): array $config = [[], [], []]; foreach ($repositories as $name => $repository) { /** - * @var string $className - * @phpstan-var class-string> $className + * @var class-string> $className */ $className = is_object($repository) ? get_class($repository) : $repository; $config[0][$className] = true; @@ -76,7 +70,7 @@ public static function getConfiguration(array $repositories): array /** - * @phpstan-param array{ + * @param array{ * array>, true>, * array>>, * array, class-string>> @@ -119,8 +113,8 @@ public function hasRepository(string $className): bool * Returns repository by repository class. * @template E of IEntity * @template T of IRepository - * @phpstan-param class-string $className - * @phpstan-return T + * @param class-string $className + * @return T */ public function getRepository(string $className): IRepository { @@ -134,8 +128,8 @@ public function getRepository(string $className): IRepository /** * @template E of IEntity - * @phpstan-param E|class-string $entity - * @phpstan-return IRepository + * @param E|class-string $entity + * @return IRepository */ public function getRepositoryForEntity($entity): IRepository { @@ -241,7 +235,7 @@ public function refreshAll(bool $allowOverwrite = false): void /** * Returns repository by name. - * @phpstan-return IRepository + * @return IRepository */ public function &__get(string $name): IRepository { @@ -251,8 +245,7 @@ public function &__get(string $name): IRepository /** - * @return IRepository[] - * @phpstan-return list> + * @return list> */ private function getLoadedRepositories(): array { diff --git a/src/Model/SimpleModelFactory.php b/src/Model/SimpleModelFactory.php index d227d3bb..aa3d31ce 100644 --- a/src/Model/SimpleModelFactory.php +++ b/src/Model/SimpleModelFactory.php @@ -16,10 +16,7 @@ class SimpleModelFactory /** @var Cache */ private $cache; - /** - * @var IRepository[] - * @phpstan-var array> - */ + /** @var array> */ private $repositories; /** @var IMetadataParserFactory|null */ @@ -27,9 +24,8 @@ class SimpleModelFactory /** - * @param array $repositories - * @template E of \Nextras\Orm\Entity\IEntity - * @phpstan-param array> $repositories + * @template E of IEntity + * @param array> $repositories */ public function __construct(Cache $cache, array $repositories, IMetadataParserFactory $metadataParserFactory = null) { @@ -39,10 +35,7 @@ public function __construct(Cache $cache, array $repositories, IMetadataParserFa } - /** - * @return Model - */ - public function create() + public function create(): Model { $config = Model::getConfiguration($this->repositories); $parser = $this->metadataParserFactory ?? new MetadataParserFactory(); diff --git a/src/Model/SimpleRepositoryLoader.php b/src/Model/SimpleRepositoryLoader.php index b82a22ff..24b99ba6 100644 --- a/src/Model/SimpleRepositoryLoader.php +++ b/src/Model/SimpleRepositoryLoader.php @@ -10,15 +10,12 @@ class SimpleRepositoryLoader implements IRepositoryLoader { - /** - * @var IRepository[] - * @phpstan-var array>, IRepository> - */ + /** @var array>, IRepository> */ private $repositories = []; /** - * @phpstan-param list> $repositories + * @param list> $repositories */ public function __construct(array $repositories) { @@ -36,16 +33,16 @@ public function hasRepository(string $className): bool /** * Returns instance of repository. - * @template T of IRepository<\Nextras\Orm\Entity\IEntity> - * @phpstan-param class-string $className - * @phpstan-return T + * @template T of IRepository + * @param class-string $className + * @return T */ public function getRepository(string $className): IRepository { if (!isset($this->repositories[$className])) { throw new InvalidArgumentException("Repository '$className' not defined."); } - /** @phpstan-var T */ + /** @var T */ return $this->repositories[$className]; } diff --git a/src/Relationships/HasMany.php b/src/Relationships/HasMany.php index 1d37227c..f813a738 100644 --- a/src/Relationships/HasMany.php +++ b/src/Relationships/HasMany.php @@ -30,37 +30,22 @@ abstract class HasMany implements IRelationshipCollection use SmartObject; - /** - * @phpstan-var E - */ + /** @var E */ protected IEntity $parent; - /** - * @phpstan-var ICollection|null - */ + /** @var ICollection|null */ protected ?ICollection $collection = null; - /** - * @var IEntity[] - * @phpstan-var array - */ + /** @var array */ protected array $toAdd = []; - /** - * @var IEntity[] - * @phpstan-var array - */ + /** @var array */ protected array $toRemove = []; - /** - * @var IEntity[] - * @phpstan-var array - */ + /** @var array */ protected array $tracked = []; - /** - * @phpstan-var IRepository|null - */ + /** @var IRepository|null */ protected ?IRepository $targetRepository = null; protected bool $updatingReverseRelationship = false; @@ -266,7 +251,7 @@ public function toCollection(): ICollection /** * @deprecated Use toCollection() instead. - * @phpstan-return ICollection + * @return ICollection */ public function get(): ICollection { @@ -287,8 +272,7 @@ public function countStored(): int /** - * @return ICollection|IEntity[] - * @phpstan-return ICollection + * @return ICollection */ public function getIterator(): ICollection { @@ -319,7 +303,7 @@ public function trackEntity(IEntity $entity): void /** - * @phpstan-return ICollection + * @return ICollection */ protected function getCollection(bool $forceNew = false): ICollection { @@ -355,9 +339,8 @@ function (): array { /** - * @param IEntity|string|int $entity - * @phpstan-param E|string|int $entity - * @phpstan-return E|null + * @param E|string|int $entity + * @return E|null */ protected function createEntity($entity, bool $need = true): ?IEntity { @@ -393,7 +376,7 @@ public function __clone() /** - * @phpstan-return IRepository + * @return IRepository */ protected function getTargetRepository(): IRepository { @@ -421,8 +404,8 @@ protected function getRelationshipMapper(): IRelationshipMapper /** - * @phpstan-param ICollection $collection - * @phpstan-return ICollection + * @param ICollection $collection + * @return ICollection */ protected function applyDefaultOrder(ICollection $collection): ICollection { @@ -442,21 +425,21 @@ abstract protected function modify(): void; /** * Returns collection for has many relationship. - * @phpstan-return ICollection + * @return ICollection */ abstract protected function createCollection(): ICollection; /** * Updates relationship change for the $entity. - * @phpstan-param E $entity + * @param E $entity */ abstract protected function updateRelationshipAdd(IEntity $entity): void; /** * Updates relationship change for the $entity. - * @phpstan-param E $entity + * @param E $entity */ abstract protected function updateRelationshipRemove(IEntity $entity): void; } diff --git a/src/Relationships/HasOne.php b/src/Relationships/HasOne.php index eddb23d6..699be0e6 100644 --- a/src/Relationships/HasOne.php +++ b/src/Relationships/HasOne.php @@ -24,14 +24,10 @@ abstract class HasOne implements IRelationshipContainer use SmartObject; - /** - * @phpstan-var E|null - */ + /** @var E|null */ protected ?IEntity $parent = null; - /** - * @phpstan-var ICollection|null - */ + /** @var ICollection|null */ protected ?ICollection $collection = null; /** Is value validated against storage? */ @@ -40,22 +36,13 @@ abstract class HasOne implements IRelationshipContainer /** Is raw value loaded from storage and not converted yet? */ protected bool $isValueFromStorage = false; - /** - * @var IEntity|string|int|null - * @phpstan-var E|string|int|null - */ + /** @var E|string|int|null */ protected $value = null; - /** - * @var IEntity[] - * @phpstan-var list - */ + /** @var list */ protected array $tracked = []; - /** - * @var IRepository|null - * @phpstan-var IRepository|null - */ + /** @var IRepository|null */ protected ?IRepository $targetRepository = null; protected bool $updatingReverseRelationship = false; @@ -142,8 +129,7 @@ public function isLoaded(): bool /** * Sets the relationship value to passed entity. * Returns true if the setter has modified property value. - * @param IEntity|int|string|null $value Accepts also a primary key value. - * @phpstan-param E|int|string|null $value Accepts also a primary key value. + * @param E|int|string|null $value Accepts also a primary key value. */ public function set($value, bool $allowNull = false): bool { @@ -220,7 +206,7 @@ protected function getPrimaryValue(): mixed /** - * @phpstan-return E|null + * @return E|null */ protected function getValue(bool $allowPreloadContainer = true): ?IEntity { @@ -251,7 +237,7 @@ protected function initValue(bool $allowPreloadContainer = true): void /** - * @phpstan-return E|null + * @return E|null */ protected function fetchValue(): ?IEntity { @@ -261,7 +247,7 @@ protected function fetchValue(): ?IEntity /** - * @phpstan-return IRepository + * @return IRepository */ protected function getTargetRepository(): IRepository { @@ -279,7 +265,7 @@ protected function getTargetRepository(): IRepository /** - * @phpstan-return ICollection + * @return ICollection */ protected function getCollection(): ICollection { @@ -301,9 +287,8 @@ protected function getParentEntity(): IEntity /** - * @param IEntity|string|int|null $entity - * @phpstan-param E|string|int|null $entity - * @phpstan-return E|null + * @param E|string|int|null $entity + * @return E|null */ protected function createEntity($entity, bool $allowNull): ?IEntity { @@ -401,7 +386,7 @@ abstract protected function isImmediateEntityForPersistence(?IEntity $entity): b /** * Creates relationship collection. - * @phpstan-return ICollection + * @return ICollection */ abstract protected function createCollection(): ICollection; diff --git a/src/Relationships/IRelationshipCollection.php b/src/Relationships/IRelationshipCollection.php index fd623048..955e2977 100644 --- a/src/Relationships/IRelationshipCollection.php +++ b/src/Relationships/IRelationshipCollection.php @@ -20,9 +20,8 @@ interface IRelationshipCollection extends IPropertyContainer, IEntityAwareProper { /** * Adds entity. - * @param IEntity|string|int $entity - * @phpstan-param E|string|int $entity - * @phpstan-return E|null + * @param E|string|int $entity + * @return E|null */ public function add($entity): ?IEntity; @@ -30,31 +29,28 @@ public function add($entity): ?IEntity; /** * Replaces all entities with given ones. * Returns true if the setter has modified property value. - * @param IEntity[]|string[]|int[] $data - * @phpstan-param list|list|list $data + * @param list|list|list $data */ public function set(array $data): bool; /** * Removes entity. - * @param IEntity|string|int $entity - * @phpstan-param E|string|int $entity - * @phpstan-return E|null + * @param E|string|int $entity + * @return E|null */ public function remove($entity): ?IEntity; /** - * @param IEntity|string|int $entity - * @phpstan-param E|string|int $entity + * @param E|string|int $entity */ public function has($entity): bool; /** * Returns collection of all entity. - * @phpstan-return ICollection + * @return ICollection */ public function toCollection(): ICollection; @@ -80,15 +76,14 @@ public function countStored(): int; /** * @internal * @ignore - * @phpstan-param E $entity + * @param E $entity */ public function trackEntity(IEntity $entity): void; /** * Returns IEntity for persistence. - * @return IEntity[] - * @phpstan-return array + * @return array * @ignore * @internal */ diff --git a/src/Relationships/IRelationshipContainer.php b/src/Relationships/IRelationshipContainer.php index 766120e2..b0549342 100644 --- a/src/Relationships/IRelationshipContainer.php +++ b/src/Relationships/IRelationshipContainer.php @@ -15,7 +15,7 @@ interface IRelationshipContainer extends IPropertyContainer, IEntityAwareProperty { /** - * @phpstan-return E|null + * @return E|null */ public function getEntity(): ?IEntity; @@ -34,8 +34,7 @@ public function isModified(): bool; /** * Returns IEntity for persistence. - * @return IEntity[] - * @phpstan-return list + * @return list * @ignore * @internal */ @@ -44,8 +43,7 @@ public function getEntitiesForPersistence(): array; /** * Returns immediate IEntity for Depth-first-search persistence. - * @return IEntity|null - * @phpstan-return E|null + * @return E|null * @ignore * @internal */ diff --git a/src/Repository/IRepository.php b/src/Repository/IRepository.php index 59a641fb..624e5200 100644 --- a/src/Repository/IRepository.php +++ b/src/Repository/IRepository.php @@ -32,7 +32,7 @@ public function setModel(IModel $model): void; /** - * @phpstan-return IMapper + * @return IMapper */ public function getMapper(): IMapper; @@ -40,37 +40,35 @@ public function getMapper(): IMapper; /** * Hydrates entity. * @param array $data - * @phpstan-return E|null + * @return E|null */ public function hydrateEntity(array $data): ?IEntity; /** * Attaches entity to repository. - * @phpstan-param E $entity + * @param E $entity */ public function attach(IEntity $entity): void; /** * Detaches entity from repository. - * @phpstan-param E $entity + * @param E $entity */ public function detach(IEntity $entity): void; /** * Returns possible entity class names for current repository. - * @return string[] - * @phpstan-return list> + * @return list> */ public static function getEntityClassNames(): array; /** * Returns entity metadata. - * @param string|null $entityClass for STI (must extends base class) - * @phpstan-param class-string|null $entityClass + * @param class-string|null $entityClass for STI (must extends base class) */ public function getEntityMetadata(string $entityClass = null): EntityMetadata; @@ -78,7 +76,7 @@ public function getEntityMetadata(string $entityClass = null): EntityMetadata; /** * Returns entity class name. * @param array $data - * @phpstan-return class-string + * @return class-string */ public function getEntityClassName(array $data): string; @@ -88,8 +86,8 @@ public function getEntityClassName(array $data): string; * * Limits collection via {@see ICollection::findBy()} and returns the first entity (or null). * - * @phpstan-param array|array $conds - * @phpstan-return E|null + * @param array|array $conds + * @return E|null */ public function getBy(array $conds): ?IEntity; @@ -99,9 +97,9 @@ public function getBy(array $conds): ?IEntity; * * Limits collection via {@see ICollection::findBy()} and returns the first entity (or throw). * - * @phpstan-param array|array $conds + * @param array|array $conds * @throws NoResultException - * @phpstan-return E + * @return E */ public function getByChecked(array $conds): IEntity; @@ -109,7 +107,7 @@ public function getByChecked(array $conds): IEntity; /** * Returns entity by primary value, null if none found. * @param mixed $id - * @phpstan-return E|null + * @return E|null */ public function getById($id): ?IEntity; @@ -125,7 +123,7 @@ public function getByIdChecked($id): IEntity; /** * Returns new collection with all entities. - * @phpstan-return ICollection + * @return ICollection */ public function findAll(): ICollection; @@ -160,17 +158,16 @@ public function findAll(): ICollection; * ] * * - * @phpstan-param array|array|list $conds - * @phpstan-return ICollection + * @param array|array|list $conds + * @return ICollection */ public function findBy(array $conds): ICollection; /** * Returns entities by primary values. - * @param mixed[] $ids - * @phpstan-param list $ids - * @phpstan-return ICollection + * @param list $ids + * @return ICollection */ public function findByIds(array $ids): ICollection; @@ -189,32 +186,32 @@ public function getConditionParser(): ConditionParser; /** * @template F of E - * @phpstan-param F $entity - * @phpstan-return F + * @param F $entity + * @return F */ public function persist(IEntity $entity, bool $withCascade = true): IEntity; /** * @template F of E - * @phpstan-param F $entity - * @phpstan-return F + * @param F $entity + * @return F */ public function persistAndFlush(IEntity $entity, bool $withCascade = true): IEntity; /** * @template F of E - * @phpstan-param F $entity - * @phpstan-return F + * @param F $entity + * @return F */ public function remove(IEntity $entity, bool $withCascade = true): IEntity; /** * @template F of E - * @phpstan-param F $entity - * @phpstan-return F + * @param F $entity + * @return F */ public function removeAndFlush(IEntity $entity, bool $withCascade = true): IEntity; @@ -229,7 +226,7 @@ public function flush(): void; * DO NOT CALL THIS METHOD DIRECTLY. * @internal * @ignore - * @phpstan-param E $entity + * @param E $entity */ public function doPersist(IEntity $entity): void; @@ -238,7 +235,7 @@ public function doPersist(IEntity $entity): void; * DO NOT CALL THIS METHOD DIRECTLY. * @internal * @ignore - * @phpstan-param E $entity + * @param E $entity */ public function doRemove(IEntity $entity): void; @@ -246,8 +243,8 @@ public function doRemove(IEntity $entity): void; /** * DO NOT CALL THIS METHOD DIRECTLY. * @internal - * @phpstan-return array{list, list} array of all persisted & removed entities * @ignore + * @return array{list, list} array of all persisted & removed entities */ public function doFlush(): array; @@ -273,56 +270,56 @@ public function doRefreshAll(bool $allowOverwrite): void; /** - * @phpstan-param E $entity + * @param E $entity * @internal */ public function onBeforePersist(IEntity $entity): void; /** - * @phpstan-param E $entity + * @param E $entity * @internal */ public function onAfterPersist(IEntity $entity): void; /** - * @phpstan-param E $entity + * @param E $entity * @internal */ public function onBeforeInsert(IEntity $entity): void; /** - * @phpstan-param E $entity + * @param E $entity * @internal */ public function onAfterInsert(IEntity $entity): void; /** - * @phpstan-param E $entity + * @param E $entity * @internal */ public function onBeforeUpdate(IEntity $entity): void; /** - * @phpstan-param E $entity + * @param E $entity * @internal */ public function onAfterUpdate(IEntity $entity): void; /** - * @phpstan-param E $entity + * @param E $entity * @internal */ public function onBeforeRemove(IEntity $entity): void; /** - * @phpstan-param E $entity + * @param E $entity * @internal */ public function onAfterRemove(IEntity $entity): void; @@ -330,8 +327,8 @@ public function onAfterRemove(IEntity $entity): void; /** - * @phpstan-param list $persistedEntities - * @phpstan-param list $removedEntities + * @param list $persistedEntities + * @param list $removedEntities * @internal */ public function onFlush(array $persistedEntities, array $removedEntities): void; diff --git a/src/Repository/IdentityMap.php b/src/Repository/IdentityMap.php index 4d9ee7df..eaa4910e 100644 --- a/src/Repository/IdentityMap.php +++ b/src/Repository/IdentityMap.php @@ -22,33 +22,21 @@ */ class IdentityMap { - /** - * @var IRepository - * @phpstan-var IRepository - */ + /** @var IRepository */ private $repository; - /** - * @var IEntity[] - * @phpstan-var array - */ + /** @var array */ private $entities = []; - /** - * @var bool[] - * @phpstan-var array - */ + /** @var array */ private $entitiesForRefresh = []; - /** - * @var ReflectionClass[] - * @phpstan-var array, ReflectionClass> - */ + /** @var array, ReflectionClass> */ private $entityReflections; /** - * @phpstan-param IRepository $repository + * @param IRepository $repository */ public function __construct(IRepository $repository) { @@ -68,8 +56,7 @@ public function hasById($id): bool /** * @param array|int|mixed $id - * @return IEntity|null|false - * @phpstan-return E|null|false + * @return E|null|false */ public function getById($id) { @@ -87,7 +74,7 @@ public function getById($id) /** - * @phpstan-param E $entity + * @param E $entity */ public function add(IEntity $entity): void { @@ -109,7 +96,7 @@ public function remove($id): void /** * @param array $data - * @phpstan-return E|null + * @return E|null */ public function create(array $data): ?IEntity { @@ -135,8 +122,7 @@ public function create(array $data): ?IEntity /** - * @return IEntity[] - * @phpstan-return list + * @return list */ public function getAll(): array { @@ -181,7 +167,7 @@ public function isMarkedForRefresh(IEntity $entity): bool /** * @param array $data - * @phpstan-return E + * @return E */ protected function createEntity(array $data): IEntity { diff --git a/src/Repository/RemovalHelper.php b/src/Repository/RemovalHelper.php index a1be63dd..1b47e52c 100644 --- a/src/Repository/RemovalHelper.php +++ b/src/Repository/RemovalHelper.php @@ -80,7 +80,7 @@ public static function getCascadeQueueAndSetNulls( /** * Returns entity relationships as array, 0 => pre, 1 => post, 2 => nulls - * @phpstan-return array{ + * @return array{ * array>, * array>, * array diff --git a/src/Repository/Repository.php b/src/Repository/Repository.php index a3cc2006..621c177f 100644 --- a/src/Repository/Repository.php +++ b/src/Repository/Repository.php @@ -51,106 +51,63 @@ */ abstract class Repository implements IRepository { - /** - * @var callable[] - * @phpstan-var array - */ + /** @var array */ public $onBeforePersist = []; - /** - * @var callable[] - * @phpstan-var array - */ + /** @var array */ public $onAfterPersist = []; - /** - * @var callable[] - * @phpstan-var array - */ + /** @var array */ public $onBeforeInsert = []; - /** - * @var callable[] - * @phpstan-var array - */ + /** @var array */ public $onAfterInsert = []; - /** - * @var callable[] - * @phpstan-var array - */ + /** @var array */ public $onBeforeUpdate = []; - /** - * @var callable[] - * @phpstan-var array - */ + /** @var array */ public $onAfterUpdate = []; - /** - * @var callable[] - * @phpstan-var array - */ + /** @var array */ public $onBeforeRemove = []; - /** - * @var callable[] - * @phpstan-var array - */ + /** @var array */ public $onAfterRemove = []; - /** - * @var callable[] - * @phpstan-var array - */ + /** @var array */ public $onFlush = []; - /** - * @var IMapper - * @phpstan-var IMapper - */ + /** @var IMapper */ protected $mapper; - /** - * @var string|null - * @phpstan-var class-string|null - */ + /** @var class-string|null */ protected $entityClassName; /** @var IModel|null */ private $model; - /** - * @var IdentityMap - * @phpstan-var IdentityMap - */ + /** @var IdentityMap */ private $identityMap; /** @var array */ private $proxyMethods; - /** - * @var array - * @phpstan-var array{list, list} - */ + /** @var array{list, list} */ private $entitiesToFlush = [[], []]; /** @var IDependencyProvider|null */ private $dependencyProvider; - /** - * @var array Collection functions cache - */ + /** @var array Collection functions cache */ private array $collectionFunctions = []; - /** - * @var ConditionParser|null - */ + /** @var ConditionParser|null */ private $conditionParser; /** - * @phpstan-param IMapper $mapper + * @param IMapper $mapper */ public function __construct(IMapper $mapper, IDependencyProvider $dependencyProvider = null) { @@ -380,7 +337,7 @@ public function getEntityMetadata(string $entityClass = null): EntityMetadata public function getEntityClassName(array $data): string { if ($this->entityClassName === null) { - /** @phpstan-var class-string $entityClassName */ + /** @var class-string $entityClassName */ $entityClassName = static::getEntityClassNames()[0]; $this->entityClassName = $entityClassName; } @@ -494,7 +451,7 @@ public function doClear(): void /** - * @phpstan-param mixed[] $args + * @param mixed[] $args * @return mixed */ public function __call(string $method, array $args) diff --git a/src/TestHelper/EntityCreator.php b/src/TestHelper/EntityCreator.php index 73cf3865..0b93fd33 100644 --- a/src/TestHelper/EntityCreator.php +++ b/src/TestHelper/EntityCreator.php @@ -26,9 +26,9 @@ public function __construct(IModel $model) /** * @template T of IEntity - * @phpstan-param class-string $entity - * @phpstan-param array $params - * @phpstan-return T + * @param class-string $entity + * @param array $params + * @return T */ public function create(string $entity, array $params = []): IEntity { diff --git a/src/TestHelper/TestCaseEntityTrait.php b/src/TestHelper/TestCaseEntityTrait.php index ce2507a8..fa73427c 100644 --- a/src/TestHelper/TestCaseEntityTrait.php +++ b/src/TestHelper/TestCaseEntityTrait.php @@ -10,9 +10,9 @@ trait TestCaseEntityTrait { /** * @template T of IEntity - * @phpstan-param class-string $entityClass - * @phpstan-return T + * @param class-string $entityClass * @param array $parameters + * @return T */ protected function e(string $entityClass, array $parameters = []): IEntity { diff --git a/src/TestHelper/TestMapper.php b/src/TestHelper/TestMapper.php index f5460d53..f95ebaae 100644 --- a/src/TestHelper/TestMapper.php +++ b/src/TestHelper/TestMapper.php @@ -27,7 +27,7 @@ public function addMethod(string $name, callable $callback): void /** - * @phpstan-param mixed[] $args + * @param mixed[] $args * @return mixed */ public function __call(string $name, array $args)