EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Entity null default suppress inspection
Yurii702efd539de6
diff --git a/application/Espo/Classes/FieldProcessing/LeadCapture/ExampleLoader.php b/application/Espo/Classes/FieldProcessing/LeadCapture/ExampleLoader.phpindex 3e3a57fc34..4141a9310c 100644--- a/application/Espo/Classes/FieldProcessing/LeadCapture/ExampleLoader.php+++ b/application/Espo/Classes/FieldProcessing/LeadCapture/ExampleLoader.php@@ -141,7 +141,6 @@ class ExampleLoader implements Loader$siteUrl = $this->getSiteUrl();if (!$entity->hasFormEnabled() || !$formId) {- /** @noinspection PhpRedundantOptionalArgumentInspection */$entity->set('formUrl', null);return;diff --git a/application/Espo/Classes/RecordHooks/EmailFilter/BeforeSave.php b/application/Espo/Classes/RecordHooks/EmailFilter/BeforeSave.phpindex baf6451114..c19df6657c 100644--- a/application/Espo/Classes/RecordHooks/EmailFilter/BeforeSave.php+++ b/application/Espo/Classes/RecordHooks/EmailFilter/BeforeSave.php@@ -115,12 +115,10 @@ class BeforeSave implements SaveHook}if ($entity->getAction() !== EmailFilter::ACTION_MOVE_TO_FOLDER) {- /** @noinspection PhpRedundantOptionalArgumentInspection */$entity->set('emailFolderId', null);}if ($entity->getAction() !== EmailFilter::ACTION_MOVE_TO_GROUP_FOLDER) {- /** @noinspection PhpRedundantOptionalArgumentInspection */$entity->set('groupEmailFolderId', null);}}diff --git a/application/Espo/Classes/RecordHooks/Webhook/BeforeSave.php b/application/Espo/Classes/RecordHooks/Webhook/BeforeSave.phpindex c36d22cdf1..4f85cc7356 100644--- a/application/Espo/Classes/RecordHooks/Webhook/BeforeSave.php+++ b/application/Espo/Classes/RecordHooks/Webhook/BeforeSave.php@@ -167,7 +167,6 @@ class BeforeSave implements SaveHookreturn;}- /** @noinspection PhpRedundantOptionalArgumentInspection */$entity->set('field', null);}diff --git a/application/Espo/Core/FieldProcessing/Link/NotJoinedLoader.php b/application/Espo/Core/FieldProcessing/Link/NotJoinedLoader.phpindex 587db9b52b..0905405e46 100644--- a/application/Espo/Core/FieldProcessing/Link/NotJoinedLoader.php+++ b/application/Espo/Core/FieldProcessing/Link/NotJoinedLoader.php@@ -87,7 +87,6 @@ class NotJoinedLoader implements LoaderInterface->findOne();if (!$foreignEntity) {- /** @noinspection PhpRedundantOptionalArgumentInspection */$entity->set($nameAttribute, null);return;diff --git a/application/Espo/Core/FieldProcessing/Relation/Saver.php b/application/Espo/Core/FieldProcessing/Relation/Saver.phpindex 5efa054164..2840951065 100644--- a/application/Espo/Core/FieldProcessing/Relation/Saver.php+++ b/application/Espo/Core/FieldProcessing/Relation/Saver.php@@ -190,7 +190,6 @@ class Saver implements SaverInterfacereturn;}- /** @noinspection PhpRedundantOptionalArgumentInspection */$anotherEntity->set($idAttribute, null);$this->entityManager->saveEntity($anotherEntity, [diff --git a/application/Espo/Core/ORM/Entity.php b/application/Espo/Core/ORM/Entity.phpindex f4939ff2a5..baa3280f33 100644--- a/application/Espo/Core/ORM/Entity.php+++ b/application/Espo/Core/ORM/Entity.php@@ -98,7 +98,6 @@ class Entity extends BaseEntity$toSetFetched = !$this->isNew() && !$this->isAttributeChanged($idAttribute);if (!$parentId || !$parentType) {- /** @noinspection PhpRedundantOptionalArgumentInspection */$this->set($nameAttribute, null);if ($toSetFetched) {diff --git a/application/Espo/Core/Repositories/Event.php b/application/Espo/Core/Repositories/Event.phpindex ee8ba153ff..ed8089eaf7 100644--- a/application/Espo/Core/Repositories/Event.php+++ b/application/Espo/Core/Repositories/Event.php@@ -85,7 +85,6 @@ class Event extends Database implements$entity->set(Meeting::FIELD_DATE_START, $dateStart);} else {- /** @noinspection PhpRedundantOptionalArgumentInspection */$entity->set(Meeting::FIELD_DATE_START_DATE, null);}}@@ -107,7 +106,6 @@ class Event extends Database implements$dateEnd = $dt->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT);$entity->set(Meeting::FIELD_DATE_END, $dateEnd);} else {- /** @noinspection PhpRedundantOptionalArgumentInspection */$entity->set(Meeting::FIELD_DATE_END_DATE, null);}}diff --git a/application/Espo/Entities/Integration.php b/application/Espo/Entities/Integration.phpindex cc7a760443..377f3e6b97 100644--- a/application/Espo/Entities/Integration.php+++ b/application/Espo/Entities/Integration.php@@ -30,6 +30,7 @@namespace Espo\Entities;use Espo\Core\ORM\Entity;+use Espo\ORM\Entity\EmptyValue;use Espo\ORM\Name\Attribute;use stdClass;@@ -86,7 +87,7 @@ class Integration extends Entityreturn $this->set($valueMap);}- public function set($attribute, $value = null): static+ public function set($attribute, $value = new EmptyValue()): static{if (is_object($attribute)) {$attribute = get_object_vars($attribute);@@ -98,6 +99,10 @@ class Integration extends Entityreturn $this;}+ if ($value instanceof EmptyValue) {+ $value = null;+ }+$name = $attribute;if ($name === Attribute::ID) {diff --git a/application/Espo/ORM/BaseEntity.php b/application/Espo/ORM/BaseEntity.phpindex 0f55457c12..8170ea38fc 100644--- a/application/Espo/ORM/BaseEntity.php+++ b/application/Espo/ORM/BaseEntity.php@@ -35,6 +35,7 @@ use Espo\ORM\DataLoader\Loader;use Espo\ORM\Defs\Params\AttributeParam;use Espo\ORM\Defs\Params\EntityParam;use Espo\ORM\Defs\Params\RelationParam;+use Espo\ORM\Entity\EmptyValue;use Espo\ORM\Name\Attribute;use Espo\ORM\Relation\EmptyRelations;use Espo\ORM\Relation\Relations;@@ -162,7 +163,7 @@ class BaseEntity implements Entity* @param string|stdClass|array<string, mixed> $attribute* @param mixed $value*/- public function set($attribute, $value = null): static+ public function set($attribute, $value = new EmptyValue()): static{$arg = $attribute;@@ -183,6 +184,10 @@ class BaseEntity implements Entityif (is_string($arg)) {$name = $arg;+ if ($value instanceof EmptyValue) {+ $value = null;+ }+if ($name == Attribute::ID) {$this->id = $value;}diff --git a/application/Espo/ORM/Entity.php b/application/Espo/ORM/Entity.phpindex 0356fa143b..31650bf20d 100644--- a/application/Espo/ORM/Entity.php+++ b/application/Espo/ORM/Entity.php@@ -89,7 +89,7 @@ interface Entity* @param string|stdClass|array<string, mixed> $attribute* @param mixed $value*/- public function set($attribute, $value = null): static;+ public function set($attribute, $value): static;/*** Set multiple attributes.diff --git a/application/Espo/ORM/Entity/EmptyValue.php b/application/Espo/ORM/Entity/EmptyValue.phpnew file mode 100644index 0000000000..2b4cd37be5--- /dev/null+++ b/application/Espo/ORM/Entity/EmptyValue.php@@ -0,0 +1,38 @@+<?php+/************************************************************************+ * This file is part of EspoCRM.+ *+ * EspoCRM – Open Source CRM application.+ * Copyright (C) 2014-2026 EspoCRM, Inc.+ * Website: https://www.espocrm.com+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ * The interactive user interfaces in modified source and object code versions+ * of this program must display Appropriate Legal Notices, as required under+ * Section 5 of the GNU Affero General Public License version 3.+ *+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.+ ************************************************************************/++namespace Espo\ORM\Entity;++/**+ * @internal+ *+ * Prevents inspection firing on a null value.+ */+class EmptyValue+{}diff --git a/application/Espo/ORM/Mapper/BaseMapper.php b/application/Espo/ORM/Mapper/BaseMapper.phpindex b835861de1..501fa23e7a 100644--- a/application/Espo/ORM/Mapper/BaseMapper.php+++ b/application/Espo/ORM/Mapper/BaseMapper.php@@ -1172,7 +1172,6 @@ class BaseMapper implements RDBMapper$where[$typeKey] = $foreignEntityType;}- /** @noinspection PhpRedundantOptionalArgumentInspection */$entity->set($typeKey, null);$entity->setFetched($typeKey, null);}diff --git a/application/Espo/Repositories/Email.php b/application/Espo/Repositories/Email.phpindex 224ac5cc4a..fc0d4019d1 100644--- a/application/Espo/Repositories/Email.php+++ b/application/Espo/Repositories/Email.php@@ -558,7 +558,6 @@ class Email extends Database implements$from = trim($entity->getFromAddress() ?? '');if (!$from) {- /** @noinspection PhpRedundantOptionalArgumentInspection */$entity->set(self::ATTR_FROM_EMAIL_ADDRESS_ID, null);return;diff --git a/application/Espo/Tools/UserSecurity/Service.php b/application/Espo/Tools/UserSecurity/Service.phpindex c97be0a2c4..6346573dba 100644--- a/application/Espo/Tools/UserSecurity/Service.php+++ b/application/Espo/Tools/UserSecurity/Service.php@@ -172,7 +172,6 @@ class Service}$userData->set('auth2FA', false);- /** @noinspection PhpRedundantOptionalArgumentInspection */$userData->set('auth2FAMethod', null);$this->entityManager->saveEntity($userData);@@ -233,7 +232,6 @@ class Service}if (!$userData->get('auth2FA')) {- /** @noinspection PhpRedundantOptionalArgumentInspection */$userData->set('auth2FAMethod', null);}diff --git a/tests/unit/Espo/ORM/EntityTest.php b/tests/unit/Espo/ORM/EntityTest.phpindex 18d83bd0ba..8e5843ecd4 100644--- a/tests/unit/Espo/ORM/EntityTest.php+++ b/tests/unit/Espo/ORM/EntityTest.php@@ -99,7 +99,6 @@ class EntityTest extends TestCase$this->assertTrue($job->isAttributeChanged('string'));$job = $this->createEntity('Job', Job::class);- /** @noinspection PhpRedundantOptionalArgumentInspection */$job->set('string', null);$this->assertTrue($job->isAttributeChanged('string'));@@ -165,7 +164,6 @@ class EntityTest extends TestCase$this->assertTrue($job->isAttributeChanged('array'));$job = $this->createEntity('Job', Job::class);- /** @noinspection PhpRedundantOptionalArgumentInspection */$job->set('array', null);$this->assertTrue($job->isAttributeChanged('array'));@@ -190,7 +188,6 @@ class EntityTest extends TestCase$job = $this->createEntity('Job', Job::class);$job->setFetched('arrayUnordered', ['1', '2']);- /** @noinspection PhpRedundantOptionalArgumentInspection */$job->set('arrayUnordered', null);$this->assertTrue($job->isAttributeChanged('arrayUnordered'));