mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
type fixes
This commit is contained in:
@@ -31,6 +31,9 @@ namespace Espo\Core\Notification\AssignmentNotificator;
|
||||
|
||||
class Params
|
||||
{
|
||||
/**
|
||||
* @var array<string,mixed>
|
||||
*/
|
||||
private $options = [];
|
||||
|
||||
public function hasOption(string $option): bool
|
||||
@@ -46,11 +49,17 @@ class Params
|
||||
return $this->options[$option] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function getRawOptions(): array
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $options
|
||||
*/
|
||||
public function withRawOptions(array $options): self
|
||||
{
|
||||
$obj = clone $this;
|
||||
|
||||
@@ -39,13 +39,16 @@ use Espo\Core\{
|
||||
|
||||
class AssignmentNotificatorFactory
|
||||
{
|
||||
protected $defaultClassName = DefaultAssignmentNotificator::class;
|
||||
/**
|
||||
* @var class-string
|
||||
*/
|
||||
protected string $defaultClassName = DefaultAssignmentNotificator::class;
|
||||
|
||||
private $injectableFactory;
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
private $classFinder;
|
||||
private ClassFinder $classFinder;
|
||||
|
||||
private $metadata;
|
||||
private Metadata $metadata;
|
||||
|
||||
public function __construct(InjectableFactory $injectableFactory, ClassFinder $classFinder, Metadata $metadata)
|
||||
{
|
||||
@@ -66,6 +69,9 @@ class AssignmentNotificatorFactory
|
||||
return $this->injectableFactory->create($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string
|
||||
*/
|
||||
private function getClassName(string $entityType): string
|
||||
{
|
||||
$className1 = $this->metadata->get(['notificationDefs', $entityType, 'assignmentNotificatorClassName']);
|
||||
|
||||
@@ -29,15 +29,16 @@
|
||||
|
||||
namespace Espo\Core\Notification;
|
||||
|
||||
use Espo\Core\{
|
||||
ORM\EntityManager,
|
||||
};
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
class UserEnabledChecker
|
||||
{
|
||||
/**
|
||||
* @var array<string,bool>
|
||||
*/
|
||||
private $assignmentCache = [];
|
||||
|
||||
private $entityManager;
|
||||
private EntityManager $entityManager;
|
||||
|
||||
public function __construct(EntityManager $entityManager)
|
||||
{
|
||||
|
||||
@@ -45,13 +45,13 @@ use Espo\Core\{
|
||||
*/
|
||||
class DefaultNotificator
|
||||
{
|
||||
protected $entityType;
|
||||
protected $entityType; /** @phpstan-ignore-line */
|
||||
|
||||
protected $user;
|
||||
protected $user; /** @phpstan-ignore-line */
|
||||
|
||||
protected $entityManager;
|
||||
protected $entityManager; /** @phpstan-ignore-line */
|
||||
|
||||
private $base;
|
||||
private $base; /** @phpstan-ignore-line */
|
||||
|
||||
public function __construct(User $user, EntityManager $entityManager, DefaultAssignmentNotificator $base)
|
||||
{
|
||||
@@ -60,7 +60,7 @@ class DefaultNotificator
|
||||
$this->base = $base;
|
||||
}
|
||||
|
||||
public function process(Entity $entity, array $options = [])
|
||||
public function process(Entity $entity, array $options = []) /** @phpstan-ignore-line */
|
||||
{
|
||||
$this->base->process($entity, Params::create()->withRawOptions($options));
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class DefaultNotificator
|
||||
/**
|
||||
* For backward compatibility.
|
||||
*/
|
||||
protected function getEntityManager()
|
||||
protected function getEntityManager() /** @phpstan-ignore-line */
|
||||
{
|
||||
return $this->entityManager;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class DefaultNotificator
|
||||
/**
|
||||
* For backward compatibility.
|
||||
*/
|
||||
protected function getUser()
|
||||
protected function getUser() /** @phpstan-ignore-line */
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ use RuntimeException;
|
||||
*/
|
||||
class AttributeExtractorFactory implements AttributeExtractorFactoryInterface
|
||||
{
|
||||
private $metadata;
|
||||
private Metadata $metadata;
|
||||
|
||||
private $ormMetadata;
|
||||
private OrmMetadata $ormMetadata;
|
||||
|
||||
private $injectableFactory;
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
public function __construct(Metadata $metadata, OrmMetadata $ormMetadata, InjectableFactory $injectableFactory)
|
||||
{
|
||||
@@ -77,6 +77,9 @@ class AttributeExtractorFactory implements AttributeExtractorFactoryInterface
|
||||
return $this->injectableFactory->create($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
private function getClassName(string $entityType, string $field): ?string
|
||||
{
|
||||
$fieldDefs = $this->ormMetadata
|
||||
|
||||
@@ -93,6 +93,14 @@ class Entity extends BaseEntity
|
||||
$this->set($field . 'Name', null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $link
|
||||
* @return ?array{
|
||||
* orderBy: ?string,
|
||||
* order: ?string,
|
||||
* }
|
||||
*/
|
||||
protected function getRelationOrderParams(string $link): ?array
|
||||
{
|
||||
$field = $link;
|
||||
@@ -145,11 +153,14 @@ class Entity extends BaseEntity
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?array<string,string> $columns
|
||||
*/
|
||||
public function loadLinkMultipleField(string $field, $columns = null): void
|
||||
{
|
||||
if (!$this->hasRelation($field) || !$this->hasAttribute($field . 'Ids')) {
|
||||
return;
|
||||
// @todo Throw exception in 6.4.
|
||||
// @todo Throw exception on v7.2.
|
||||
// throw new LogicException("There's no link-multiple field '{$field}'.");
|
||||
}
|
||||
|
||||
@@ -320,6 +331,9 @@ class Entity extends BaseEntity
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setLinkMultipleColumn(string $field, string $column, string $id, $value): void
|
||||
{
|
||||
$columnsAttribute = $field . 'Columns';
|
||||
@@ -347,6 +361,9 @@ class Entity extends BaseEntity
|
||||
$this->set($columnsAttribute, $object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $idList
|
||||
*/
|
||||
public function setLinkMultipleIdList(string $field, array $idList): void
|
||||
{
|
||||
$idsAttribute = $field . 'Ids';
|
||||
@@ -397,6 +414,9 @@ class Entity extends BaseEntity
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?string[]
|
||||
*/
|
||||
public function getLinkMultipleIdList(string $field): ?array
|
||||
{
|
||||
$idsAttribute = $field . 'Ids';
|
||||
|
||||
@@ -49,15 +49,15 @@ use Espo\ORM\{
|
||||
|
||||
class EntityFactory implements EntityFactoryInterface
|
||||
{
|
||||
private $classFinder;
|
||||
private ClassFinder $classFinder;
|
||||
|
||||
private $helper;
|
||||
private Helper $helper;
|
||||
|
||||
private $injectableFactory;
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
private $entityManager = null;
|
||||
private ?EntityManager $entityManager = null;
|
||||
|
||||
private $valueAccessorFactory = null;
|
||||
private ?ValueAccessorFactory $valueAccessorFactory = null;
|
||||
|
||||
public function __construct(ClassFinder $classFinder, Helper $helper, InjectableFactory $injectableFactory)
|
||||
{
|
||||
@@ -66,6 +66,9 @@ class EntityFactory implements EntityFactoryInterface
|
||||
$this->injectableFactory = $injectableFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string
|
||||
*/
|
||||
private function getClassName(string $entityType): ?string
|
||||
{
|
||||
return $this->classFinder->find('Entities', $entityType);
|
||||
@@ -108,6 +111,9 @@ class EntityFactory implements EntityFactoryInterface
|
||||
return $this->injectableFactory->createWithBinding($className, $bindingContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $defs
|
||||
*/
|
||||
private function getBindingContainer(string $className, string $entityType, array $defs): BindingContainer
|
||||
{
|
||||
$data = new BindingData();
|
||||
|
||||
@@ -50,14 +50,17 @@ use RuntimeException;
|
||||
|
||||
class EntityManagerFactory
|
||||
{
|
||||
private $config;
|
||||
private Config $config;
|
||||
|
||||
private $injectableFactory;
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
private $metadataDataProvider;
|
||||
private MetadataDataProvider $metadataDataProvider;
|
||||
|
||||
private $eventDispatcher;
|
||||
private EventDispatcher $eventDispatcher;
|
||||
|
||||
/**
|
||||
* @var array<string,string>
|
||||
*/
|
||||
private $driverPlatformMap = [
|
||||
'pdo_mysql' => 'Mysql',
|
||||
'mysqli' => 'Mysql',
|
||||
|
||||
@@ -41,9 +41,9 @@ use Espo\Core\{
|
||||
|
||||
class EntityManagerProxy
|
||||
{
|
||||
private $entityManager = null;
|
||||
private ?EntityManager $entityManager = null;
|
||||
|
||||
private $container;
|
||||
private Container $container;
|
||||
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
@@ -64,6 +64,10 @@ class EntityManagerProxy
|
||||
return $this->getEntityManager()->getEntity($entityType, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed,string> $options
|
||||
* @return void
|
||||
*/
|
||||
public function saveEntity(Entity $entity, array $options = [])
|
||||
{
|
||||
/** Return for backward compatibility. */
|
||||
@@ -71,11 +75,17 @@ class EntityManagerProxy
|
||||
return $this->getEntityManager()->saveEntity($entity, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Repository<Entity>
|
||||
*/
|
||||
public function getRepository(string $entityType): Repository
|
||||
{
|
||||
return $this->getEntityManager()->getRepository($entityType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RDBRepository<Entity>
|
||||
*/
|
||||
public function getRDBRepository(string $entityType): RDBRepository
|
||||
{
|
||||
return $this->getEntityManager()->getRDBRepository($entityType);
|
||||
|
||||
@@ -40,13 +40,16 @@ use LogicException;
|
||||
|
||||
class FunctionConverterFactory implements FunctionConverterFactoryInterface
|
||||
{
|
||||
/**
|
||||
* @var array<string,FunctionConverter>
|
||||
*/
|
||||
private $hash = [];
|
||||
|
||||
private $metadata;
|
||||
private Metadata $metadata;
|
||||
|
||||
private $databaseParams;
|
||||
private DatabaseParams $databaseParams;
|
||||
|
||||
private $injectableFactory;
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
public function __construct(
|
||||
Metadata $metadata,
|
||||
@@ -80,6 +83,9 @@ class FunctionConverterFactory implements FunctionConverterFactoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
private function getClassName(string $name): ?string
|
||||
{
|
||||
if (!array_key_exists($name, $this->hash)) {
|
||||
|
||||
@@ -42,49 +42,49 @@ use Espo\Core\{
|
||||
};
|
||||
|
||||
/** @deprecated */
|
||||
class RDB extends \Espo\Core\Repositories\Database implements Injectable
|
||||
class RDB extends \Espo\Core\Repositories\Database implements Injectable /** @phpstan-ignore-line */
|
||||
{
|
||||
protected $dependencyList = [
|
||||
protected $dependencyList = [ /** @phpstan-ignore-line */
|
||||
'config',
|
||||
];
|
||||
|
||||
protected $dependencies = [];
|
||||
protected $dependencies = []; /** @phpstan-ignore-line */
|
||||
|
||||
protected $injections = [];
|
||||
protected $injections = []; /** @phpstan-ignore-line */
|
||||
|
||||
protected function addDependency($name)
|
||||
protected function addDependency($name) /** @phpstan-ignore-line */
|
||||
{
|
||||
$this->dependencyList[] = $name;
|
||||
}
|
||||
|
||||
protected function addDependencyList(array $list)
|
||||
protected function addDependencyList(array $list) /** @phpstan-ignore-line */
|
||||
{
|
||||
foreach ($list as $item) {
|
||||
$this->addDependency($item);
|
||||
}
|
||||
}
|
||||
|
||||
public function inject($name, $object)
|
||||
public function inject($name, $object) /** @phpstan-ignore-line */
|
||||
{
|
||||
$this->injections[$name] = $object;
|
||||
}
|
||||
|
||||
protected function getInjection($name)
|
||||
protected function getInjection($name) /** @phpstan-ignore-line */
|
||||
{
|
||||
return $this->injections[$name] ?? $this->$name ?? null;
|
||||
}
|
||||
|
||||
public function getDependencyList()
|
||||
public function getDependencyList() /** @phpstan-ignore-line */
|
||||
{
|
||||
return array_merge($this->dependencyList, $this->dependencies);
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
protected function getMetadata() /** @phpstan-ignore-line */
|
||||
{
|
||||
return $this->getInjection('metadata');
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
protected function getConfig() /** @phpstan-ignore-line */
|
||||
{
|
||||
return $this->getInjection('config');
|
||||
}
|
||||
@@ -111,7 +111,7 @@ class RDB extends \Espo\Core\Repositories\Database implements Injectable
|
||||
$this->init();
|
||||
}
|
||||
|
||||
protected function init()
|
||||
protected function init() /** @phpstan-ignore-line */
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,46 +38,50 @@ use Espo\ORM\{
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @extends RDBRepository<Entity>
|
||||
*/
|
||||
abstract class Repository extends RDBRepository implements Injectable
|
||||
{
|
||||
protected $dependencyList = [];
|
||||
protected $dependencyList = []; /** @phpstan-ignore-line */
|
||||
|
||||
protected $dependencies = []; // for backward compatibility
|
||||
protected $dependencies = []; /** @phpstan-ignore-line */
|
||||
|
||||
protected $injections = [];
|
||||
protected $injections = []; /** @phpstan-ignore-line */
|
||||
|
||||
protected function init()
|
||||
protected function init() /** @phpstan-ignore-line */
|
||||
{
|
||||
}
|
||||
|
||||
public function inject($name, $object)
|
||||
public function inject($name, $object) /** @phpstan-ignore-line */
|
||||
{
|
||||
$this->injections[$name] = $object;
|
||||
}
|
||||
|
||||
protected function getInjection($name)
|
||||
protected function getInjection($name) /** @phpstan-ignore-line */
|
||||
{
|
||||
return $this->injections[$name];
|
||||
}
|
||||
|
||||
public function getDependencyList()
|
||||
public function getDependencyList() /** @phpstan-ignore-line */
|
||||
{
|
||||
return array_merge($this->dependencyList, $this->dependencies);
|
||||
}
|
||||
|
||||
protected function addDependencyList(array $list)
|
||||
protected function addDependencyList(array $list) /** @phpstan-ignore-line */
|
||||
{
|
||||
foreach ($list as $item) {
|
||||
$this->addDependency($item);
|
||||
}
|
||||
}
|
||||
|
||||
protected function addDependency($name)
|
||||
protected function addDependency($name) /** @phpstan-ignore-line */
|
||||
{
|
||||
$this->dependencyList[] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $entityType
|
||||
*/
|
||||
public function __construct($entityType, EntityManager $entityManager, EntityFactory $entityFactory)
|
||||
{
|
||||
parent::__construct($entityType, $entityManager, $entityFactory);
|
||||
|
||||
@@ -39,13 +39,17 @@ use Espo\Core\HookManager;
|
||||
|
||||
class HookMediator extends EmptyHookMediator
|
||||
{
|
||||
protected $hookManager;
|
||||
protected HookManager $hookManager;
|
||||
|
||||
public function __construct(HookManager $hookManager)
|
||||
{
|
||||
$this->hookManager = $hookManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?array<string,mixed> $columnData
|
||||
* @param array<string,mixed> $options
|
||||
*/
|
||||
public function afterRelate(
|
||||
Entity $entity,
|
||||
string $relationName,
|
||||
@@ -62,7 +66,7 @@ class HookMediator extends EmptyHookMediator
|
||||
'relationName' => $relationName,
|
||||
'relationData' => $columnData,
|
||||
'foreignEntity' => $foreignEntity,
|
||||
'foreignId' => $foreignEntity->getId()
|
||||
'foreignId' => $foreignEntity->getId(),
|
||||
];
|
||||
|
||||
$this->hookManager->process(
|
||||
@@ -73,6 +77,10 @@ class HookMediator extends EmptyHookMediator
|
||||
$hookData
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $options
|
||||
*/
|
||||
public function afterUnrelate(Entity $entity, string $relationName, Entity $foreignEntity, array $options): void
|
||||
{
|
||||
if (!empty($options['skipHooks'])) {
|
||||
@@ -94,6 +102,9 @@ class HookMediator extends EmptyHookMediator
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $options
|
||||
*/
|
||||
public function afterMassRelate(Entity $entity, string $relationName, Select $query, array $options): void
|
||||
{
|
||||
if (!empty($options['skipHooks'])) {
|
||||
|
||||
@@ -46,22 +46,16 @@ use Espo\ORM\{
|
||||
|
||||
class RepositoryFactory implements RepositoryFactoryInterface
|
||||
{
|
||||
/**
|
||||
* @var class-string
|
||||
*/
|
||||
protected $defaultClassName = DatabaseRepository::class;
|
||||
|
||||
/**
|
||||
* @var EntityFactoryInteface
|
||||
*/
|
||||
protected $entityFactory;
|
||||
protected EntityFactoryInteface $entityFactory;
|
||||
|
||||
/**
|
||||
* @var InjectableFactory
|
||||
*/
|
||||
protected $injectableFactory;
|
||||
protected InjectableFactory $injectableFactory;
|
||||
|
||||
/**
|
||||
* @var ClassFinder
|
||||
*/
|
||||
protected $classFinder;
|
||||
protected ClassFinder $classFinder;
|
||||
|
||||
public function __construct(
|
||||
EntityFactoryInteface $entityFactory,
|
||||
@@ -74,6 +68,9 @@ class RepositoryFactory implements RepositoryFactoryInterface
|
||||
$this->classFinder = $classFinder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
protected function getClassName(string $entityType): ?string
|
||||
{
|
||||
return $this->classFinder->find('Repositories', $entityType);
|
||||
|
||||
@@ -44,11 +44,11 @@ use RuntimeException;
|
||||
|
||||
class ValueFactoryFactory implements ValueFactoryFactoryInteface
|
||||
{
|
||||
private $metadata;
|
||||
private Metadata $metadata;
|
||||
|
||||
private $ormMetadata;
|
||||
private OrmMetadata $ormMetadata;
|
||||
|
||||
private $injectableFactory;
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
public function __construct(Metadata $metadata, OrmMetadata $ormMetadata, InjectableFactory $injectableFactory)
|
||||
{
|
||||
@@ -73,6 +73,9 @@ class ValueFactoryFactory implements ValueFactoryFactoryInteface
|
||||
return $this->injectableFactory->create($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
private function getClassName(string $entityType, string $field): ?string
|
||||
{
|
||||
$fieldDefs = $this->ormMetadata
|
||||
|
||||
@@ -291,6 +291,7 @@ class Metadata
|
||||
|
||||
/**
|
||||
* @param stdClass $data
|
||||
* @return stdClass
|
||||
*/
|
||||
private function addAdditionalFieldsObj($data)
|
||||
{
|
||||
|
||||
@@ -177,8 +177,8 @@ class BaseEntity implements Entity
|
||||
$p1 = $attribute;
|
||||
$p2 = $value;
|
||||
|
||||
/** @phpstan-var mixed $p1 */
|
||||
/** @phpstan-var mixed $p2 */
|
||||
/** @var mixed $p1 */
|
||||
/** @var mixed $p2 */
|
||||
|
||||
if (is_array($p1) || is_object($p1)) {
|
||||
if (is_object($p1)) {
|
||||
|
||||
@@ -86,6 +86,8 @@ class RDBRepository implements Repository
|
||||
|
||||
/**
|
||||
* Get a new entity.
|
||||
*
|
||||
* @return TEntity
|
||||
*/
|
||||
public function getNew(): Entity
|
||||
{
|
||||
@@ -102,6 +104,8 @@ class RDBRepository implements Repository
|
||||
|
||||
/**
|
||||
* Fetch an entity by ID.
|
||||
*
|
||||
* @return ?TEntity
|
||||
*/
|
||||
public function getById(string $id): ?Entity
|
||||
{
|
||||
@@ -123,7 +127,7 @@ class RDBRepository implements Repository
|
||||
/**
|
||||
* Get an entity. If ID is NULL, a new entity is returned.
|
||||
*
|
||||
* @phpstan-return ?TEntity
|
||||
* @return ?TEntity
|
||||
*/
|
||||
public function get(?string $id = null): ?Entity
|
||||
{
|
||||
@@ -141,6 +145,10 @@ class RDBRepository implements Repository
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TEntity $entity
|
||||
* @param array<string,mixed> $options
|
||||
*/
|
||||
public function save(Entity $entity, array $options = []): void
|
||||
{
|
||||
$this->processCheckEntity($entity);
|
||||
@@ -207,7 +215,7 @@ class RDBRepository implements Repository
|
||||
/**
|
||||
* Get an access point for a specific relation of a record.
|
||||
*
|
||||
* @phpstan-param TEntity $entity
|
||||
* @param TEntity $entity
|
||||
*/
|
||||
public function getRelation(Entity $entity, string $relationName): RDBRelation
|
||||
{
|
||||
@@ -246,7 +254,7 @@ class RDBRepository implements Repository
|
||||
* Find records.
|
||||
*
|
||||
* @param ?array<string,mixed> $params @deprecated
|
||||
* @phpstan-return Collection<TEntity>
|
||||
* @return Collection<TEntity>
|
||||
*/
|
||||
public function find(?array $params = []): Collection
|
||||
{
|
||||
@@ -281,7 +289,7 @@ class RDBRepository implements Repository
|
||||
if (!$mapper instanceof BaseMapper) {
|
||||
throw new RuntimeException("Not supported 'findBySql'.");
|
||||
}
|
||||
|
||||
|
||||
/** @var SthCollection<TEntity> */
|
||||
return $mapper->selectBySql($this->entityType, $sql);
|
||||
}
|
||||
@@ -790,7 +798,7 @@ class RDBRepository implements Repository
|
||||
/**
|
||||
* Clone an existing query for a further modification and usage by 'find' or 'count' methods.
|
||||
*
|
||||
* @phpstan-return RDBSelectBuilder<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
*/
|
||||
public function clone(Select $query): RDBSelectBuilder
|
||||
{
|
||||
@@ -812,7 +820,7 @@ class RDBRepository implements Repository
|
||||
* @param string|null $alias An alias.
|
||||
* @param WhereItem|array<scalar,mixed>|null $conditions Join conditions.
|
||||
*
|
||||
* @phpstan-return RDBSelectBuilder<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
*/
|
||||
public function join($target, ?string $alias = null, $conditions = null): RDBSelectBuilder
|
||||
{
|
||||
@@ -827,7 +835,7 @@ class RDBRepository implements Repository
|
||||
* @param string|null $alias An alias.
|
||||
* @param WhereItem|array<scalar,mixed>|null $conditions Join conditions.
|
||||
*
|
||||
* @phpstan-return RDBSelectBuilder<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
*/
|
||||
public function leftJoin($target, ?string $alias = null, $conditions = null): RDBSelectBuilder
|
||||
{
|
||||
@@ -857,7 +865,7 @@ class RDBRepository implements Repository
|
||||
/**
|
||||
* Set to return STH collection. Recommended fetching large number of records.
|
||||
*
|
||||
* @phpstan-return RDBSelectBuilder<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
*/
|
||||
public function sth(): RDBSelectBuilder
|
||||
@@ -894,7 +902,7 @@ class RDBRepository implements Repository
|
||||
* @param WhereItem|array<scalar,mixed>|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<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
*/
|
||||
public function having($clause = [], $value = null): RDBSelectBuilder
|
||||
{
|
||||
@@ -916,7 +924,7 @@ class RDBRepository implements Repository
|
||||
* @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC.
|
||||
*
|
||||
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]>|string[] $orderBy
|
||||
* @phpstan-return RDBSelectBuilder<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
*/
|
||||
public function order($orderBy = 'id', $direction = null): RDBSelectBuilder
|
||||
{
|
||||
@@ -926,7 +934,7 @@ class RDBRepository implements Repository
|
||||
/**
|
||||
* Apply OFFSET and LIMIT.
|
||||
*
|
||||
* @phpstan-return RDBSelectBuilder<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
*/
|
||||
public function limit(?int $offset = null, ?int $limit = null): RDBSelectBuilder
|
||||
{
|
||||
@@ -947,7 +955,7 @@ class RDBRepository implements Repository
|
||||
* An array of expressions or one expression.
|
||||
* @param string|null $alias An alias. Actual if the first parameter is not an array.
|
||||
*
|
||||
* @phpstan-return RDBSelectBuilder<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
*/
|
||||
public function select($select = [], ?string $alias = null): RDBSelectBuilder
|
||||
{
|
||||
@@ -993,7 +1001,7 @@ class RDBRepository implements Repository
|
||||
/**
|
||||
* Create a select builder.
|
||||
*
|
||||
* @phpstan-return RDBSelectBuilder<TEntity>
|
||||
* @return RDBSelectBuilder<TEntity>
|
||||
*/
|
||||
protected function createSelectBuilder(): RDBSelectBuilder
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ class RDBSelectBuilder
|
||||
|
||||
/**
|
||||
* @param ?array<string,mixed> $params @deprecated. Omit it.
|
||||
* @phpstan-return Collection<TEntity>
|
||||
* @return Collection<TEntity>
|
||||
*/
|
||||
public function find(?array $params = null): Collection
|
||||
{
|
||||
@@ -109,7 +109,7 @@ class RDBSelectBuilder
|
||||
/**
|
||||
* @param ?array<string,mixed> $params @deprecated
|
||||
*
|
||||
* @phpstan-return ?TEntity
|
||||
* @return ?TEntity
|
||||
*/
|
||||
public function findOne(?array $params = null): ?Entity
|
||||
{
|
||||
|
||||
@@ -41,14 +41,14 @@ interface Repository
|
||||
/**
|
||||
* Get a new entity.
|
||||
*
|
||||
* @phpstan-return TEntity
|
||||
* @return TEntity
|
||||
*/
|
||||
public function getNew(): Entity;
|
||||
|
||||
/**
|
||||
* Fetch an entity by ID.
|
||||
*
|
||||
* @phpstan-return ?TEntity
|
||||
* @return ?TEntity
|
||||
*/
|
||||
public function getById(string $id): ?Entity;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user