diff --git a/application/Espo/Core/Record/Collection.php b/application/Espo/Core/Record/Collection.php index 9895c2c8cd..99936dfe25 100644 --- a/application/Espo/Core/Record/Collection.php +++ b/application/Espo/Core/Record/Collection.php @@ -36,6 +36,8 @@ use stdClass; /** * Contains an an ORM collection and total number of records. + * + * @template TEntity of \Espo\ORM\Entity */ class Collection { @@ -43,10 +45,16 @@ class Collection public const TOTAL_HAS_NO_MORE = -2; - private $collection; + /** + * @var OrmCollection + */ + private OrmCollection $collection; - private $total; + private ?int $total; + /** + * @param OrmCollection $collection + */ public function __construct(OrmCollection $collection, ?int $total = null) { $this->collection = $collection; @@ -63,6 +71,8 @@ class Collection /** * Get an ORM collection. + * + * @return OrmCollection */ public function getCollection(): OrmCollection { diff --git a/application/Espo/Core/Record/CreateParams.php b/application/Espo/Core/Record/CreateParams.php index 66dbb7b5af..693695ce6c 100644 --- a/application/Espo/Core/Record/CreateParams.php +++ b/application/Espo/Core/Record/CreateParams.php @@ -31,15 +31,9 @@ namespace Espo\Core\Record; class CreateParams { - /** - * @var bool - */ - private $skipDuplicateCheck = false; + private bool $skipDuplicateCheck = false; - /** - * @var ?string - */ - private $duplicateSourceId = null; + private ?string $duplicateSourceId = null; public function __construct() {} diff --git a/application/Espo/Core/Record/Duplicator/FieldDuplicatorFactory.php b/application/Espo/Core/Record/Duplicator/FieldDuplicatorFactory.php index 942ddb298c..fd5e30dc13 100644 --- a/application/Espo/Core/Record/Duplicator/FieldDuplicatorFactory.php +++ b/application/Espo/Core/Record/Duplicator/FieldDuplicatorFactory.php @@ -37,20 +37,11 @@ use RuntimeException; class FieldDuplicatorFactory { - /** - * @var Defs - */ - private $defs; + private Defs $defs; - /** - * @var Metadata - */ - private $metadata; + private Metadata $metadata; - /** - * @var InjectableFactory - */ - private $injectableFactory; + private InjectableFactory $injectableFactory; public function __construct(Defs $defs, Metadata $metadata, InjectableFactory $injectableFactory) { @@ -75,6 +66,9 @@ class FieldDuplicatorFactory return $this->getClassName($entityType, $field) !== null; } + /** + * @return ?class-string + */ private function getClassName(string $entityType, string $field): ?string { $fieldDefs = $this->defs diff --git a/application/Espo/Core/Record/Hook/Provider.php b/application/Espo/Core/Record/Hook/Provider.php index cd6fbf6cac..5b9b04e578 100644 --- a/application/Espo/Core/Record/Hook/Provider.php +++ b/application/Espo/Core/Record/Hook/Provider.php @@ -37,12 +37,19 @@ use RuntimeException; class Provider { - private $metadata; + private Metadata $metadata; - private $injectableFactory; + private InjectableFactory $injectableFactory; + /** + * + * @var array + */ private $map = []; + /** + * @var array + */ private $typeInterfaceMap = [ Type::BEFORE_CREATE => CreateHook::class, Type::BEFORE_READ => ReadHook::class, @@ -79,6 +86,7 @@ class Provider { $key = $type . 'HookClassNameList'; + /** @var class-string[] */ $classNameList = $this->metadata->get(['recordDefs', $entityType, $key]) ?? []; $interfaceName = $this->typeInterfaceMap[$type] ?? null; diff --git a/application/Espo/Core/Record/HookManager.php b/application/Espo/Core/Record/HookManager.php index 522ec42d15..f18479fe31 100644 --- a/application/Espo/Core/Record/HookManager.php +++ b/application/Espo/Core/Record/HookManager.php @@ -44,7 +44,7 @@ use Espo\Core\Record\Hook\{ class HookManager { - private $provider; + private Provider $provider; public function __construct(Provider $provider) { @@ -126,7 +126,7 @@ class HookManager } /** - * @return LinkHook[] + * @return LinkHook<\Espo\ORM\Entity>[] */ private function getBeforeLinkHookList(string $entityType): array { diff --git a/application/Espo/Core/Record/SearchParamsFetcher.php b/application/Espo/Core/Record/SearchParamsFetcher.php index 570dc93e3e..10fffae3af 100644 --- a/application/Espo/Core/Record/SearchParamsFetcher.php +++ b/application/Espo/Core/Record/SearchParamsFetcher.php @@ -44,7 +44,7 @@ class SearchParamsFetcher { private const MAX_SIZE_LIMIT = 200; - private $config; + private Config $config; public function __construct(Config $config) { @@ -58,6 +58,9 @@ class SearchParamsFetcher ); } + /** + * @return array + */ private function fetchRaw(Request $request): array { $params = $request->hasQueryParam('searchParams') ? @@ -69,6 +72,9 @@ class SearchParamsFetcher return $params; } + /** + * @return array + */ private function fetchRawJsonSearchParams(Request $request): array { try { @@ -79,6 +85,9 @@ class SearchParamsFetcher } } + /** + * @return array + */ private function fetchRawMultipleParams(Request $request): array { $params = []; @@ -147,6 +156,9 @@ class SearchParamsFetcher return $params; } + /** + * @param array $params + */ private function handleRawParams(array &$params): void { if (isset($params['maxSize']) && !is_int($params['maxSize'])) { @@ -156,6 +168,9 @@ class SearchParamsFetcher $this->handleMaxSize($params); } + /** + * @param array $params + */ private function handleMaxSize(array &$params): void { $value = $params['maxSize']; diff --git a/application/Espo/Core/Record/Select/ApplierClassNameListProvider.php b/application/Espo/Core/Record/Select/ApplierClassNameListProvider.php index 9439295e3f..67590755a9 100644 --- a/application/Espo/Core/Record/Select/ApplierClassNameListProvider.php +++ b/application/Espo/Core/Record/Select/ApplierClassNameListProvider.php @@ -33,13 +33,16 @@ use Espo\Core\Utils\Metadata; class ApplierClassNameListProvider { - private $metadata; + private Metadata $metadata; public function __construct(Metadata $metadata) { $this->metadata = $metadata; } + /** + * @return class-string[] + */ public function get(string $entityType): array { return $this->metadata->get(['recordDefs', $entityType, 'selectApplierClassNameList']) ?? []; diff --git a/application/Espo/Core/Record/Service.php b/application/Espo/Core/Record/Service.php index 3c6d5bc660..1273af767b 100644 --- a/application/Espo/Core/Record/Service.php +++ b/application/Espo/Core/Record/Service.php @@ -110,11 +110,13 @@ class Service implements Crud, use Di\AssignmentCheckerManagerSetter; use Di\RecordHookManagerSetter; + /** @var bool */ protected $getEntityBeforeUpdate = false; /** @var ?string */ protected $entityType = null; + /** @var ?StreamService */ private $streamService = null; /** @@ -162,26 +164,34 @@ class Service implements Crud, /** @var string[] */ protected $noEditAccessRequiredLinkList = []; + /** @var bool */ protected $noEditAccessRequiredForLink = false; + /** @var bool */ protected $checkForDuplicatesInUpdate = false; + /** @var bool */ protected $actionHistoryDisabled = false; /** @var string[] */ protected $duplicatingLinkList = []; + /** @var bool */ protected $listCountQueryDisabled = false; + /** @var ?int */ protected $maxSelectTextAttributeLength = null; + /** @var bool */ protected $maxSelectTextAttributeLengthDisabled = false; + /** @var ?string[] */ protected $selectAttributeList = null; /** @var string[] */ protected $mandatorySelectAttributeList = []; + /** @var bool */ protected $forceSelectAllAttributes = false; /** @var string[] */ @@ -189,6 +199,7 @@ class Service implements Crud, /** * @todo Move to metadata. + * @var string[] */ protected $validateRequiredSkipFieldList = []; @@ -220,9 +231,11 @@ class Service implements Crud, */ protected $recordHookManager; - private $listLoadProcessor; + /** @var ?ListLoadProcessor */ + private $listLoadProcessor = null; - private $duplicateFinder; + /** @var ?DuplicateFinder */ + private $duplicateFinder = null; protected const MAX_SELECT_TEXT_ATTRIBUTE_LENGTH = 10000; @@ -357,6 +370,9 @@ class Service implements Crud, return $this->listLoadProcessor; } + /** + * @return void + */ public function loadAdditionalFields(Entity $entity) { $loadProcessor = $this->createReadLoadProcessor(); @@ -378,6 +394,7 @@ class Service implements Crud, } /** + * @param stdClass $data * @return void * @throws BadRequest */ @@ -409,6 +426,11 @@ class Service implements Crud, return $this->assignmentCheckerManager->check($this->user, $entity); } + /** + * @param string $attribute + * @param mixed $value + * @return mixed + */ protected function filterInputAttribute($attribute, $value) { if (in_array($attribute, $this->notFilteringAttributeList)) { @@ -424,9 +446,13 @@ class Service implements Crud, return $value; } + /** + * @param stdClass $data + * @return void + */ protected function filterInput($data) { - foreach ($this->readOnlyAttributeList as $attribute) { + foreach($this->readOnlyAttributeList as $attribute) { unset($data->$attribute); } @@ -434,7 +460,7 @@ class Service implements Crud, unset($data->$attribute); } - foreach ($data as $key => $value) { + foreach (get_object_vars($data) as $key => $value) { $data->$key = $this->filterInputAttribute($key, $data->$key); } @@ -495,6 +521,8 @@ class Service implements Crud, /** * @deprecated + * @param stdClass $data + * @return void */ protected function handleCreateInput($data) { @@ -502,6 +530,8 @@ class Service implements Crud, /** * @deprecated + * @param stdClass $data + * @return void */ protected function handleInput($data) { @@ -776,6 +806,7 @@ class Service implements Crud, /** * Find records. * + * @return RecordCollection * @throws Forbidden */ public function find(SearchParams $searchParams): RecordCollection @@ -903,6 +934,7 @@ class Service implements Crud, /** * Find linked records. * + * @return RecordCollection<\Espo\ORM\Entity> * @throws NotFound If a record not found. * @throws Forbidden If no access. * @throws Error @@ -1496,6 +1528,8 @@ class Service implements Crud, /** * Find duplicates for an entity. + * + * @return ?Collection */ public function findDuplicates(Entity $entity): ?Collection { @@ -1544,6 +1578,11 @@ class Service implements Crud, } } + /** + * @return RecordCollection<\Espo\ORM\Entity> + * @throws NotFound + * @throws Forbidden + */ protected function findLinkedFollowers(string $id, SearchParams $params): RecordCollection { $entity = $this->getRepository()->getById($id); @@ -1627,6 +1666,10 @@ class Service implements Crud, } } + /** + * @param string $type + * @return string[] + */ protected function getFieldByTypeList($type) { return $this->fieldUtil->getFieldByTypeList($this->entityType, $type); @@ -1689,6 +1732,7 @@ class Service implements Crud, /** * @param stdClass $data + * @return void */ protected function beforeCreateEntity(Entity $entity, $data) { @@ -1696,6 +1740,7 @@ class Service implements Crud, /** * @param stdClass $data + * @return void */ protected function afterCreateEntity(Entity $entity, $data) { @@ -1703,6 +1748,7 @@ class Service implements Crud, /** * @param stdClass $data + * @return void */ protected function beforeUpdateEntity(Entity $entity, $data) { @@ -1710,15 +1756,22 @@ class Service implements Crud, /** * @param stdClass $data + * @return void */ protected function afterUpdateEntity(Entity $entity, $data) { } + /** + * @return void + */ protected function beforeDeleteEntity(Entity $entity) { } + /** + * @return void + */ protected function afterDeleteEntity(Entity $entity) { } diff --git a/application/Espo/Core/Record/ServiceContainer.php b/application/Espo/Core/Record/ServiceContainer.php index 6061bed5f2..ed1328f465 100644 --- a/application/Espo/Core/Record/ServiceContainer.php +++ b/application/Espo/Core/Record/ServiceContainer.php @@ -46,15 +46,21 @@ class ServiceContainer private const RECORD_TREE_SERVICE_NAME = 'RecordTree'; + /** + * @var array + */ private $defaultTypeMap = [ 'CategoryTree' => self::RECORD_TREE_SERVICE_NAME, ]; + /** + * @var array> + */ private $data = []; - private $serviceFactory; + private ServiceFactory $serviceFactory; - private $metadata; + private Metadata $metadata; public function __construct(ServiceFactory $serviceFactory, Metadata $metadata) { @@ -62,6 +68,9 @@ class ServiceContainer $this->metadata = $metadata; } + /** + * @return Service<\Espo\ORM\Entity> + */ public function get(string $entityType): Service { if (!array_key_exists($entityType, $this->data)) { diff --git a/application/Espo/Core/Record/UpdateParams.php b/application/Espo/Core/Record/UpdateParams.php index 5924ea9061..6fff221203 100644 --- a/application/Espo/Core/Record/UpdateParams.php +++ b/application/Espo/Core/Record/UpdateParams.php @@ -31,9 +31,9 @@ namespace Espo\Core\Record; class UpdateParams { - private $skipDuplicateCheck = false; + private bool $skipDuplicateCheck = false; - private $versionNumber = null; + private ?int $versionNumber = null; public function __construct() {} diff --git a/application/Espo/Services/Notification.php b/application/Espo/Services/Notification.php index 259d0bad17..39fe0c5c2f 100644 --- a/application/Espo/Services/Notification.php +++ b/application/Espo/Services/Notification.php @@ -29,8 +29,6 @@ namespace Espo\Services; -use Espo\Entities\Note; - use Espo\Core\{ Record\Collection as RecordCollection, Exceptions\Error, @@ -159,7 +157,7 @@ class Notification extends \Espo\Services\Record switch ($entity->get('type')) { case 'Note': case 'MentionInPost': - /** @var ?Note $note */ + /** @var ?\Espo\Entities\Note $note */ $note = $this->entityManager->getEntity('Note', $data->noteId); if (!$note) {