diff --git a/application/Espo/Core/Acl/AccessEntityCreateChecker.php b/application/Espo/Core/Acl/AccessEntityCreateChecker.php index 1381d85b86..40d6a20f0e 100644 --- a/application/Espo/Core/Acl/AccessEntityCreateChecker.php +++ b/application/Espo/Core/Acl/AccessEntityCreateChecker.php @@ -40,7 +40,7 @@ interface AccessEntityCreateChecker extends AccessCreateChecker /** * Check 'create' access for an entity. * - * @phpstan-param TEntity $entity + * @param TEntity $entity */ public function checkEntityCreate(User $user, Entity $entity, ScopeData $data): bool; } diff --git a/application/Espo/Core/Acl/AccessEntityDeleteChecker.php b/application/Espo/Core/Acl/AccessEntityDeleteChecker.php index a1a4144afc..df1b5ad5a6 100644 --- a/application/Espo/Core/Acl/AccessEntityDeleteChecker.php +++ b/application/Espo/Core/Acl/AccessEntityDeleteChecker.php @@ -40,7 +40,7 @@ interface AccessEntityDeleteChecker extends AccessDeleteChecker /** * Check 'delete' access for an entity. * - * @phpstan-param TEntity $entity + * @param TEntity $entity */ public function checkEntityDelete(User $user, Entity $entity, ScopeData $data): bool; } diff --git a/application/Espo/Core/Acl/AccessEntityEditChecker.php b/application/Espo/Core/Acl/AccessEntityEditChecker.php index dc3274c837..10c942a96a 100644 --- a/application/Espo/Core/Acl/AccessEntityEditChecker.php +++ b/application/Espo/Core/Acl/AccessEntityEditChecker.php @@ -40,7 +40,7 @@ interface AccessEntityEditChecker extends AccessEditChecker /** * Check 'edit' access for an entity. * - * @phpstan-param TEntity $entity + * @param TEntity $entity */ public function checkEntityEdit(User $user, Entity $entity, ScopeData $data): bool; } diff --git a/application/Espo/Core/Acl/AccessEntityReadChecker.php b/application/Espo/Core/Acl/AccessEntityReadChecker.php index cb8d4aafe5..156e246bed 100644 --- a/application/Espo/Core/Acl/AccessEntityReadChecker.php +++ b/application/Espo/Core/Acl/AccessEntityReadChecker.php @@ -40,7 +40,7 @@ interface AccessEntityReadChecker extends AccessReadChecker /** * Check 'read' access for entity. * - * @phpstan-param TEntity $entity + * @param TEntity $entity */ public function checkEntityRead(User $user, Entity $entity, ScopeData $data): bool; } diff --git a/application/Espo/Core/Acl/AccessEntityStreamChecker.php b/application/Espo/Core/Acl/AccessEntityStreamChecker.php index f6a96ce3f4..acd06a87e0 100644 --- a/application/Espo/Core/Acl/AccessEntityStreamChecker.php +++ b/application/Espo/Core/Acl/AccessEntityStreamChecker.php @@ -40,7 +40,7 @@ interface AccessEntityStreamChecker extends AccessStreamChecker /** * Check 'stream' access for an entity. * - * @phpstan-param TEntity $entity + * @param TEntity $entity */ public function checkEntityStream(User $user, Entity $entity, ScopeData $data): bool; } diff --git a/application/Espo/Core/Duplicate/WhereBuilder.php b/application/Espo/Core/Duplicate/WhereBuilder.php index aac1612b3c..a363cea4b2 100644 --- a/application/Espo/Core/Duplicate/WhereBuilder.php +++ b/application/Espo/Core/Duplicate/WhereBuilder.php @@ -29,10 +29,8 @@ namespace Espo\Core\Duplicate; -use Espo\ORM\{ - Query\Part\WhereItem, - Entity, -}; +use Espo\ORM\Entity; +use Espo\ORM\Query\Part\WhereItem; /** * @template TEntity of Entity @@ -40,7 +38,7 @@ use Espo\ORM\{ interface WhereBuilder { /** - * @phpstan-param TEntity $entity + * @param TEntity $entity */ public function build(Entity $entity): ?WhereItem; } diff --git a/application/Espo/ORM/Mapper/Mapper.php b/application/Espo/ORM/Mapper/Mapper.php index edbb77ef5e..8976e2d6f5 100644 --- a/application/Espo/ORM/Mapper/Mapper.php +++ b/application/Espo/ORM/Mapper/Mapper.php @@ -43,7 +43,7 @@ interface Mapper /** * Select entities from DB. * - * @phpstan-return Collection + * @return Collection */ public function select(Select $select): Collection; @@ -60,7 +60,7 @@ interface Mapper /** * Insert a collection into DB. * - * @phpstan-param Collection $collection + * @param Collection $collection */ public function massInsert(Collection $collection): void; @@ -77,8 +77,7 @@ interface Mapper /** * Select related entities from DB. * - * @return Collection|Entity|null - * @phpstan-return Collection|Entity|null + * @return Collection|Entity|null */ public function selectRelated(Entity $entity, string $relationName, ?Select $select = null); diff --git a/application/Espo/ORM/Repository/RDBRelation.php b/application/Espo/ORM/Repository/RDBRelation.php index b177b874ba..4571c2f5d7 100644 --- a/application/Espo/ORM/Repository/RDBRelation.php +++ b/application/Espo/ORM/Repository/RDBRelation.php @@ -50,19 +50,12 @@ use RuntimeException; class RDBRelation { private EntityManager $entityManager; - private HookMediator $hookMediator; - private Entity $entity; - private string $entityType; - private ?string $foreignEntityType = null; - private string $relationName; - private ?string $relationType = null; - private bool $noBuilder = false; public function __construct( @@ -84,9 +77,7 @@ class RDBRelation } $this->relationName = $relationName; - $this->relationType = $entity->getRelationType($relationName); - $this->entityType = $entity->getEntityType(); if ($entity instanceof BaseEntity) { @@ -180,7 +171,10 @@ class RDBRelation return $this->getMapper()->selectRelated($this->entity, $this->relationName); } - $collection = $this->sth()->limit(0, 1)->find(); + $collection = $this + ->sth() + ->limit(0, 1) + ->find(); foreach ($collection as $entity) { return $entity; @@ -203,7 +197,7 @@ class RDBRelation * @param Join|string $target * A relation name or table. A relation name should be in camelCase, a table in CamelCase. * @param string|null $alias An alias. - * @param WhereItem|array|null $conditions Join conditions. + * @param WhereItem|array|null $conditions Join conditions. */ public function join($target, ?string $alias = null, $conditions = null): Builder { @@ -216,7 +210,7 @@ class RDBRelation * @param Join|string $target * A relation name or table. A relation name should be in camelCase, a table in CamelCase. * @param string|null $alias An alias. - * @param WhereItem|array|null $conditions Join conditions. + * @param WhereItem|array|null $conditions Join conditions. */ public function leftJoin($target, ?string $alias = null, $conditions = null): Builder { @@ -280,12 +274,10 @@ class RDBRelation * * `order([$expr1, $expr2, ...]) * * `order(string $expression, string $direction) * - * @param Order|Order[]|Expression|string $orderBy - * An attribute to order by or an array or order items. - * Passing an array will reset a previously set order. + * @param Order|Order[]|Expression|string|array|string[] $orderBy + * An attribute to order by or an array or order items. + * Passing an array will reset a previously set order. * @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC. - * - * @phpstan-param Order|Order[]|Expression|string|array|string[] $orderBy */ public function order($orderBy = 'id', $direction = null): Builder { @@ -311,7 +303,7 @@ class RDBRelation * * `select(string $expression, string $alias)` * * @param Selection|Selection[]|Expression|Expression[]|string[]|string|array $select - * An array of expressions or one expression. + * An array of expressions or one expression. * @param string|null $alias An alias. Actual if the first parameter is not an array. */ public function select($select = [], ?string $alias = null): Builder @@ -517,7 +509,6 @@ class RDBRelation public function relate(Entity $entity, ?array $columnData = null, array $options = []): void { $this->processCheckForeignEntity($entity); - $this->beforeRelate($entity, $columnData, $options); $result = $this->getMapper()->relate($this->entity, $this->relationName, $entity, $columnData); @@ -537,18 +528,15 @@ class RDBRelation public function unrelate(Entity $entity, array $options = []): void { $this->processCheckForeignEntity($entity); - $this->beforeUnrelate($entity, $options); - $this->getMapper()->unrelate($this->entity, $this->relationName, $entity); - $this->afterUnrelate($entity, $options); } /** * Mass-relate. * - * @param array $options + * @param array $options */ public function massRelate(Select $query, array $options = []): void { @@ -561,16 +549,14 @@ class RDBRelation } $this->beforeMassRelate($query, $options); - $this->getMapper()->massRelate($this->entity, $this->relationName, $query); - $this->afterMassRelate($query, $options); } /** * Update relationship columns. For many-to-many relationships. * - * @param array $columnData Role values. + * @param array $columnData Role values. */ public function updateColumns(Entity $entity, array $columnData): void { @@ -612,8 +598,8 @@ class RDBRelation } /** - * @param array|null $columnData Role values. - * @param array $options + * @param array|null $columnData Role values. + * @param array $options */ private function beforeRelate(Entity $entity, ?array $columnData, array $options): void { @@ -621,8 +607,8 @@ class RDBRelation } /** - * @param array|null $columnData Role values. - * @param array $options + * @param array|null $columnData Role values. + * @param array $options */ private function afterRelate(Entity $entity, ?array $columnData, array $options): void { @@ -630,7 +616,7 @@ class RDBRelation } /** - * @param array $options + * @param array $options */ private function beforeUnrelate(Entity $entity, array $options): void { @@ -638,7 +624,7 @@ class RDBRelation } /** - * @param array $options + * @param array $options */ private function afterUnrelate(Entity $entity, array $options): void { @@ -646,7 +632,7 @@ class RDBRelation } /** - * @param array $options + * @param array $options */ private function beforeMassRelate(Select $query, array $options): void { @@ -654,7 +640,7 @@ class RDBRelation } /** - * @param array $options + * @param array $options */ private function afterMassRelate(Select $query, array $options): void { diff --git a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php index ca26bbcd7a..0a31d0ba07 100644 --- a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php +++ b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php @@ -52,19 +52,12 @@ use InvalidArgumentException; class RDBRelationSelectBuilder { private EntityManager $entityManager; - private Entity $entity; - private string $foreignEntityType; - private string $relationName; - private ?string $relationType = null; - private SelectBuilder $builder; - private ?string $middleTableAlias = null; - private bool $returnSthCollection = false; public function __construct( @@ -74,13 +67,9 @@ class RDBRelationSelectBuilder ?Select $query = null ) { $this->entityManager = $entityManager; - $this->entity = $entity; - $this->relationName = $relationName; - $this->relationType = $entity->getRelationType($relationName); - $entityType = $entity->getEntityType(); if ($entity instanceof BaseEntity) { @@ -132,7 +121,7 @@ class RDBRelationSelectBuilder * Usage example: * `->columnsWhere(['column' => $value])` * - * @param WhereItem|array $clause Where clause. + * @param WhereItem|array $clause Where clause. */ public function columnsWhere($clause): self { @@ -300,7 +289,7 @@ class RDBRelationSelectBuilder * * `where(array $clause)` * * `where(string $key, string $value)` * - * @param WhereItem|array|string $clause A key or where clause. + * @param WhereItem|array|string $clause A key or where clause. * @param mixed[]|scalar|null $value A value. Should be omitted if the first argument is not string. */ public function where($clause = [], $value = null): self @@ -330,7 +319,7 @@ class RDBRelationSelectBuilder * * `having(array $clause)` * * `having(string $key, string $value)` * - * @param WhereItem|array|string $clause A key or where clause. + * @param WhereItem|array|string $clause A key or where clause. * @param mixed[]|string|null $value A value. Should be omitted if the first argument is not string. */ public function having($clause = [], $value = null): self @@ -349,12 +338,10 @@ class RDBRelationSelectBuilder * * `order([$expr1, $expr2, ...]) * * `order(string $expression, string $direction) * - * @param Order|Order[]|Expression|string $orderBy - * An attribute to order by or an array or order items. - * Passing an array will reset a previously set order. + * @param Order|Order[]|Expression|string|array|string[] $orderBy + * An attribute to order by or an array or order items. + * Passing an array will reset a previously set order. * @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC. - * - * @phpstan-param Order|Order[]|Expression|string|array|string[] $orderBy */ public function order($orderBy = 'id', $direction = null): self { @@ -384,7 +371,7 @@ class RDBRelationSelectBuilder * * `select(string $expression, string $alias)` * * @param Selection|Selection[]|Expression|Expression[]|string[]|string|array $select - * An array of expressions or one expression. + * An array of expressions or one expression. * @param string|null $alias An alias. Actual if the first parameter is not an array. */ public function select($select, ?string $alias = null): self @@ -452,8 +439,8 @@ class RDBRelationSelectBuilder } /** - * @param array $where - * @return array + * @param array $where + * @return array */ protected function applyRelationAliasToWhereClause(array $where): array { @@ -492,7 +479,7 @@ class RDBRelationSelectBuilder /** * @param Collection $collection - * @phpstan-return Collection + * @return Collection */ protected function handleReturnCollection(Collection $collection): Collection { diff --git a/application/Espo/ORM/Repository/RDBRepository.php b/application/Espo/ORM/Repository/RDBRepository.php index e4ffcac8dd..e2330a5e9c 100644 --- a/application/Espo/ORM/Repository/RDBRepository.php +++ b/application/Espo/ORM/Repository/RDBRepository.php @@ -916,12 +916,10 @@ class RDBRepository implements Repository * * `order([$expr1, $expr2, ...]) * * `order(string $expression, string $direction) * - * @param Order|Order[]|Expression|string $orderBy - * An attribute to order by or an array or order items. - * Passing an array will reset a previously set order. + * @param Order|Order[]|Expression|string|array|string[] $orderBy + * An attribute to order by or an array or order items. + * Passing an array will reset a previously set order. * @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC. - * - * @phpstan-param Order|Order[]|Expression|string|array|string[] $orderBy * @return RDBSelectBuilder */ public function order($orderBy = 'id', $direction = null): RDBSelectBuilder @@ -950,7 +948,7 @@ class RDBRepository implements Repository * * `select(string $expression, string $alias)` * * @param Selection|Selection[]|Expression|Expression[]|string[]|string|array $select - * An array of expressions or one expression. + * An array of expressions or one expression. * @param string|null $alias An alias. Actual if the first parameter is not an array. * @return RDBSelectBuilder */ diff --git a/application/Espo/ORM/Repository/RDBSelectBuilder.php b/application/Espo/ORM/Repository/RDBSelectBuilder.php index 115dfb5f98..45bef50823 100644 --- a/application/Espo/ORM/Repository/RDBSelectBuilder.php +++ b/application/Espo/ORM/Repository/RDBSelectBuilder.php @@ -30,6 +30,7 @@ namespace Espo\ORM\Repository; use Espo\ORM\Collection; +use Espo\ORM\EntityCollection; use Espo\ORM\SthCollection; use Espo\ORM\Entity; use Espo\ORM\EntityManager; @@ -53,12 +54,8 @@ use RuntimeException; class RDBSelectBuilder { private EntityManager $entityManager; - private SelectBuilder $builder; - - /** - * @var RDBRepository - */ + /** @var RDBRepository */ private RDBRepository $repository; private bool $returnSthCollection = false; @@ -107,8 +104,7 @@ class RDBSelectBuilder } /** - * @param ?array $params @deprecated - * + * @param ?array $params @deprecated * @return ?TEntity */ public function findOne(?array $params = null): ?Entity @@ -205,11 +201,10 @@ class RDBSelectBuilder * Add JOIN. * * @param Join|string $target - * A relation name or table. A relation name should be in camelCase, a table in CamelCase. + * A relation name or table. A relation name should be in camelCase, a table in CamelCase. * @param string|null $alias An alias. - * @param WhereItem|array|null $conditions Join conditions. - * - * @phpstan-return RDBSelectBuilder + * @param WhereItem|array|null $conditions Join conditions. + * @return RDBSelectBuilder */ public function join($target, ?string $alias = null, $conditions = null): self { @@ -222,11 +217,11 @@ class RDBSelectBuilder * Add LEFT JOIN. * * @param Join|string $target - * A relation name or table. A relation name should be in camelCase, a table in CamelCase. + * A relation name or table. A relation name should be in camelCase, a table in CamelCase. * @param string|null $alias An alias. * @param WhereItem|array|null $conditions Join conditions. * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function leftJoin($target, ?string $alias = null, $conditions = null): self { @@ -238,7 +233,7 @@ class RDBSelectBuilder /** * Set DISTINCT parameter. * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function distinct(): self { @@ -250,7 +245,7 @@ class RDBSelectBuilder /** * Lock selected rows. To be used within a transaction. * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function forUpdate(): self { @@ -263,8 +258,7 @@ class RDBSelectBuilder * Set to return STH collection. Recommended for fetching large number of records. * * @todo Remove. - * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function sth(): self { @@ -281,10 +275,9 @@ class RDBSelectBuilder * * `where(array $clause)` * * `where(string $key, string $value)` * - * @param WhereItem|array|string $clause A key or where clause. + * @param WhereItem|array|string $clause A key or where clause. * @param mixed[]|scalar|null $value A value. Should be omitted if the first argument is not string. - * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function where($clause = [], $value = null): self { @@ -301,10 +294,9 @@ class RDBSelectBuilder * * `having(array $clause)` * * `having(string $key, string $value)` * - * @param WhereItem|array|string $clause A key or where clause. + * @param WhereItem|array|string $clause A key or where clause. * @param mixed[]|scalar|null $value A value. Should be omitted if the first argument is not string. - * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function having($clause = [], $value = null): self { @@ -322,13 +314,11 @@ class RDBSelectBuilder * * `order([$expr1, $expr2, ...]) * * `order(string $expression, string $direction) * - * @param Order|Order[]|Expression|string $orderBy + * @param Order|Order[]|Expression|string|array|string[] $orderBy * An attribute to order by or an array or order items. * Passing an array will reset a previously set order. * @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC. - * - * @phpstan-param Order|Order[]|Expression|string|array|string[] $orderBy - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function order($orderBy = 'id', $direction = null): self { @@ -340,7 +330,7 @@ class RDBSelectBuilder /** * Apply OFFSET and LIMIT. * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function limit(?int $offset = null, ?int $limit = null): self { @@ -365,8 +355,7 @@ class RDBSelectBuilder * @param Selection|Selection[]|Expression|Expression[]|string[]|string|array $select * An array of expressions or one expression. * @param string|null $alias An alias. Actual if the first parameter is a string. - * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function select($select, ?string $alias = null): self { @@ -385,8 +374,7 @@ class RDBSelectBuilder * * `groupBy([$expr1, $expr2, ...])` * * @param Expression|Expression[]|string|string[] $groupBy - * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder */ public function group($groupBy): self { @@ -398,7 +386,7 @@ class RDBSelectBuilder /** * @deprecated Use `group` method. * - * @phpstan-return RDBSelectBuilder + * @return RDBSelectBuilder * @param Expression|Expression[]|string|string[] $groupBy */ public function groupBy($groupBy): self @@ -421,7 +409,7 @@ class RDBSelectBuilder } /** - * @var \Espo\ORM\EntityCollection + * @var EntityCollection */ return $this->entityManager->getCollectionFactory()->createFromSthCollection($collection); } @@ -429,7 +417,7 @@ class RDBSelectBuilder /** * For backward compatibility. * @todo Remove. - * @param array $params + * @param array $params */ protected function getMergedParams(?array $params = null): Select { diff --git a/application/Espo/ORM/Repository/Repository.php b/application/Espo/ORM/Repository/Repository.php index 4970653ed3..8d806b22c8 100644 --- a/application/Espo/ORM/Repository/Repository.php +++ b/application/Espo/ORM/Repository/Repository.php @@ -55,7 +55,7 @@ interface Repository /** * Store an entity. * - * @phpstan-param TEntity $entity + * @param TEntity $entity * @param array $options */ public function save(Entity $entity, array $options = []): void; @@ -63,7 +63,7 @@ interface Repository /** * Remove an entity. * - * @phpstan-param TEntity $entity + * @param TEntity $entity * @param array $options */ public function remove(Entity $entity, array $options = []): void; diff --git a/application/Espo/ORM/Value/AttributeExtractor.php b/application/Espo/ORM/Value/AttributeExtractor.php index e06109bc23..6379489e9b 100644 --- a/application/Espo/ORM/Value/AttributeExtractor.php +++ b/application/Espo/ORM/Value/AttributeExtractor.php @@ -39,7 +39,7 @@ use stdClass; interface AttributeExtractor { /** - * @phpstan-param T $value + * @param T $value */ public function extract(object $value, string $field): stdClass;