diff --git a/application/Espo/Tools/Import/Import.php b/application/Espo/Tools/Import/Import.php index 23dae063b5..4a2cd55a2c 100644 --- a/application/Espo/Tools/Import/Import.php +++ b/application/Espo/Tools/Import/Import.php @@ -71,15 +71,18 @@ class Import private const DEFAULT_TIME_FORMAT = 'HH:mm'; + /** + * @var string[] + */ private $attributeList = []; - private $params; + private Params $params; - private $id = null; + private ?string $id = null; - private $attachmentId = null; + private ?string $attachmentId = null; - private $entityType = null; + private ?string $entityType = null; private $aclManager; @@ -165,6 +168,8 @@ class Import /** * Set an attribute list to parse from CSV rows. + * + * @param string[] $attributeList */ public function setAttributeList(array $attributeList): self { @@ -386,6 +391,11 @@ class Import ->withCountUpdated(count($result->updatedIds)); } + /** + * @param string[] $attributeList + * @param mixed[] $row + * @throws Error + */ private function importRow(array $attributeList, array $row): ?stdClass { $params = $this->params; @@ -627,6 +637,9 @@ class Import } } + /** + * @param mixed $value + */ private function processRowItem(Entity $entity, string $attribute, $value, stdClass $valueMap): void { $params = $this->params; @@ -801,6 +814,7 @@ class Import } /** + * @param mixed $value * @return mixed */ private function parseValue(Entity $entity, string $attribute, $value) @@ -894,6 +908,7 @@ class Import } /** + * @param mixed $value * @return mixed */ private function prepareAttributeValue(Entity $entity, string $attribute, $value) @@ -909,7 +924,14 @@ class Import return $value; } - private function parsePersonName($value, string $format): array + /** + * @return array{ + * firstName: ?string, + * lastName: ?string, + * middleName?: ?string, + * } + */ + private function parsePersonName(string $value, string $format): array { $firstName = null; $lastName = $value; @@ -929,6 +951,7 @@ class Import case 'l f': $pos = strpos($value, ' '); + if ($pos) { $lastName = trim(substr($value, 0, $pos)); $firstName = trim(substr($value, $pos + 1)); @@ -1002,6 +1025,9 @@ class Import ]; } + /** + * @return string[] + */ private function readCsvString( string &$string, string $separator = ';', diff --git a/application/Espo/Tools/Import/Params.php b/application/Espo/Tools/Import/Params.php index c092b8b087..4cc9dc734f 100644 --- a/application/Espo/Tools/Import/Params.php +++ b/application/Espo/Tools/Import/Params.php @@ -40,39 +40,42 @@ class Params public const ACTION_UPDATE = 'update'; - private $action = null; + private ?string $action = null; - private $delimiter = null; + private ?string $delimiter = null; - private $textQualifier = null; + private ?string $textQualifier = null; - private $personNameFormat = null; + private ?string $personNameFormat = null; - private $idleMode = false; + private bool $idleMode = false; - private $manualMode = false; + private bool $manualMode = false; - private $silentMode = false; + private bool $silentMode = false; - private $headerRow = false; + private bool $headerRow = false; - private $skipDuplicateChecking = false; + private bool $skipDuplicateChecking = false; - private $startFromLastIndex = false; + private bool $startFromLastIndex = false; + /** + * @var int[] + */ private $updateBy = []; - private $defaultValues; + private stdClass $defaultValues; - private $dateFormat = null; + private ?string $dateFormat = null; - private $timeFormat = null; + private ?string $timeFormat = null; - private $currency = null; + private ?string $currency = null; - private $timezone = null; + private ?string $timezone = null; - private $decimalMark = null; + private ?string $decimalMark = null; private function __construct() { @@ -129,6 +132,9 @@ class Params return $this->startFromLastIndex; } + /** + * @return int[] + */ public function getUpdateBy(): array { return $this->updateBy; @@ -249,6 +255,9 @@ class Params return $obj; } + /** + * @param int[] $updateBy + */ public function withUpdateBy(array $updateBy): self { $obj = clone $this; @@ -258,7 +267,7 @@ class Params } /** - * @param stdClass|array|null $defaultValues + * @param stdClass|array|null $defaultValues */ public function withDefaultValues($defaultValues): self { @@ -323,7 +332,7 @@ class Params } /** - * @param stdClass|array|null $params + * @param stdClass|array|null $params */ public static function fromRaw($params): self { @@ -355,6 +364,9 @@ class Params return $obj; } + /** + * @return array + */ public function getRaw(): array { return [ diff --git a/application/Espo/Tools/Import/Result.php b/application/Espo/Tools/Import/Result.php index 438811da11..872df3980c 100644 --- a/application/Espo/Tools/Import/Result.php +++ b/application/Espo/Tools/Import/Result.php @@ -33,13 +33,13 @@ use stdClass; class Result { - private $id = null; + private ?string $id = null; - private $countCreated = 0; + private int $countCreated = 0; - private $countUpdated = 0; + private int $countUpdated = 0; - private $manualMode = false; + private bool $manualMode = false; public function getId(): ?string { diff --git a/application/Espo/Tools/Import/Service.php b/application/Espo/Tools/Import/Service.php index c9ecd528d1..4def79a605 100644 --- a/application/Espo/Tools/Import/Service.php +++ b/application/Espo/Tools/Import/Service.php @@ -68,6 +68,11 @@ class Service $this->acl = $acl; } + /** + * @param string[] $attributeList + * @param string $attachmentId + * @throws Forbidden + */ public function import( string $entityType, array $attributeList,