diff --git a/application/Espo/Core/Application.php b/application/Espo/Core/Application.php index fee2b16e83..259a00eca6 100644 --- a/application/Espo/Core/Application.php +++ b/application/Espo/Core/Application.php @@ -93,7 +93,7 @@ class Application } $runner = $this->getInjectableFactory()->createWith($className, [ - 'params' => $params ?? RunnerParams::fromNothing(), + 'params' => $params ?? RunnerParams::create(), ]); if (!$runner instanceof Runner) { diff --git a/application/Espo/Core/Application/RunnerParams.php b/application/Espo/Core/Application/RunnerParams.php index 1fec126c7a..ddabf5bbad 100644 --- a/application/Espo/Core/Application/RunnerParams.php +++ b/application/Espo/Core/Application/RunnerParams.php @@ -34,9 +34,9 @@ namespace Espo\Core\Application; */ class RunnerParams { - private $data; + private $data = []; - private function __construct() + public function __construct() { } @@ -73,7 +73,7 @@ class RunnerParams } /** - * Create from an array. + * Create from an associative array. */ public static function fromArray(array $data): self { @@ -87,7 +87,7 @@ class RunnerParams /** * Create an empty instance. */ - public static function fromNothing(): self + public static function create(): self { return new self(); } diff --git a/application/Espo/Core/ApplicationRunners/EntryPoint.php b/application/Espo/Core/ApplicationRunners/EntryPoint.php index 5a285a09e3..4fb4966f21 100644 --- a/application/Espo/Core/ApplicationRunners/EntryPoint.php +++ b/application/Espo/Core/ApplicationRunners/EntryPoint.php @@ -98,7 +98,7 @@ class EntryPoint implements Runner $this->authBuilderFactory = $authBuilderFactory; $this->errorOutput = $errorOutput; - $this->params = $params ?? RunnerParams::fromNothing(); + $this->params = $params ?? RunnerParams::create(); } public function run(): void diff --git a/application/Espo/Core/ApplicationRunners/PortalClient.php b/application/Espo/Core/ApplicationRunners/PortalClient.php index 1967968072..0fdbc5a0cc 100644 --- a/application/Espo/Core/ApplicationRunners/PortalClient.php +++ b/application/Espo/Core/ApplicationRunners/PortalClient.php @@ -74,7 +74,7 @@ class PortalClient implements Runner $this->config = $config; $this->errorOutput = $errorOutput; - $this->params = $params ?? RunnerParams::fromNothing(); + $this->params = $params ?? RunnerParams::create(); } public function run(): void diff --git a/application/Espo/Core/Authentication/Result.php b/application/Espo/Core/Authentication/Result.php index 170034d5a4..2942eb8b72 100644 --- a/application/Espo/Core/Authentication/Result.php +++ b/application/Espo/Core/Authentication/Result.php @@ -84,8 +84,8 @@ class Result public static function fail(?string $reason = null): self { $data = $reason ? - ResultData::fromFailReason($reason) : - ResultData::fromNothing(); + ResultData::createWithFailReason($reason) : + ResultData::create(); return new self(self::STATUS_FAIL, null, $data); } diff --git a/application/Espo/Core/Authentication/ResultData.php b/application/Espo/Core/Authentication/ResultData.php index a0c8e4df1e..f3ea06182b 100644 --- a/application/Espo/Core/Authentication/ResultData.php +++ b/application/Espo/Core/Authentication/ResultData.php @@ -57,17 +57,17 @@ class ResultData $this->loggedUser = $loggedUser; } - public static function fromNothing(): self + public static function create(): self { return new self(); } - public static function fromFailReason(string $failReason): self + public static function createWithFailReason(string $failReason): self { return new self(null, $failReason); } - public static function fromMessage(string $message): self + public static function createWithMessage(string $message): self { return new self($message); } @@ -112,4 +112,49 @@ class ResultData { return $this->failReason; } + + public function withMessage(?string $message): self + { + $obj = clone $this; + + $obj->message = $message; + + return $obj; + } + + public function withFailReason(?string $failReason): self + { + $obj = clone $this; + + $obj->failReason = $failReason; + + return $obj; + } + + public function withToken(?string $token): self + { + $obj = clone $this; + + $obj->token = $token; + + return $obj; + } + + public function withView(?string $view): self + { + $obj = clone $this; + + $obj->view = $view; + + return $obj; + } + + public function withLoggedUser(?User $loggedUser): self + { + $obj = clone $this; + + $obj->loggedUser = $loggedUser; + + return $obj; + } } diff --git a/application/Espo/Core/Authentication/TwoFactor/Methods/Totp.php b/application/Espo/Core/Authentication/TwoFactor/Methods/Totp.php index 4c6fedeaef..2524eb894c 100644 --- a/application/Espo/Core/Authentication/TwoFactor/Methods/Totp.php +++ b/application/Espo/Core/Authentication/TwoFactor/Methods/Totp.php @@ -80,6 +80,6 @@ class Totp implements CodeVerify public function getLoginData(User $user): ResultData { - return ResultData::fromMessage('enterTotpCode'); + return ResultData::createWithMessage('enterTotpCode'); } } diff --git a/application/Espo/Core/FieldProcessing/LoaderParams.php b/application/Espo/Core/FieldProcessing/LoaderParams.php index 7375882d97..759d88e087 100644 --- a/application/Espo/Core/FieldProcessing/LoaderParams.php +++ b/application/Espo/Core/FieldProcessing/LoaderParams.php @@ -62,7 +62,7 @@ class LoaderParams return $obj; } - public static function fromNothing(): self + public static function create(): self { return new self(); } diff --git a/application/Espo/Core/FieldProcessing/SaveProcessor.php b/application/Espo/Core/FieldProcessing/SaveProcessor.php index 0eec8a4f84..7df98d4129 100644 --- a/application/Espo/Core/FieldProcessing/SaveProcessor.php +++ b/application/Espo/Core/FieldProcessing/SaveProcessor.php @@ -55,7 +55,7 @@ class SaveProcessor public function process(Entity $entity, array $options): void { - $params = SaverParams::fromNothing()->withRawOptions($options); + $params = SaverParams::create()->withRawOptions($options); foreach ($this->getSaverList($entity->getEntityType()) as $processor) { $processor->process($entity, $params); diff --git a/application/Espo/Core/FieldProcessing/SaverParams.php b/application/Espo/Core/FieldProcessing/SaverParams.php index 80ac66d67e..61b69f1eb6 100644 --- a/application/Espo/Core/FieldProcessing/SaverParams.php +++ b/application/Espo/Core/FieldProcessing/SaverParams.php @@ -65,7 +65,7 @@ class SaverParams return $obj; } - public static function fromNothing(): self + public static function create(): self { return new self(); } diff --git a/application/Espo/Core/FieldValidation/Params.php b/application/Espo/Core/FieldValidation/Params.php index e253108e09..bbd3fabaf7 100644 --- a/application/Espo/Core/FieldValidation/Params.php +++ b/application/Espo/Core/FieldValidation/Params.php @@ -42,7 +42,7 @@ class Params /** * A field list that will be skipped in validation. * - * @return array + * @return string[] */ public function getSkipFieldList(): array { @@ -52,7 +52,7 @@ class Params /** * A field list that will be skipped in validation for a specific validation type. * - * @return array + * @return string[] */ public function getTypeSkipFieldList(string $type): array { @@ -62,7 +62,7 @@ class Params /** * Clone with a specified field list that will be skipped in validation. * - * @param array $list + * @param string[] $list */ public function withSkipFieldList(array $list): self { @@ -76,7 +76,7 @@ class Params /** * Clone with a specified field list that will be skipped in validation for a specific validation type. * - * @param array $list + * @param string[] $list */ public function withTypeSkipFieldList(string $type, array $list): self { @@ -90,7 +90,7 @@ class Params /** * Create an empty instance. */ - public static function fromNothing(): self + public static function create(): self { return new self(); } diff --git a/application/Espo/Core/Fields/Address.php b/application/Espo/Core/Fields/Address.php index 33f6b127d4..74b547d792 100644 --- a/application/Espo/Core/Fields/Address.php +++ b/application/Espo/Core/Fields/Address.php @@ -208,7 +208,7 @@ class Address /** * Create an empty address. */ - public static function fromNothing(): self + public static function create(): self { return new self(); } diff --git a/application/Espo/Core/Fields/Currency.php b/application/Espo/Core/Fields/Currency.php index 98512ebc47..5b31adc5d2 100644 --- a/application/Espo/Core/Fields/Currency.php +++ b/application/Espo/Core/Fields/Currency.php @@ -135,7 +135,7 @@ class Currency /** * Create from an amount and code. */ - public static function fromAmountAndCode(float $amount, string $code): self + public static function create(float $amount, string $code): self { return new self($amount, $code); } diff --git a/application/Espo/Core/Fields/EmailAddress.php b/application/Espo/Core/Fields/EmailAddress.php index a8d1ec8b91..b7c3d6b6f9 100644 --- a/application/Espo/Core/Fields/EmailAddress.php +++ b/application/Espo/Core/Fields/EmailAddress.php @@ -132,7 +132,7 @@ class EmailAddress /** * Create from an address. */ - public static function fromAddress(string $address): self + public static function create(string $address): self { return new self($address); } diff --git a/application/Espo/Core/Fields/EmailAddress/EmailAddressGroupFactory.php b/application/Espo/Core/Fields/EmailAddress/EmailAddressGroupFactory.php index d775ffa318..2269d45a15 100644 --- a/application/Espo/Core/Fields/EmailAddress/EmailAddressGroupFactory.php +++ b/application/Espo/Core/Fields/EmailAddress/EmailAddressGroupFactory.php @@ -105,7 +105,7 @@ class EmailAddressGroupFactory implements ValueFactory } foreach ($dataList as $item) { - $emailAddress = EmailAddress::fromAddress($item->emailAddress); + $emailAddress = EmailAddress::create($item->emailAddress); if ($item->optOut) { $emailAddress = $emailAddress->optedOut(); @@ -122,7 +122,7 @@ class EmailAddressGroupFactory implements ValueFactory $emailAddressList[] = $emailAddress; } - $group = EmailAddressGroup::fromList($emailAddressList); + $group = EmailAddressGroup::create($emailAddressList); if ($primaryEmailAddress) { $group = $group->withPrimary($primaryEmailAddress); diff --git a/application/Espo/Core/Fields/EmailAddressGroup.php b/application/Espo/Core/Fields/EmailAddressGroup.php index 79504aaa5a..a8da9c2d0e 100644 --- a/application/Espo/Core/Fields/EmailAddressGroup.php +++ b/application/Espo/Core/Fields/EmailAddressGroup.php @@ -38,7 +38,7 @@ use RuntimeException; class EmailAddressGroup { /** - * @var array + * @var EmailAddress[] */ private $list = []; @@ -48,7 +48,7 @@ class EmailAddressGroup private $primary = null; /** - * @param array $list + * @param EmailAddress[] $list * * @throws RuntimeException */ @@ -95,7 +95,7 @@ class EmailAddressGroup /** * Get a list of all email addresses. * - * @return array + * @return EmailAddress[] */ public function getList(): array { @@ -113,7 +113,7 @@ class EmailAddressGroup /** * Get a list of email addresses w/o a primary. * - * @return array + * @return EmailAddress[] */ public function getSecondaryList(): array { @@ -133,7 +133,7 @@ class EmailAddressGroup /** * Get a list of email addresses represented as strings. * - * @return array + * @return string[] */ public function getAddressList(): array { @@ -185,13 +185,13 @@ class EmailAddressGroup $newList = array_merge([$emailAddress], $list); - return self::fromList($newList); + return self::create($newList); } /** * Clone with an added email address list. * - * @param array $list + * @param EmailAddress[] $list */ public function withAddedList(array $list): self { @@ -209,7 +209,7 @@ class EmailAddressGroup $newList[] = $item; } - return self::fromList($newList); + return self::create($newList); } /** @@ -243,27 +243,19 @@ class EmailAddressGroup $newList = array_values($newList); } - return self::fromList($newList); + return self::create($newList); } /** - * Create from an email address list. A first item will be set as primary. + * Create with an optional email address list. A first item will be set as primary. * - * @param array $list + * @param EmailAddress[] $list */ - public static function fromList(array $list): self + public static function create(array $list = []): self { return new self($list); } - /** - * Create empty. - */ - public static function fromNothing(): self - { - return new self([]); - } - private function searchAddressInList(string $address): ?int { foreach ($this->getAddressList() as $i => $item) { diff --git a/application/Espo/Core/Fields/Link.php b/application/Espo/Core/Fields/Link.php index f2d3dbc71f..7a7c8a37e9 100644 --- a/application/Espo/Core/Fields/Link.php +++ b/application/Espo/Core/Fields/Link.php @@ -80,7 +80,7 @@ class Link /** * Create from an ID. */ - public static function fromId(string $id): self + public static function create(string $id): self { return new self($id); } diff --git a/application/Espo/Core/Fields/Link/LinkFactory.php b/application/Espo/Core/Fields/Link/LinkFactory.php index 19fa4e0b3f..ed69528bd0 100644 --- a/application/Espo/Core/Fields/Link/LinkFactory.php +++ b/application/Espo/Core/Fields/Link/LinkFactory.php @@ -55,7 +55,7 @@ class LinkFactory implements ValueFactory $name = $entity->get($field . 'Name'); return Link - ::fromId($id) + ::create($id) ->withName($name); } } diff --git a/application/Espo/Core/Fields/LinkMultiple.php b/application/Espo/Core/Fields/LinkMultiple.php index 00e0abf81c..b80b258b2c 100644 --- a/application/Espo/Core/Fields/LinkMultiple.php +++ b/application/Espo/Core/Fields/LinkMultiple.php @@ -39,7 +39,7 @@ class LinkMultiple private $list = []; /** - * @param array $list + * @param LinkMultipleItem[] $list * * @throws RuntimeException */ @@ -72,7 +72,7 @@ class LinkMultiple /** * Get a list of IDs. * - * @return array + * @return string[] */ public function getIdList(): array { @@ -88,7 +88,7 @@ class LinkMultiple /** * Get a list of items. * - * @return array + * @return LinkMultipleItem[] */ public function getList(): array { @@ -128,7 +128,7 @@ class LinkMultiple /** * Clone with an added item list. * . - * @param array $list + * @param LinkMultipleItem[] $list * * @throws RuntimeException */ @@ -148,7 +148,7 @@ class LinkMultiple $newList[] = $item; } - return self::fromList($newList); + return self::create($newList); } /** @@ -174,29 +174,21 @@ class LinkMultiple $newList = array_values($newList); } - return self::fromList($newList); + return self::create($newList); } /** - * Create from an item list. + * Create with an optional item list. * - * @param array $list + * @param LinkMultipleItem[] $list * * @throws RuntimeException */ - public static function fromList(array $list): self + public static function create(array $list = []): self { return new self($list); } - /** - * Create empty. - */ - public static function fromNothing(): self - { - return new self([]); - } - private function validateList(): void { $idList = []; diff --git a/application/Espo/Core/Fields/LinkMultiple/LinkMultipleFactory.php b/application/Espo/Core/Fields/LinkMultiple/LinkMultipleFactory.php index 5153bfba27..93d07dbe8a 100644 --- a/application/Espo/Core/Fields/LinkMultiple/LinkMultipleFactory.php +++ b/application/Espo/Core/Fields/LinkMultiple/LinkMultipleFactory.php @@ -100,7 +100,7 @@ class LinkMultipleFactory implements ValueFactory } foreach ($idList as $id) { - $item = LinkMultipleItem::fromId($id); + $item = LinkMultipleItem::create($id); if ($columnData && property_exists($columnData, $id)) { $item = $this->addColumnValues($item, $columnData->$id); diff --git a/application/Espo/Core/Fields/LinkMultipleItem.php b/application/Espo/Core/Fields/LinkMultipleItem.php index 271e91c3eb..9022bda1d6 100644 --- a/application/Espo/Core/Fields/LinkMultipleItem.php +++ b/application/Espo/Core/Fields/LinkMultipleItem.php @@ -125,11 +125,11 @@ class LinkMultipleItem } /** - * Create from an ID. + * Create. * * @throws RuntimeException */ - public static function fromId(string $id): self + public static function create(string $id): self { return new self($id); } diff --git a/application/Espo/Core/Fields/LinkParent.php b/application/Espo/Core/Fields/LinkParent.php index c378a3ba2c..7910de13ac 100644 --- a/application/Espo/Core/Fields/LinkParent.php +++ b/application/Espo/Core/Fields/LinkParent.php @@ -93,9 +93,9 @@ class LinkParent } /** - * Create from an entity type and ID. + * Create. */ - public static function fromEntityTypeAndId(string $entityType, string $id): self + public static function create(string $entityType, string $id): self { return new self($entityType, $id); } diff --git a/application/Espo/Core/Fields/LinkParent/LinkParentFactory.php b/application/Espo/Core/Fields/LinkParent/LinkParentFactory.php index 6a341e6e52..c9029eb615 100644 --- a/application/Espo/Core/Fields/LinkParent/LinkParentFactory.php +++ b/application/Espo/Core/Fields/LinkParent/LinkParentFactory.php @@ -55,7 +55,7 @@ class LinkParentFactory implements ValueFactory $entityType = $entity->get($field . 'Type'); return LinkParent - ::fromEntityTypeAndId($entityType, $id) + ::create($entityType, $id) ->withName($entity->get($field . 'Name')); } } diff --git a/application/Espo/Core/Fields/PhoneNumber.php b/application/Espo/Core/Fields/PhoneNumber.php index c92a6b3431..56cc2b7429 100644 --- a/application/Espo/Core/Fields/PhoneNumber.php +++ b/application/Espo/Core/Fields/PhoneNumber.php @@ -146,9 +146,9 @@ class PhoneNumber } /** - * Create from a number. + * Create with a number. */ - public static function fromNumber(string $number): self + public static function create(string $number): self { return new self($number); } @@ -156,9 +156,9 @@ class PhoneNumber /** * Create from a number and type. */ - public static function fromNumberAndType(string $number, string $type): self + public static function createWithType(string $number, string $type): self { - return self::fromNumber($number)->withType($type); + return self::create($number)->withType($type); } private function clone(): self diff --git a/application/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupFactory.php b/application/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupFactory.php index f77e73696a..d20f835969 100644 --- a/application/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupFactory.php +++ b/application/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupFactory.php @@ -105,7 +105,7 @@ class PhoneNumberGroupFactory implements ValueFactory } foreach ($dataList as $item) { - $phoneNumber = PhoneNumber::fromNumber($item->phoneNumber); + $phoneNumber = PhoneNumber::create($item->phoneNumber); if ($item->type) { $phoneNumber = $phoneNumber->withType($item->type); @@ -126,7 +126,7 @@ class PhoneNumberGroupFactory implements ValueFactory $phoneNumberList[] = $phoneNumber; } - $group = PhoneNumberGroup::fromList($phoneNumberList); + $group = PhoneNumberGroup::create($phoneNumberList); if ($primaryPhoneNumber) { $group = $group->withPrimary($primaryPhoneNumber); diff --git a/application/Espo/Core/Fields/PhoneNumberGroup.php b/application/Espo/Core/Fields/PhoneNumberGroup.php index b010e4fbd3..d5d3d87bb7 100644 --- a/application/Espo/Core/Fields/PhoneNumberGroup.php +++ b/application/Espo/Core/Fields/PhoneNumberGroup.php @@ -38,7 +38,7 @@ use RuntimeException; class PhoneNumberGroup { /** - * @var array + * @var PhoneNumber[] */ private $list = []; @@ -48,7 +48,7 @@ class PhoneNumberGroup private $primary = null; /** - * @param array $list + * @param PhoneNumber[] $list * * @throws RuntimeException */ @@ -95,7 +95,7 @@ class PhoneNumberGroup /** * Get a list of all phone numbers. * - * @return array + * @return PhoneNumber[] */ public function getList(): array { @@ -113,7 +113,7 @@ class PhoneNumberGroup /** * Get a list of phone numbers w/o a primary. * - * @return array + * @return PhoneNumber[] */ public function getSecondaryList(): array { @@ -133,7 +133,7 @@ class PhoneNumberGroup /** * Get a list of phone numbers represented as strings. * - * @return array + * @return string[] */ public function getNumberList(): array { @@ -185,13 +185,13 @@ class PhoneNumberGroup $newList = array_merge([$phoneNumber], $list); - return self::fromList($newList); + return self::create($newList); } /** * Clone with an added phone number list. * - * @param array $list + * @param PhoneNumber[] $list */ public function withAddedList(array $list): self { @@ -209,7 +209,7 @@ class PhoneNumberGroup $newList[] = $item; } - return self::fromList($newList); + return self::create($newList); } /** @@ -243,27 +243,19 @@ class PhoneNumberGroup $newList = array_values($newList); } - return self::fromList($newList); + return self::create($newList); } /** - * Create from a phone number list. A first item will be set as primary. + * Create with an optional phone number list. A first item will be set as primary. * - * @param array $list + * @param PhoneNumber[] $list */ - public static function fromList(array $list): self + public static function create(array $list = []): self { return new self($list); } - /** - * Create empty. - */ - public static function fromNothing(): self - { - return new self([]); - } - private function searchNumberInList(string $number): ?int { foreach ($this->getNumberList() as $i => $item) { diff --git a/application/Espo/Core/Formula/Functions/ExtGroup/PdfGroup/GenerateType.php b/application/Espo/Core/Formula/Functions/ExtGroup/PdfGroup/GenerateType.php index adbe48cc50..2de88539d4 100644 --- a/application/Espo/Core/Formula/Functions/ExtGroup/PdfGroup/GenerateType.php +++ b/application/Espo/Core/Formula/Functions/ExtGroup/PdfGroup/GenerateType.php @@ -112,7 +112,7 @@ class GenerateType extends BaseFunction implements $fileName = Util::sanitizeFileName($entity->get('name')) . '.pdf'; } - $data = Data::fromNothing()->withAcl(false); + $data = Data::create()->withAcl(false); try { $contents = $this->serviceFactory diff --git a/application/Espo/Core/Job/JobManager.php b/application/Espo/Core/Job/JobManager.php index cfa028b82d..11f39c47d8 100644 --- a/application/Espo/Core/Job/JobManager.php +++ b/application/Espo/Core/Job/JobManager.php @@ -177,7 +177,7 @@ class JobManager public function processQueue(string $queue, int $limit): void { $params = QueueProcessorParams - ::fromNothing() + ::create() ->withQueue($queue) ->withLimit($limit) ->withUseProcessPool(false) @@ -193,7 +193,7 @@ class JobManager $limit = (int) $this->config->get('jobMaxPortion', 0); $params = QueueProcessorParams - ::fromNothing() + ::create() ->withUseProcessPool($this->useProcessPool) ->withLimit($limit); diff --git a/application/Espo/Core/Job/QueueProcessorParams.php b/application/Espo/Core/Job/QueueProcessorParams.php index af2334d16c..f71d747d30 100644 --- a/application/Espo/Core/Job/QueueProcessorParams.php +++ b/application/Espo/Core/Job/QueueProcessorParams.php @@ -95,7 +95,7 @@ class QueueProcessorParams return $this->limit; } - public static function fromNothing(): self + public static function create(): self { return new self(); } diff --git a/application/Espo/Core/MassAction/Params.php b/application/Espo/Core/MassAction/Params.php index 1dacc32a83..0b4dc9a2f7 100644 --- a/application/Espo/Core/MassAction/Params.php +++ b/application/Espo/Core/MassAction/Params.php @@ -75,7 +75,7 @@ class Params return !is_null($this->ids); } - public static function fromIds(string $entityType, array $ids): self + public static function createWithIds(string $entityType, array $ids): self { return self::fromRaw([ 'entityType' => $entityType, @@ -83,7 +83,7 @@ class Params ]); } - public static function fromSearchParams(string $entityType, SearchParams $searchParams): self + public static function createWithSearchParams(string $entityType, SearchParams $searchParams): self { $obj = new self(); diff --git a/application/Espo/Core/Record/Service.php b/application/Espo/Core/Record/Service.php index 4a825aa26d..24efa0630a 100644 --- a/application/Espo/Core/Record/Service.php +++ b/application/Espo/Core/Record/Service.php @@ -354,7 +354,7 @@ class Service implements Crud, public function processValidation(Entity $entity, $data) { $params = FieldValidationParams - ::fromNothing() + ::create() ->withSkipFieldList($this->validateSkipFieldList) ->withTypeSkipFieldList('required', $this->validateRequiredSkipFieldList); diff --git a/application/Espo/Core/Select/SearchParams.php b/application/Espo/Core/Select/SearchParams.php index 320424280d..1de5f16026 100644 --- a/application/Espo/Core/Select/SearchParams.php +++ b/application/Espo/Core/Select/SearchParams.php @@ -252,7 +252,7 @@ class SearchParams /** * Create an empty instance. */ - public static function fromNothing(): self + public static function create(): self { return new self(); } diff --git a/application/Espo/Modules/Crm/Services/Activities.php b/application/Espo/Modules/Crm/Services/Activities.php index e4b19d4ecc..f0de9cc1c2 100644 --- a/application/Espo/Modules/Crm/Services/Activities.php +++ b/application/Espo/Modules/Crm/Services/Activities.php @@ -829,7 +829,7 @@ class Activities implements ); $loadProcessorParams = FieldLoaderParams - ::fromNothing() + ::create() ->withSelect($searchParams->getSelect()); foreach ($collection as $e) { diff --git a/application/Espo/Services/Pdf.php b/application/Espo/Services/Pdf.php index 1573b5e45f..24845cc9c7 100644 --- a/application/Espo/Services/Pdf.php +++ b/application/Espo/Services/Pdf.php @@ -332,7 +332,7 @@ class Pdf if (!$data) { $data = Data - ::fromNothing() + ::create() ->withAdditionalTemplateData($additionalData ?? []) ->withAcl($applyAcl); } diff --git a/application/Espo/Tools/Export/Export.php b/application/Espo/Tools/Export/Export.php index 8a3ba0d9a5..73daf1d71d 100644 --- a/application/Espo/Tools/Export/Export.php +++ b/application/Espo/Tools/Export/Export.php @@ -148,7 +148,7 @@ class Export $dataResource = fopen('php://temp', 'w'); $loaderParams = LoaderParams - ::fromNothing() + ::create() ->withSelect($attributeList); $recordService = $this->serviceContainer->get($entityType); diff --git a/application/Espo/Tools/Export/Params.php b/application/Espo/Tools/Export/Params.php index 1e62abba89..ab995bfe1d 100644 --- a/application/Espo/Tools/Export/Params.php +++ b/application/Espo/Tools/Export/Params.php @@ -110,7 +110,7 @@ class Params } $obj->searchParams = SearchParams - ::fromNothing() + ::create() ->withWhere( WhereItem::fromRaw([ 'type' => 'equals', @@ -131,7 +131,7 @@ class Params return $obj; } - public static function fromEntityType(string $entityType): self + public static function create(string $entityType): self { return new self($entityType); } @@ -205,7 +205,7 @@ class Params public function getSearchParams(): SearchParams { if (!$this->searchParams) { - return SearchParams::fromNothing(); + return SearchParams::create(); } return $this->searchParams; diff --git a/application/Espo/Tools/Kanban/Kanban.php b/application/Espo/Tools/Kanban/Kanban.php index a4771a4f82..37bf35ce7f 100644 --- a/application/Espo/Tools/Kanban/Kanban.php +++ b/application/Espo/Tools/Kanban/Kanban.php @@ -251,7 +251,7 @@ class Kanban } $loadProcessorParams = FieldLoaderParams - ::fromNothing() + ::create() ->withSelect($searchParams->getSelect()); foreach ($collectionSub as $e) { diff --git a/application/Espo/Tools/Pdf/Data.php b/application/Espo/Tools/Pdf/Data.php index 8a6cde5f12..1dceb29e8f 100644 --- a/application/Espo/Tools/Pdf/Data.php +++ b/application/Espo/Tools/Pdf/Data.php @@ -71,7 +71,7 @@ class Data return $obj; } - public static function fromNothing(): self + public static function create(): self { return new self(); } diff --git a/tests/integration/Espo/Actions/ActionTest.php b/tests/integration/Espo/Actions/ActionTest.php index 83d38e916f..41f66c2a89 100644 --- a/tests/integration/Espo/Actions/ActionTest.php +++ b/tests/integration/Espo/Actions/ActionTest.php @@ -139,14 +139,14 @@ class ActionTest extends \tests\integration\Core\BaseTestCase $contact1 = $this->entityManager->getEntity('Contact'); $emailAddressGroup1 = $contact1->getEmailAddressGroup() - ->withAdded(EmailAddress::fromAddress('c1a@test.com')) - ->withAdded(EmailAddress::fromAddress('c1b@test.com')->invalid()); + ->withAdded(EmailAddress::create('c1a@test.com')) + ->withAdded(EmailAddress::create('c1b@test.com')->invalid()); $contact1->setEmailAddressGroup($emailAddressGroup1); $phoneNumberGroup1 = $contact1->getPhoneNumberGroup() - ->withAdded(PhoneNumber::fromNumber('+1a')) - ->withAdded(PhoneNumber::fromNumber('+1b')->invalid()); + ->withAdded(PhoneNumber::create('+1a')) + ->withAdded(PhoneNumber::create('+1b')->invalid()); $contact1->setPhoneNumberGroup($phoneNumberGroup1); @@ -158,14 +158,14 @@ class ActionTest extends \tests\integration\Core\BaseTestCase $contact2 = $this->entityManager->getEntity('Contact'); $emailAddressGroup2 = $contact1->getEmailAddressGroup() - ->withAdded(EmailAddress::fromAddress('c2a@test.com')) - ->withAdded(EmailAddress::fromAddress('c2b@test.com')->optedOut()); + ->withAdded(EmailAddress::create('c2a@test.com')) + ->withAdded(EmailAddress::create('c2b@test.com')->optedOut()); $contact2->setEmailAddressGroup($emailAddressGroup2); $phoneNumberGroup2 = $contact2->getPhoneNumberGroup() - ->withAdded(PhoneNumber::fromNumber('+2a')) - ->withAdded(PhoneNumber::fromNumber('+2b')->optedOut()); + ->withAdded(PhoneNumber::create('+2a')) + ->withAdded(PhoneNumber::create('+2b')->optedOut()); $contact2->setPhoneNumberGroup($phoneNumberGroup2); diff --git a/tests/integration/Espo/Core/FieldProcessing/EmailAddressTest.php b/tests/integration/Espo/Core/FieldProcessing/EmailAddressTest.php index bf50c2863f..c1803cb48a 100644 --- a/tests/integration/Espo/Core/FieldProcessing/EmailAddressTest.php +++ b/tests/integration/Espo/Core/FieldProcessing/EmailAddressTest.php @@ -56,13 +56,12 @@ class EmailAddressTest extends \tests\integration\Core\BaseTestCase $this->assertEquals('test@test.com', $group1->getPrimary()->getAddress()); - $group2 = EmailAddressGroup - ::fromNothing() + $group2 = EmailAddressGroup::create() ->withAdded( - EmailAddress::fromAddress('test-a@test.com')->invalid() + EmailAddress::create('test-a@test.com')->invalid() ) ->withAdded( - EmailAddress::fromAddress('test@test.com')->optedOut() + EmailAddress::create('test@test.com')->optedOut() ); $contact->setValueObject('emailAddress', $group2); @@ -82,10 +81,9 @@ class EmailAddressTest extends \tests\integration\Core\BaseTestCase $this->assertTrue($group3->getList()[1]->isOptedOut()); - $group4 = EmailAddressGroup - ::fromNothing() + $group4 = EmailAddressGroup::create() ->withAdded( - EmailAddress::fromAddress('test-a@test.com')->invalid() + EmailAddress::create('test-a@test.com')->invalid() ); $contact->setValueObject('emailAddress', $group4); diff --git a/tests/integration/Espo/Core/FieldProcessing/PhoneNumberTest.php b/tests/integration/Espo/Core/FieldProcessing/PhoneNumberTest.php index 5c22ee0872..ae4154abfa 100644 --- a/tests/integration/Espo/Core/FieldProcessing/PhoneNumberTest.php +++ b/tests/integration/Espo/Core/FieldProcessing/PhoneNumberTest.php @@ -57,12 +57,12 @@ class PhoneNumberTest extends \tests\integration\Core\BaseTestCase $this->assertEquals('+1', $group1->getPrimary()->getNumber()); $group2 = PhoneNumberGroup - ::fromNothing() + ::create() ->withAdded( - PhoneNumber::fromNumber('+2')->invalid() + PhoneNumber::create('+2')->invalid() ) ->withAdded( - PhoneNumber::fromNumber('+1')->optedOut() + PhoneNumber::create('+1')->optedOut() ); $contact->setValueObject('phoneNumber', $group2); @@ -83,9 +83,9 @@ class PhoneNumberTest extends \tests\integration\Core\BaseTestCase $this->assertTrue($group3->getList()[1]->isOptedOut()); $group4 = PhoneNumberGroup - ::fromNothing() + ::create() ->withAdded( - PhoneNumber::fromNumber('+2')->invalid() + PhoneNumber::create('+2')->invalid() ); $contact->setValueObject('phoneNumber', $group4); diff --git a/tests/integration/Espo/Core/Fields/ValueObjectTest.php b/tests/integration/Espo/Core/Fields/ValueObjectTest.php index 4ed92d3716..285d0ae053 100644 --- a/tests/integration/Espo/Core/Fields/ValueObjectTest.php +++ b/tests/integration/Espo/Core/Fields/ValueObjectTest.php @@ -54,7 +54,7 @@ class ValueObjectTest extends \tests\integration\Core\BaseTestCase $entity = $entityManager->getEntity('Account'); $address = Address - ::fromNothing() + ::create() ->withCity('Test') ->withCountry('United States'); @@ -212,10 +212,10 @@ class ValueObjectTest extends \tests\integration\Core\BaseTestCase $entity = $entityManager->getEntity('Account'); - $group = EmailAddressGroup::fromList([ - EmailAddress::fromAddress('one@test.com'), - EmailAddress::fromAddress('two@test.com')->optedOut(), - EmailAddress::fromAddress('three@test.com')->invalid(), + $group = EmailAddressGroup::create([ + EmailAddress::create('one@test.com'), + EmailAddress::create('two@test.com')->optedOut(), + EmailAddress::create('three@test.com')->invalid(), ]); $entity->setEmailAddressGroup($group); @@ -239,10 +239,10 @@ class ValueObjectTest extends \tests\integration\Core\BaseTestCase $entity = $entityManager->getEntity('Account'); - $group = PhoneNumberGroup::fromList([ - PhoneNumber::fromNumber('1')->withType('Office'), - PhoneNumber::fromNumber('2')->optedOut(), - PhoneNumber::fromNumber('3')->invalid(), + $group = PhoneNumberGroup::create([ + PhoneNumber::create('1')->withType('Office'), + PhoneNumber::create('2')->optedOut(), + PhoneNumber::create('3')->invalid(), ]); $entity->setPhoneNumberGroup($group); @@ -267,7 +267,7 @@ class ValueObjectTest extends \tests\integration\Core\BaseTestCase $entity = $entityManager->getEntity('Account'); - $entity->setValueObject('assignedUser', Link::fromId('1')); + $entity->setValueObject('assignedUser', Link::create('1')); $link = $entity->getValueObject('assignedUser'); @@ -284,7 +284,7 @@ class ValueObjectTest extends \tests\integration\Core\BaseTestCase $entity = $entityManager->getEntity('Task'); - $entity->setValueObject('parent', LinkParent::fromEntityTypeAndId('Account', 'test-id')); + $entity->setValueObject('parent', LinkParent::create('Account', 'test-id')); $link = $entity->getValueObject('parent'); @@ -305,9 +305,9 @@ class ValueObjectTest extends \tests\integration\Core\BaseTestCase $entity = $entityManager->getEntity('Opportunity'); - $link = LinkMultiple::fromList([ - LinkMultipleItem::fromId($c1->id)->withColumnValue('role', 'Decision Maker'), - LinkMultipleItem::fromId($c2->id), + $link = LinkMultiple::create([ + LinkMultipleItem::create($c1->id)->withColumnValue('role', 'Decision Maker'), + LinkMultipleItem::create($c2->id), ]); $entity->setValueObject('contacts', $link); @@ -336,9 +336,9 @@ class ValueObjectTest extends \tests\integration\Core\BaseTestCase $entity = $entityManager->getEntity('Opportunity'); - $link = LinkMultiple::fromList([ - LinkMultipleItem::fromId($c1->id)->withColumnValue('role', 'Decision Maker'), - LinkMultipleItem::fromId($c2->id), + $link = LinkMultiple::create([ + LinkMultipleItem::create($c1->id)->withColumnValue('role', 'Decision Maker'), + LinkMultipleItem::create($c2->id), ]); $entity->setValueObject('contacts', $link); diff --git a/tests/integration/Espo/Export/ExportTest.php b/tests/integration/Espo/Export/ExportTest.php index 1067e2b55a..90bcd952ad 100644 --- a/tests/integration/Espo/Export/ExportTest.php +++ b/tests/integration/Espo/Export/ExportTest.php @@ -98,7 +98,7 @@ class ExportTest extends \tests\integration\Core\BaseTestCase ]); $searchParams = SearchParams - ::fromNothing() + ::create() ->withWhere(WhereItem::fromRaw([ 'type' => 'equals', 'attribute' => 'assignedUserId', @@ -106,7 +106,7 @@ class ExportTest extends \tests\integration\Core\BaseTestCase ])); $params = Params - ::fromEntityType('Task') + ::create('Task') ->withFieldList([ 'name', 'assignedUser', @@ -154,7 +154,7 @@ class ExportTest extends \tests\integration\Core\BaseTestCase ]); $params = Params - ::fromEntityType('Task') + ::create('Task') ->withAttributeList([ 'id', 'name', @@ -216,7 +216,7 @@ class ExportTest extends \tests\integration\Core\BaseTestCase ->find(); $params = Params - ::fromEntityType('Task') + ::create('Task') ->withAttributeList([ 'name', 'assignedUserId', diff --git a/tests/integration/Espo/Portal/AclTest.php b/tests/integration/Espo/Portal/AclTest.php index 1d8c26b87c..6aa3179761 100644 --- a/tests/integration/Espo/Portal/AclTest.php +++ b/tests/integration/Espo/Portal/AclTest.php @@ -89,7 +89,7 @@ class AclTest extends \tests\integration\Core\BaseTestCase $service = $app->getContainer()->get('recordServiceContainer')->get('Case'); - $result = $service->find(SearchParams::fromNothing()); + $result = $service->find(SearchParams::create()); $idList = []; foreach ($result->getCollection() as $e) { @@ -160,7 +160,7 @@ class AclTest extends \tests\integration\Core\BaseTestCase $this->assertTrue($acl->check($case4, 'read')); $service = $app->getContainer()->get('recordServiceContainer')->get('Case'); - $result = $service->find(SearchParams::fromNothing()); + $result = $service->find(SearchParams::create()); $idList = []; foreach ($result->getCollection() as $e) { @@ -238,7 +238,7 @@ class AclTest extends \tests\integration\Core\BaseTestCase $service = $app->getContainer()->get('recordServiceContainer')->get('Case'); - $result = $service->find(SearchParams::fromNothing()); + $result = $service->find(SearchParams::create()); $idList = []; diff --git a/tests/integration/Espo/User/AclTest.php b/tests/integration/Espo/User/AclTest.php index d17e1a3c72..9c03b628d9 100644 --- a/tests/integration/Espo/User/AclTest.php +++ b/tests/integration/Espo/User/AclTest.php @@ -569,7 +569,7 @@ class AclTest extends \tests\integration\Core\BaseTestCase $this->expectException(Forbidden::class); $searchParams = SearchParams - ::fromNothing() + ::create() ->withWhere(WhereItem::fromRaw( [ 'type' => 'isNull', diff --git a/tests/unit/Espo/Core/FieldProcessing/LoaderParamsTest.php b/tests/unit/Espo/Core/FieldProcessing/LoaderParamsTest.php index b60ae6cc3b..9dcb0d2706 100644 --- a/tests/unit/Espo/Core/FieldProcessing/LoaderParamsTest.php +++ b/tests/unit/Espo/Core/FieldProcessing/LoaderParamsTest.php @@ -43,7 +43,7 @@ class LoaderParamsTest extends \PHPUnit\Framework\TestCase ]; $params = LoaderParams - ::fromNothing() + ::create() ->withSelect($select); $this->assertEquals(true, $params->hasInSelect('id')); @@ -55,7 +55,7 @@ class LoaderParamsTest extends \PHPUnit\Framework\TestCase public function testTwo(): void { $params = LoaderParams - ::fromNothing(); + ::create(); $this->assertEquals(false, $params->hasSelect()); diff --git a/tests/unit/Espo/Core/FieldProcessing/SaverParamsTest.php b/tests/unit/Espo/Core/FieldProcessing/SaverParamsTest.php index 084452bf3c..ad90dfdb06 100644 --- a/tests/unit/Espo/Core/FieldProcessing/SaverParamsTest.php +++ b/tests/unit/Espo/Core/FieldProcessing/SaverParamsTest.php @@ -42,7 +42,7 @@ class SaverParamsTest extends \PHPUnit\Framework\TestCase ]; $params = SaverParams - ::fromNothing() + ::create() ->withRawOptions($options); $this->assertEquals(true, $params->getOption('silent')); diff --git a/tests/unit/Espo/Core/Fields/Address/AddressTest.php b/tests/unit/Espo/Core/Fields/Address/AddressTest.php index b53abe0939..1837100bf2 100644 --- a/tests/unit/Espo/Core/Fields/Address/AddressTest.php +++ b/tests/unit/Espo/Core/Fields/Address/AddressTest.php @@ -125,7 +125,7 @@ class AddressTest extends \PHPUnit\Framework\TestCase public function testCreateFromNothing() { - $address = Address::fromNothing(); + $address = Address::create(); $this->assertEquals(null, $address->getState()); } diff --git a/tests/unit/Espo/Core/Fields/Currency/CurrencyTest.php b/tests/unit/Espo/Core/Fields/Currency/CurrencyTest.php index 8041746e28..ed717568c1 100644 --- a/tests/unit/Espo/Core/Fields/Currency/CurrencyTest.php +++ b/tests/unit/Espo/Core/Fields/Currency/CurrencyTest.php @@ -48,7 +48,7 @@ class CurrencyTest extends \PHPUnit\Framework\TestCase public function testValue() { - $value = Currency::fromAmountAndCode(2.0, 'USD'); + $value = Currency::create(2.0, 'USD'); $this->assertEquals(2.0, $value->getAmount()); diff --git a/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressGroupAttributeExtractorTest.php b/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressGroupAttributeExtractorTest.php index 6c82dcef22..ef65a1927e 100644 --- a/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressGroupAttributeExtractorTest.php +++ b/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressGroupAttributeExtractorTest.php @@ -40,9 +40,9 @@ class EmailAddressGroupAttributeExtractorTest extends \PHPUnit\Framework\TestCas public function testExtract() { $group = EmailAddressGroup - ::fromList([ - EmailAddress::fromAddress('ONE@test.com'), - EmailAddress::fromAddress('two@test.com')->optedOut(), + ::create([ + EmailAddress::create('ONE@test.com'), + EmailAddress::create('two@test.com')->optedOut(), ]); $valueMap = (new EmailAddressGroupAttributeExtractor())->extract($group, 'emailAddress'); @@ -74,7 +74,7 @@ class EmailAddressGroupAttributeExtractorTest extends \PHPUnit\Framework\TestCas public function testEmpty() { $group = EmailAddressGroup - ::fromList([]); + ::create([]); $valueMap = (new EmailAddressGroupAttributeExtractor())->extract($group, 'emailAddress'); diff --git a/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressGroupTest.php b/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressGroupTest.php index f41dfe1bf8..0446ced1d8 100644 --- a/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressGroupTest.php +++ b/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressGroupTest.php @@ -40,7 +40,7 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase { public function testEmpty() { - $group = EmailAddressGroup::fromNothing(); + $group = EmailAddressGroup::create(); $this->assertEquals(0, count($group->getAddressList())); $this->assertEquals(0, count($group->getSecondaryList())); @@ -55,9 +55,9 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase $this->expectException(RuntimeException::class); EmailAddressGroup - ::fromList([ - EmailAddress::fromAddress('one@test.com'), - EmailAddress::fromAddress('one@test.com'), + ::create([ + EmailAddress::create('one@test.com'), + EmailAddress::create('one@test.com'), ]); } @@ -66,18 +66,18 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase $this->expectException(RuntimeException::class); EmailAddressGroup - ::fromList([ - EmailAddress::fromAddress('one@test.com'), - EmailAddress::fromAddress('ONE@test.com'), + ::create([ + EmailAddress::create('one@test.com'), + EmailAddress::create('ONE@test.com'), ]); } public function testWithPrimary1() { - $primary = EmailAddress::fromAddress('primary@test.com')->invalid(); + $primary = EmailAddress::create('primary@test.com')->invalid(); $group = EmailAddressGroup - ::fromNothing() + ::create() ->withPrimary($primary); $this->assertEquals(1, count($group->getList())); @@ -87,7 +87,7 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase $this->assertEquals('primary@test.com', $group->getPrimary()->getAddress()); - $primaryAnother = EmailAddress::fromAddress('primaryAnother@test.com'); + $primaryAnother = EmailAddress::create('primaryAnother@test.com'); $groupAnother = $group->withPrimary($primaryAnother); @@ -106,15 +106,15 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase public function testWithPrimary2() { - $address = EmailAddress::fromAddress('one@test.com')->invalid(); + $address = EmailAddress::create('one@test.com')->invalid(); $group = EmailAddressGroup - ::fromList([$address]) + ::create([$address]) ->withAdded( - EmailAddress::fromAddress('two@test.com') + EmailAddress::create('two@test.com') ) ->withPrimary( - EmailAddress::fromAddress('two@test.com') + EmailAddress::create('two@test.com') ); $this->assertEquals('two@test.com', $group->getPrimary()->getAddress()); @@ -124,12 +124,12 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase public function testWithAdded1() { - $address = EmailAddress::fromAddress('one@test.com')->invalid(); + $address = EmailAddress::create('one@test.com')->invalid(); $group = EmailAddressGroup - ::fromList([$address]) + ::create([$address]) ->withAdded( - EmailAddress::fromAddress('two@test.com') + EmailAddress::create('two@test.com') ); $this->assertEquals('one@test.com', $group->getPrimary()->getAddress()); @@ -142,10 +142,10 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase public function testWithAddedList() { $group = EmailAddressGroup - ::fromNothing() + ::create() ->withAddedList([ - EmailAddress::fromAddress('one@test.com'), - EmailAddress::fromAddress('two@test.com'), + EmailAddress::create('one@test.com'), + EmailAddress::create('two@test.com'), ]); $this->assertEquals('one@test.com', $group->getPrimary()->getAddress()); @@ -156,12 +156,12 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase public function testWithRemoved1() { $group = EmailAddressGroup - ::fromList([ - EmailAddress::fromAddress('one@test.com'), - EmailAddress::fromAddress('two@test.com'), - EmailAddress::fromAddress('three@test.com'), + ::create([ + EmailAddress::create('one@test.com'), + EmailAddress::create('two@test.com'), + EmailAddress::create('three@test.com'), ]) - ->withRemoved(EmailAddress::fromAddress('two@test.com')); + ->withRemoved(EmailAddress::create('two@test.com')); $this->assertEquals('one@test.com', $group->getPrimary()->getAddress()); @@ -171,12 +171,12 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase public function testWithRemoved2() { $group = EmailAddressGroup - ::fromList([ - EmailAddress::fromAddress('one@test.com'), - EmailAddress::fromAddress('two@test.com'), - EmailAddress::fromAddress('three@test.com'), + ::create([ + EmailAddress::create('one@test.com'), + EmailAddress::create('two@test.com'), + EmailAddress::create('three@test.com'), ]) - ->withRemoved(EmailAddress::fromAddress('one@test.com')); + ->withRemoved(EmailAddress::create('one@test.com')); $this->assertEquals('two@test.com', $group->getPrimary()->getAddress()); @@ -186,10 +186,10 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase public function testWithRemoved3() { $group = EmailAddressGroup - ::fromList([ - EmailAddress::fromAddress('one@test.com'), + ::create([ + EmailAddress::create('one@test.com'), ]) - ->withRemoved(EmailAddress::fromAddress('one@test.com')); + ->withRemoved(EmailAddress::create('one@test.com')); $this->assertNull($group->getPrimary()); @@ -201,9 +201,9 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase public function testHasAddress() { $group = EmailAddressGroup - ::fromList([ - EmailAddress::fromAddress('one@test.com'), - EmailAddress::fromAddress('two@test.com'), + ::create([ + EmailAddress::create('one@test.com'), + EmailAddress::create('two@test.com'), ]); $this->assertTrue($group->hasAddress('one@test.com')); @@ -215,10 +215,10 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase public function testGetByAddress() { $group = EmailAddressGroup - ::fromList([ - EmailAddress::fromAddress('one@test.com'), - EmailAddress::fromAddress('two@test.com'), - EmailAddress::fromAddress('three@test.com'), + ::create([ + EmailAddress::create('one@test.com'), + EmailAddress::create('two@test.com'), + EmailAddress::create('three@test.com'), ]); $this->assertEquals('one@test.com', $group->getByAddress('one@test.com')->getAddress()); @@ -229,10 +229,10 @@ class EmailAddressGroupTest extends \PHPUnit\Framework\TestCase public function testClone() { $group = EmailAddressGroup - ::fromList([ - EmailAddress::fromAddress('one@test.com'), - EmailAddress::fromAddress('two@test.com'), - EmailAddress::fromAddress('three@test.com'), + ::create([ + EmailAddress::create('one@test.com'), + EmailAddress::create('two@test.com'), + EmailAddress::create('three@test.com'), ]); $cloned = clone $group; diff --git a/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressTest.php b/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressTest.php index d84f9ba483..912fe7ec32 100644 --- a/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressTest.php +++ b/tests/unit/Espo/Core/Fields/EmailAddress/EmailAddressTest.php @@ -41,19 +41,19 @@ class EmailAddressTest extends \PHPUnit\Framework\TestCase { $this->expectException(RuntimeException::class); - EmailAddress::fromAddress('one'); + EmailAddress::create('one'); } public function testInvalidEmpty() { $this->expectException(RuntimeException::class); - EmailAddress::fromAddress(''); + EmailAddress::create(''); } public function testCloneInvalid() { - $address = EmailAddress::fromAddress('test@test.com')->invalid(); + $address = EmailAddress::create('test@test.com')->invalid(); $this->assertEquals('test@test.com', $address->getAddress()); @@ -63,7 +63,7 @@ class EmailAddressTest extends \PHPUnit\Framework\TestCase public function testCloneOptedOut() { - $address = EmailAddress::fromAddress('test@test.com')->optedOut(); + $address = EmailAddress::create('test@test.com')->optedOut(); $this->assertFalse($address->isInvalid()); $this->assertTrue($address->isOptedOut()); @@ -71,7 +71,7 @@ class EmailAddressTest extends \PHPUnit\Framework\TestCase public function testCloneNotOptedOut() { - $address = EmailAddress::fromAddress('test@test.com') + $address = EmailAddress::create('test@test.com') ->optedOut() ->notOptedOut() ->invalid() diff --git a/tests/unit/Espo/Core/Fields/Link/LinkTest.php b/tests/unit/Espo/Core/Fields/Link/LinkTest.php index 23528184b1..f7e7a09075 100644 --- a/tests/unit/Espo/Core/Fields/Link/LinkTest.php +++ b/tests/unit/Espo/Core/Fields/Link/LinkTest.php @@ -39,7 +39,7 @@ class LinkTest extends \PHPUnit\Framework\TestCase { public function testCreate() { - $value = Link::fromId('id'); + $value = Link::create('id'); $this->assertEquals('id', $value->getId()); $this->assertEquals(null, $value->getName()); @@ -49,12 +49,12 @@ class LinkTest extends \PHPUnit\Framework\TestCase { $this->expectException(RuntimeException::class); - Link::fromId(''); + Link::create(''); } public function testWithName() { - $value = Link::fromId('id')->withName('Name'); + $value = Link::create('id')->withName('Name'); $this->assertEquals('Name', $value->getName()); } diff --git a/tests/unit/Espo/Core/Fields/LinkMultiple/LinkMultipleTest.php b/tests/unit/Espo/Core/Fields/LinkMultiple/LinkMultipleTest.php index e50a3f6bc2..5ab2a2d4e0 100644 --- a/tests/unit/Espo/Core/Fields/LinkMultiple/LinkMultipleTest.php +++ b/tests/unit/Espo/Core/Fields/LinkMultiple/LinkMultipleTest.php @@ -40,7 +40,7 @@ class LinkMultipleTest extends \PHPUnit\Framework\TestCase { public function testEmpty() { - $value = LinkMultiple::fromNothing(); + $value = LinkMultiple::create(); $this->assertEquals(0, count($value->getIdList())); $this->assertEquals(0, count($value->getList())); @@ -52,20 +52,20 @@ class LinkMultipleTest extends \PHPUnit\Framework\TestCase $this->expectException(RuntimeException::class); LinkMultiple - ::fromList([ - LinkMultipleItem::fromId('1'), - LinkMultipleItem::fromId('1'), + ::create([ + LinkMultipleItem::create('1'), + LinkMultipleItem::create('1'), ]); } public function testWithAdded1() { - $item = LinkMultipleItem::fromId('1')->withName('test-1'); + $item = LinkMultipleItem::create('1')->withName('test-1'); $group = LinkMultiple - ::fromList([$item]) + ::create([$item]) ->withAdded( - LinkMultipleItem::fromId('2') + LinkMultipleItem::create('2') ); $this->assertEquals(2, $group->getCount()); @@ -79,10 +79,10 @@ class LinkMultipleTest extends \PHPUnit\Framework\TestCase public function testWithAddedList() { $group = LinkMultiple - ::fromNothing() + ::create() ->withAddedList([ - LinkMultipleItem::fromId('1'), - LinkMultipleItem::fromId('2'), + LinkMultipleItem::create('1'), + LinkMultipleItem::create('2'), ]); $this->assertEquals(2, $group->getCount()); @@ -91,12 +91,12 @@ class LinkMultipleTest extends \PHPUnit\Framework\TestCase public function testWithRemoved1() { $group = LinkMultiple - ::fromList([ - LinkMultipleItem::fromId('1'), - LinkMultipleItem::fromId('2'), - LinkMultipleItem::fromId('3'), + ::create([ + LinkMultipleItem::create('1'), + LinkMultipleItem::create('2'), + LinkMultipleItem::create('3'), ]) - ->withRemoved(LinkMultipleItem::fromId('1')); + ->withRemoved(LinkMultipleItem::create('1')); $this->assertEquals(2, $group->getCount()); } @@ -104,10 +104,10 @@ class LinkMultipleTest extends \PHPUnit\Framework\TestCase public function testGetById() { $group = LinkMultiple - ::fromList([ - LinkMultipleItem::fromId('1'), - LinkMultipleItem::fromId('2'), - LinkMultipleItem::fromId('3'), + ::create([ + LinkMultipleItem::create('1'), + LinkMultipleItem::create('2'), + LinkMultipleItem::create('3'), ]); $this->assertEquals('1', $group->getById('1')->getId()); @@ -118,10 +118,10 @@ class LinkMultipleTest extends \PHPUnit\Framework\TestCase public function testClone() { $group = LinkMultiple - ::fromList([ - LinkMultipleItem::fromId('1'), - LinkMultipleItem::fromId('2'), - LinkMultipleItem::fromId('3'), + ::create([ + LinkMultipleItem::create('1'), + LinkMultipleItem::create('2'), + LinkMultipleItem::create('3'), ]); $cloned = clone $group; @@ -134,7 +134,7 @@ class LinkMultipleTest extends \PHPUnit\Framework\TestCase public function testItemColumn() { $item = LinkMultipleItem - ::fromId('1') + ::create('1') ->withColumnValue('key', 'value'); $this->assertTrue($item->hasColumnValue('key')); diff --git a/tests/unit/Espo/Core/Fields/LinkParent/LinkParentTest.php b/tests/unit/Espo/Core/Fields/LinkParent/LinkParentTest.php index 7a8855cdae..69231b9cb0 100644 --- a/tests/unit/Espo/Core/Fields/LinkParent/LinkParentTest.php +++ b/tests/unit/Espo/Core/Fields/LinkParent/LinkParentTest.php @@ -39,7 +39,7 @@ class LinkParentTest extends \PHPUnit\Framework\TestCase { public function testCreate() { - $value = LinkParent::fromEntityTypeAndId('Test', 'id'); + $value = LinkParent::create('Test', 'id'); $this->assertEquals('Test', $value->getEntityType()); $this->assertEquals('id', $value->getId()); @@ -50,19 +50,19 @@ class LinkParentTest extends \PHPUnit\Framework\TestCase { $this->expectException(RuntimeException::class); - LinkParent::fromEntityTypeAndId('Test', ''); + LinkParent::create('Test', ''); } public function testBad2() { $this->expectException(RuntimeException::class); - LinkParent::fromEntityTypeAndId('', 'id'); + LinkParent::create('', 'id'); } public function testWithName() { - $value = LinkParent::fromEntityTypeAndId('Test', 'id')->withName('Name'); + $value = LinkParent::create('Test', 'id')->withName('Name'); $this->assertEquals('Name', $value->getName()); } diff --git a/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupAttributeExtractorTest.php b/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupAttributeExtractorTest.php index 6aef574632..2210954dbb 100644 --- a/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupAttributeExtractorTest.php +++ b/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupAttributeExtractorTest.php @@ -40,9 +40,9 @@ class PhoneNumberGroupAttributeExtractorTest extends \PHPUnit\Framework\TestCase public function testExtract() { $group = PhoneNumberGroup - ::fromList([ - PhoneNumber::fromNumber('+1')->withType('Test-1'), - PhoneNumber::fromNumber('+2')->withType('Test-2')->optedOut(), + ::create([ + PhoneNumber::create('+1')->withType('Test-1'), + PhoneNumber::create('+2')->withType('Test-2')->optedOut(), ]); $valueMap = (new PhoneNumberGroupAttributeExtractor())->extract($group, 'phoneNumber'); @@ -74,7 +74,7 @@ class PhoneNumberGroupAttributeExtractorTest extends \PHPUnit\Framework\TestCase public function testEmpty() { $group = PhoneNumberGroup - ::fromList([]); + ::create([]); $valueMap = (new PhoneNumberGroupAttributeExtractor())->extract($group, 'phoneNumber'); diff --git a/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupTest.php b/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupTest.php index d76d0f2243..eff635771d 100644 --- a/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupTest.php +++ b/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberGroupTest.php @@ -40,7 +40,7 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase { public function testEmpty() { - $group = PhoneNumberGroup::fromNothing(); + $group = PhoneNumberGroup::create(); $this->assertEquals(0, count($group->getNumberList())); $this->assertEquals(0, count($group->getSecondaryList())); @@ -55,18 +55,18 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase $this->expectException(RuntimeException::class); PhoneNumberGroup - ::fromList([ - PhoneNumber::fromNumber('+100'), - PhoneNumber::fromNumber('+100'), + ::create([ + PhoneNumber::create('+100'), + PhoneNumber::create('+100'), ]); } public function testWithPrimary1() { - $primary = PhoneNumber::fromNumber('+000')->invalid(); + $primary = PhoneNumber::create('+000')->invalid(); $group = PhoneNumberGroup - ::fromNothing() + ::create() ->withPrimary($primary); $this->assertEquals(1, count($group->getList())); @@ -76,7 +76,7 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase $this->assertEquals('+000', $group->getPrimary()->getNumber()); - $primaryAnother = PhoneNumber::fromNumber('+001'); + $primaryAnother = PhoneNumber::create('+001'); $groupAnother = $group->withPrimary($primaryAnother); @@ -94,15 +94,15 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase public function testWithPrimary2() { - $number = PhoneNumber::fromNumber('+100')->invalid(); + $number = PhoneNumber::create('+100')->invalid(); $group = PhoneNumberGroup - ::fromList([$number]) + ::create([$number]) ->withAdded( - PhoneNumber::fromNumber('+200') + PhoneNumber::create('+200') ) ->withPrimary( - PhoneNumber::fromNumber('+200') + PhoneNumber::create('+200') ); $this->assertEquals('+200', $group->getPrimary()->getNumber()); @@ -112,12 +112,12 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase public function testWithAdded1() { - $number = PhoneNumber::fromNumber('+100')->invalid(); + $number = PhoneNumber::create('+100')->invalid(); $group = PhoneNumberGroup - ::fromList([$number]) + ::create([$number]) ->withAdded( - PhoneNumber::fromNumber('+200') + PhoneNumber::create('+200') ); $this->assertEquals('+100', $group->getPrimary()->getNumber()); @@ -130,10 +130,10 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase public function testWithAddedList() { $group = PhoneNumberGroup - ::fromNothing() + ::create() ->withAddedList([ - PhoneNumber::fromNumber('+100'), - PhoneNumber::fromNumber('+200'), + PhoneNumber::create('+100'), + PhoneNumber::create('+200'), ]); $this->assertEquals('+100', $group->getPrimary()->getNumber()); @@ -144,12 +144,12 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase public function testWithRemoved1() { $group = PhoneNumberGroup - ::fromList([ - PhoneNumber::fromNumber('+100'), - PhoneNumber::fromNumber('+200'), - PhoneNumber::fromNumber('+300'), + ::create([ + PhoneNumber::create('+100'), + PhoneNumber::create('+200'), + PhoneNumber::create('+300'), ]) - ->withRemoved(PhoneNumber::fromNumber('+200')); + ->withRemoved(PhoneNumber::create('+200')); $this->assertEquals('+100', $group->getPrimary()->getNumber()); @@ -159,12 +159,12 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase public function testWithRemoved2() { $group = PhoneNumberGroup - ::fromList([ - PhoneNumber::fromNumber('+100'), - PhoneNumber::fromNumber('+200'), - PhoneNumber::fromNumber('+300'), + ::create([ + PhoneNumber::create('+100'), + PhoneNumber::create('+200'), + PhoneNumber::create('+300'), ]) - ->withRemoved(PhoneNumber::fromNumber('+100')); + ->withRemoved(PhoneNumber::create('+100')); $this->assertEquals('+200', $group->getPrimary()->getNumber()); @@ -174,10 +174,10 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase public function testWithRemoved3() { $group = PhoneNumberGroup - ::fromList([ - PhoneNumber::fromNumber('+100'), + ::create([ + PhoneNumber::create('+100'), ]) - ->withRemoved(PhoneNumber::fromNumber('+100')); + ->withRemoved(PhoneNumber::create('+100')); $this->assertNull($group->getPrimary()); @@ -189,9 +189,9 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase public function testHasNumber() { $group = PhoneNumberGroup - ::fromList([ - PhoneNumber::fromNumber('+100'), - PhoneNumber::fromNumber('+200'), + ::create([ + PhoneNumber::create('+100'), + PhoneNumber::create('+200'), ]); $this->assertTrue($group->hasNumber('+100')); @@ -203,10 +203,10 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase public function testGetByNumber() { $group = PhoneNumberGroup - ::fromList([ - PhoneNumber::fromNumber('+100'), - PhoneNumber::fromNumber('+200'), - PhoneNumber::fromNumber('+300'), + ::create([ + PhoneNumber::create('+100'), + PhoneNumber::create('+200'), + PhoneNumber::create('+300'), ]); $this->assertEquals('+100', $group->getByNumber('+100')->getNumber()); @@ -217,10 +217,10 @@ class PhoneNumberGroupTest extends \PHPUnit\Framework\TestCase public function testClone() { $group = PhoneNumberGroup - ::fromList([ - PhoneNumber::fromNumber('+100'), - PhoneNumber::fromNumber('+200'), - PhoneNumber::fromNumber('+300'), + ::create([ + PhoneNumber::create('+100'), + PhoneNumber::create('+200'), + PhoneNumber::create('+300'), ]); $cloned = clone $group; diff --git a/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberTest.php b/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberTest.php index e1f4587a37..ef98ba8abc 100644 --- a/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberTest.php +++ b/tests/unit/Espo/Core/Fields/PhoneNumber/PhoneNumberTest.php @@ -41,12 +41,12 @@ class PhoneNumberTest extends \PHPUnit\Framework\TestCase { $this->expectException(RuntimeException::class); - PhoneNumber::fromNumber(''); + PhoneNumber::create(''); } public function testCloneInvalid() { - $number = PhoneNumber::fromNumber('+100')->invalid(); + $number = PhoneNumber::create('+100')->invalid(); $this->assertEquals('+100', $number->getNumber()); @@ -58,7 +58,7 @@ class PhoneNumberTest extends \PHPUnit\Framework\TestCase public function testCloneOptedOut() { - $number = PhoneNumber::fromNumber('+100')->optedOut(); + $number = PhoneNumber::create('+100')->optedOut(); $this->assertFalse($number->isInvalid()); $this->assertTrue($number->isOptedOut()); @@ -66,7 +66,7 @@ class PhoneNumberTest extends \PHPUnit\Framework\TestCase public function testCloneWithType() { - $number = PhoneNumber::fromNumberAndType('+100', 'Office'); + $number = PhoneNumber::createWithType('+100', 'Office'); $this->assertEquals('+100', $number->getNumber()); $this->assertEquals('Office', $number->getType()); @@ -74,7 +74,7 @@ class PhoneNumberTest extends \PHPUnit\Framework\TestCase public function testCloneNotOptedOut() { - $number = PhoneNumber::fromNumber('+100') + $number = PhoneNumber::create('+100') ->optedOut() ->notOptedOut() ->invalid() diff --git a/tests/unit/Espo/Core/Job/QueueProcessorParamsTest.php b/tests/unit/Espo/Core/Job/QueueProcessorParamsTest.php index 17e040217e..281fbc3661 100644 --- a/tests/unit/Espo/Core/Job/QueueProcessorParamsTest.php +++ b/tests/unit/Espo/Core/Job/QueueProcessorParamsTest.php @@ -42,7 +42,7 @@ class QueueProcessorParamsTest extends \PHPUnit\Framework\TestCase public function testParams1() { $params = QueueProcessorParams - ::fromNothing() + ::create() ->withLimit(10); $this->assertFalse($params->useProcessPool()); @@ -56,7 +56,7 @@ class QueueProcessorParamsTest extends \PHPUnit\Framework\TestCase public function testParams2() { $params = QueueProcessorParams - ::fromNothing() + ::create() ->withLimit(10) ->withUseProcessPool(true) ->withNoLock(true) diff --git a/tests/unit/Espo/Core/MassAction/ParamsTest.php b/tests/unit/Espo/Core/MassAction/ParamsTest.php index abb3ce491e..fbc95f7405 100644 --- a/tests/unit/Espo/Core/MassAction/ParamsTest.php +++ b/tests/unit/Espo/Core/MassAction/ParamsTest.php @@ -60,7 +60,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase public function testFromIds() { - $params = Params::fromIds('Test', ['1']); + $params = Params::createWithIds('Test', ['1']); $this->assertEquals('Test', $params->getEntityType()); @@ -71,7 +71,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase { $searchParams = $this->createMock(SearchParams::class); - $params = Params::fromSearchParams('Test', $searchParams); + $params = Params::createWithSearchParams('Test', $searchParams); $this->assertEquals('Test', $params->getEntityType()); diff --git a/tests/unit/Espo/Core/Select/SearchParamsTest.php b/tests/unit/Espo/Core/Select/SearchParamsTest.php index 466924b8ae..39f04e1e26 100644 --- a/tests/unit/Espo/Core/Select/SearchParamsTest.php +++ b/tests/unit/Espo/Core/Select/SearchParamsTest.php @@ -304,7 +304,7 @@ class SearchParamsTest extends \PHPUnit\Framework\TestCase ]; $params = SearchParams - ::fromNothing() + ::create() ->withBoolFilterList(['a']) ->withMaxSize(10) ->withOffset(0) @@ -333,7 +333,7 @@ class SearchParamsTest extends \PHPUnit\Framework\TestCase public function testWithWhereAdded1(): void { $params = SearchParams - ::fromNothing() + ::create() ->withWhere( WhereItem::fromRaw([ 'type' => 'isTrue', @@ -374,7 +374,7 @@ class SearchParamsTest extends \PHPUnit\Framework\TestCase public function testWithWhereAdded2(): void { $params = SearchParams - ::fromNothing() + ::create() ->withWhereAdded( WhereItem::fromRaw([ 'type' => 'isTrue',