From 41b0dd4e78e1c18b590b48930f4f9365176aa3f2 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 26 Mar 2025 13:34:21 +0200 Subject: [PATCH] ref --- .../Core/EntryPoint/Traits/NotStrictAuth.php | 2 + application/Espo/Core/EntryPoints/NoAuth.php | 2 + .../Espo/Core/EntryPoints/NotStrictAuth.php | 2 + .../Clients/OAuth2Abstract.php | 2 +- .../Core/ExternalAccount/OAuth2/Client.php | 2 +- application/Espo/Core/FileStorage/Manager.php | 2 +- .../Espo/Core/FileStorage/Storages/AwsS3.php | 1 + .../Functions/JsonGroup/RetrieveType.php | 2 +- application/Espo/Core/Formula/Parser.php | 2 +- .../Core/Mail/Importer/DefaultImporter.php | 2 +- .../Espo/Core/Mail/Parsers/MailMimeParser.php | 1 - application/Espo/Core/Mail/Sender.php | 3 +- application/Espo/Core/ORM/Entity.php | 2 +- .../Espo/Core/Record/Access/LinkCheck.php | 2 +- .../Espo/Core/Record/SearchParamsFetcher.php | 2 +- .../Espo/Core/Repositories/Database.php | 6 --- .../Espo/Core/Select/Bool/FilterFactory.php | 4 +- .../Espo/Core/Select/Helpers/FieldHelper.php | 4 +- .../Espo/Core/Select/Order/Applier.php | 1 - .../Espo/Core/Select/SelectBuilder.php | 3 +- application/Espo/Core/Select/Text/Applier.php | 4 +- .../Espo/Core/Select/Where/Checker.php | 4 +- application/Espo/Core/Traits/Injectable.php | 6 ++- .../Espo/Core/Upgrades/Actions/Helper.php | 2 +- application/Espo/Core/Utils/DataUtil.php | 6 +-- .../Core/Utils/Database/Orm/Converter.php | 1 - .../Espo/Core/Utils/Database/Schema/Utils.php | 2 +- application/Espo/Core/Utils/File/Manager.php | 2 +- .../Espo/Core/Utils/File/Permission.php | 5 ++- application/Espo/Core/Utils/Log.php | 2 +- .../StreamUpdatedAtField.php | 2 +- application/Espo/Core/Utils/Util.php | 42 +++++++++++-------- application/Espo/EntryPoints/Image.php | 7 +++- .../Crm/EntryPoints/CampaignTrackOpened.php | 2 +- .../Modules/Crm/EntryPoints/CampaignUrl.php | 4 +- .../Modules/Crm/Jobs/SendEmailReminders.php | 4 +- .../Crm/Tools/Case/Distribution/LeastBusy.php | 15 +++---- .../Tools/Case/Distribution/RoundRobin.php | 13 ++---- .../Modules/Crm/Tools/Lead/ConvertService.php | 7 ++-- 39 files changed, 92 insertions(+), 85 deletions(-) diff --git a/application/Espo/Core/EntryPoint/Traits/NotStrictAuth.php b/application/Espo/Core/EntryPoint/Traits/NotStrictAuth.php index 4719069806..78d7d62eaf 100644 --- a/application/Espo/Core/EntryPoint/Traits/NotStrictAuth.php +++ b/application/Espo/Core/EntryPoint/Traits/NotStrictAuth.php @@ -31,6 +31,8 @@ namespace Espo\Core\EntryPoint\Traits; /** * @deprecated + * @todo Remove in v10.0. + * @phpstan-ignore-next-line */ trait NotStrictAuth { diff --git a/application/Espo/Core/EntryPoints/NoAuth.php b/application/Espo/Core/EntryPoints/NoAuth.php index 1c2b865146..b42414f07e 100644 --- a/application/Espo/Core/EntryPoints/NoAuth.php +++ b/application/Espo/Core/EntryPoints/NoAuth.php @@ -31,6 +31,8 @@ namespace Espo\Core\EntryPoints; /** * @deprecated Use `Espo\Core\EntryPoint\Traits\NoAuth` instead. + * @todo Remove in v10.0. + * @phpstan-ignore-next-line */ trait NoAuth { diff --git a/application/Espo/Core/EntryPoints/NotStrictAuth.php b/application/Espo/Core/EntryPoints/NotStrictAuth.php index c79872aa8b..1655dafdc7 100644 --- a/application/Espo/Core/EntryPoints/NotStrictAuth.php +++ b/application/Espo/Core/EntryPoints/NotStrictAuth.php @@ -31,6 +31,8 @@ namespace Espo\Core\EntryPoints; /** * @deprecated + * @todo Remove in v10.0. + * @phpstan-ignore-next-line */ trait NotStrictAuth { diff --git a/application/Espo/Core/ExternalAccount/Clients/OAuth2Abstract.php b/application/Espo/Core/ExternalAccount/Clients/OAuth2Abstract.php index 8f70be5858..3f1a4d0383 100644 --- a/application/Espo/Core/ExternalAccount/Clients/OAuth2Abstract.php +++ b/application/Espo/Core/ExternalAccount/Clients/OAuth2Abstract.php @@ -247,7 +247,7 @@ abstract class OAuth2Abstract implements IClient $data['refreshToken'] = $result['refresh_token'] ?? null; /** - * @var ?array{ + * @var array{ * accessToken: ?string, * tokenType: ?string, * expiresAt: ?string, diff --git a/application/Espo/Core/ExternalAccount/OAuth2/Client.php b/application/Espo/Core/ExternalAccount/OAuth2/Client.php index ffdefdc479..45dd680f6e 100644 --- a/application/Espo/Core/ExternalAccount/OAuth2/Client.php +++ b/application/Espo/Core/ExternalAccount/OAuth2/Client.php @@ -347,7 +347,7 @@ class Client curl_setopt_array($ch, $curlOptions); - curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); diff --git a/application/Espo/Core/FileStorage/Manager.php b/application/Espo/Core/FileStorage/Manager.php index 125ba77f5d..c1d25a85ef 100644 --- a/application/Espo/Core/FileStorage/Manager.php +++ b/application/Espo/Core/FileStorage/Manager.php @@ -49,8 +49,8 @@ class Manager /** * @var array - * @phpstan-ignore-next-line Used to prevent deleting from memory. * @noinspection PhpPropertyOnlyWrittenInspection + * @phpstan-ignore-next-line Used to prevent deleting from memory. */ private $resourceMap = []; diff --git a/application/Espo/Core/FileStorage/Storages/AwsS3.php b/application/Espo/Core/FileStorage/Storages/AwsS3.php index 41b9074b1d..6f53cceaed 100644 --- a/application/Espo/Core/FileStorage/Storages/AwsS3.php +++ b/application/Espo/Core/FileStorage/Storages/AwsS3.php @@ -63,6 +63,7 @@ class AwsS3 implements Storage throw new RuntimeException("AWS S3 bucket name is not specified in config."); } + /** @var array<\AsyncAws\Core\Configuration::OPTION_*, string|null> $clientOptions */ $clientOptions = [ 'region' => $region, ]; diff --git a/application/Espo/Core/Formula/Functions/JsonGroup/RetrieveType.php b/application/Espo/Core/Formula/Functions/JsonGroup/RetrieveType.php index 937e803de4..fc5f5d136b 100644 --- a/application/Espo/Core/Formula/Functions/JsonGroup/RetrieveType.php +++ b/application/Espo/Core/Formula/Functions/JsonGroup/RetrieveType.php @@ -80,7 +80,7 @@ class RetrieveType extends BaseFunction return []; } - /** @var string[] $pathArray */ + /** @var list $pathArray */ $pathArray = preg_split('/(? $item) { diff --git a/application/Espo/Core/Formula/Parser.php b/application/Espo/Core/Formula/Parser.php index 965ccfc845..8ac1bda4f2 100644 --- a/application/Espo/Core/Formula/Parser.php +++ b/application/Espo/Core/Formula/Parser.php @@ -845,7 +845,7 @@ class Parser return $this->split($expression, true); } - if (count($statementList)) { + if ($statementList !== null && count($statementList)) { return $this->processStatementList($expression, $statementList, $isRoot); } diff --git a/application/Espo/Core/Mail/Importer/DefaultImporter.php b/application/Espo/Core/Mail/Importer/DefaultImporter.php index 29aac7fe7d..1f53fa1f5f 100644 --- a/application/Espo/Core/Mail/Importer/DefaultImporter.php +++ b/application/Espo/Core/Mail/Importer/DefaultImporter.php @@ -409,7 +409,7 @@ class DefaultImporter implements Importer $subject = $parser->getHeader($message, 'subject'); } - if (!empty($subject) && is_string($subject)) { + if (!empty($subject)) { $subject = trim($subject); } diff --git a/application/Espo/Core/Mail/Parsers/MailMimeParser.php b/application/Espo/Core/Mail/Parsers/MailMimeParser.php index 191f64ef1a..248cf84ea8 100644 --- a/application/Espo/Core/Mail/Parsers/MailMimeParser.php +++ b/application/Espo/Core/Mail/Parsers/MailMimeParser.php @@ -313,7 +313,6 @@ class MailMimeParser implements Parser $content = ''; - /** @var StreamInterface|null $binaryContentStream */ $binaryContentStream = $attachmentPart->getBinaryContentStream(); if ($binaryContentStream) { diff --git a/application/Espo/Core/Mail/Sender.php b/application/Espo/Core/Mail/Sender.php index 708afd8cb2..93827bf874 100644 --- a/application/Espo/Core/Mail/Sender.php +++ b/application/Espo/Core/Mail/Sender.php @@ -564,8 +564,7 @@ class Sender $messageId = $email->getMessageId(); if ( - empty($messageId) || - !is_string($messageId) || + !$messageId || strlen($messageId) < 4 || str_starts_with($messageId, 'dummy:') ) { diff --git a/application/Espo/Core/ORM/Entity.php b/application/Espo/Core/ORM/Entity.php index 567eec148f..df8498db32 100644 --- a/application/Espo/Core/ORM/Entity.php +++ b/application/Espo/Core/ORM/Entity.php @@ -450,7 +450,7 @@ class Entity extends BaseEntity throw new LogicException("Non-object value in `$columnsAttribute`."); } - return $object->$id?->$column ?? null; + return $object->$id->$column ?? null; } /** diff --git a/application/Espo/Core/Record/Access/LinkCheck.php b/application/Espo/Core/Record/Access/LinkCheck.php index 35281c15b2..d567e8acfd 100644 --- a/application/Espo/Core/Record/Access/LinkCheck.php +++ b/application/Espo/Core/Record/Access/LinkCheck.php @@ -60,7 +60,7 @@ use stdClass; */ class LinkCheck { - /** @var array>> */ + /** @var array> */ private $linkCheckerCache = []; /** @var string[] */ diff --git a/application/Espo/Core/Record/SearchParamsFetcher.php b/application/Espo/Core/Record/SearchParamsFetcher.php index 67f3730bee..4f1157d1c0 100644 --- a/application/Espo/Core/Record/SearchParamsFetcher.php +++ b/application/Espo/Core/Record/SearchParamsFetcher.php @@ -144,7 +144,7 @@ class SearchParamsFetcher $q = $request->getQueryParam('q'); - if ($q && is_string($q)) { + if ($q) { $params['q'] = trim($q); } diff --git a/application/Espo/Core/Repositories/Database.php b/application/Espo/Core/Repositories/Database.php index caa0ab53e0..90b02f642b 100644 --- a/application/Espo/Core/Repositories/Database.php +++ b/application/Espo/Core/Repositories/Database.php @@ -240,9 +240,6 @@ class Database extends RDBRepository */ protected function afterRelate(Entity $entity, $relationName, $foreign, $data = null, array $options = []) { - /** @noinspection PhpDeprecationInspection */ - parent::afterRelate($entity, $relationName, $foreign, $data, $options); - if ($this->hooksDisabled || !empty($options[SaveOption::SKIP_HOOKS])) { return; } @@ -284,9 +281,6 @@ class Database extends RDBRepository */ protected function afterUnrelate(Entity $entity, $relationName, $foreign, array $options = []) { - /** @noinspection PhpDeprecationInspection */ - parent::afterUnrelate($entity, $relationName, $foreign, $options); - if ($this->hooksDisabled || !empty($options[SaveOption::SKIP_HOOKS])) { return; } diff --git a/application/Espo/Core/Select/Bool/FilterFactory.php b/application/Espo/Core/Select/Bool/FilterFactory.php index 56d1211e57..86f0fd2e83 100644 --- a/application/Espo/Core/Select/Bool/FilterFactory.php +++ b/application/Espo/Core/Select/Bool/FilterFactory.php @@ -111,7 +111,7 @@ class FilterFactory $className1 = $this->metadata->get(['app', 'select', 'boolFilterClassNameMap', $name]); if ($className1) { - /** @var ?class-string */ + /** @var class-string */ return $className1; } @@ -121,7 +121,7 @@ class FilterFactory return null; } - /** @var ?class-string */ + /** @var class-string */ return $className; } } diff --git a/application/Espo/Core/Select/Helpers/FieldHelper.php b/application/Espo/Core/Select/Helpers/FieldHelper.php index d6b60a2d92..a4ba2c358f 100644 --- a/application/Espo/Core/Select/Helpers/FieldHelper.php +++ b/application/Espo/Core/Select/Helpers/FieldHelper.php @@ -68,7 +68,9 @@ class FieldHelper private function getSeed(): Entity { - return $this->seed ?? $this->entityManager->getNewEntity($this->entityType); + $this->seed ??= $this->entityManager->getNewEntity($this->entityType); + + return $this->seed; } public function hasAssignedUsersField(): bool diff --git a/application/Espo/Core/Select/Order/Applier.php b/application/Espo/Core/Select/Order/Applier.php index f8844f1cd2..ca6e3bb535 100644 --- a/application/Espo/Core/Select/Order/Applier.php +++ b/application/Espo/Core/Select/Order/Applier.php @@ -71,7 +71,6 @@ class Applier if ($orderBy) { if ( - !is_string($orderBy) || str_contains($orderBy, '.') || str_contains($orderBy, ':') ) { diff --git a/application/Espo/Core/Select/SelectBuilder.php b/application/Espo/Core/Select/SelectBuilder.php index 527071d984..6c882ce243 100644 --- a/application/Espo/Core/Select/SelectBuilder.php +++ b/application/Espo/Core/Select/SelectBuilder.php @@ -169,8 +169,7 @@ class SelectBuilder $this->applyAdditional(); - /** @var QueryBuilder */ - return $this->queryBuilder; + return $this->queryBuilder ?? throw new LogicException(); } /** diff --git a/application/Espo/Core/Select/Text/Applier.php b/application/Espo/Core/Select/Text/Applier.php index f07c35bbe4..b04c4e0a78 100644 --- a/application/Espo/Core/Select/Text/Applier.php +++ b/application/Espo/Core/Select/Text/Applier.php @@ -42,9 +42,9 @@ use Espo\Entities\User; class Applier { /** @todo Move to metadata. */ - private ?int $fullTextRelevanceThreshold = null; + private ?int $fullTextRelevanceThreshold = null; /** @phpstan-ignore-line */ /** @todo Move to metadata. */ - private int $fullTextOrderRelevanceDivider = 5; + private int $fullTextOrderRelevanceDivider = 5; /** @phpstan-ignore-line */ private const DEFAULT_FT_ORDER = self::FT_ORDER_COMBINED; private const DEFAULT_ATTRIBUTE_LIST = ['name']; diff --git a/application/Espo/Core/Select/Where/Checker.php b/application/Espo/Core/Select/Where/Checker.php index 5c90d832c7..e69f88ee83 100644 --- a/application/Espo/Core/Select/Where/Checker.php +++ b/application/Espo/Core/Select/Where/Checker.php @@ -227,7 +227,9 @@ class Checker private function getSeed(): Entity { - return $this->seed ?? $this->entityManager->getNewEntity($this->entityType); + $this->seed ??= $this->entityManager->getNewEntity($this->entityType); + + return $this->seed; } private function getRelationParam(Entity $entity, string $relation, string $param): mixed diff --git a/application/Espo/Core/Traits/Injectable.php b/application/Espo/Core/Traits/Injectable.php index 2c544c5c03..0d7049de6e 100644 --- a/application/Espo/Core/Traits/Injectable.php +++ b/application/Espo/Core/Traits/Injectable.php @@ -29,7 +29,11 @@ namespace Espo\Core\Traits; -/** @deprecated */ +/** + * @deprecated + * @todo Remove in v10.0. + * @phpstan-ignore-next-line + */ trait Injectable { protected $injections = []; /** @phpstan-ignore-line */ diff --git a/application/Espo/Core/Upgrades/Actions/Helper.php b/application/Espo/Core/Upgrades/Actions/Helper.php index dadc496415..0a998e9681 100644 --- a/application/Espo/Core/Upgrades/Actions/Helper.php +++ b/application/Espo/Core/Upgrades/Actions/Helper.php @@ -36,7 +36,7 @@ use RuntimeException; class Helper { - private ?Base $actionObject; + private ?Base $actionObject = null; public function __construct(private EntityManager $entityManager) {} diff --git a/application/Espo/Core/Utils/DataUtil.php b/application/Espo/Core/Utils/DataUtil.php index a73192e6d2..7bfc1d2b47 100644 --- a/application/Espo/Core/Utils/DataUtil.php +++ b/application/Espo/Core/Utils/DataUtil.php @@ -36,9 +36,9 @@ use stdClass; class DataUtil { /** - * @param array $data + * @param array|stdClass $data * @param array|string $unsetList - * @return array + * @return array|stdClass */ public static function unsetByKey(&$data, $unsetList, bool $removeEmptyItems = false) { @@ -168,7 +168,7 @@ class DataUtil } /** @var array|stdClass */ - return $overrideData; + return $overrideData; /** @phpstan-ignore-line */ } if (is_object($overrideData)) { diff --git a/application/Espo/Core/Utils/Database/Orm/Converter.php b/application/Espo/Core/Utils/Database/Orm/Converter.php index 3b74644e2c..86d3c02b01 100644 --- a/application/Espo/Core/Utils/Database/Orm/Converter.php +++ b/application/Espo/Core/Utils/Database/Orm/Converter.php @@ -997,7 +997,6 @@ class Converter } } - /** @var array */ return $indexList; } diff --git a/application/Espo/Core/Utils/Database/Schema/Utils.php b/application/Espo/Core/Utils/Database/Schema/Utils.php index a65783cf4e..0469d5838a 100644 --- a/application/Espo/Core/Utils/Database/Schema/Utils.php +++ b/application/Espo/Core/Utils/Database/Schema/Utils.php @@ -98,7 +98,7 @@ class Utils } /** @var array> */ - return $indexList; + return $indexList; /** @phpstan-ignore-line */ } private static function getIndexTypeByIndexDefs(IndexDefs $indexDefs): string diff --git a/application/Espo/Core/Utils/File/Manager.php b/application/Espo/Core/Utils/File/Manager.php index b0a6db2db7..6d9aa49edb 100644 --- a/application/Espo/Core/Utils/File/Manager.php +++ b/application/Espo/Core/Utils/File/Manager.php @@ -926,7 +926,7 @@ class Manager if (is_dir($path)) { $fileList = $this->getFileList($path, true); - if (is_array($fileList) && empty($fileList)) { + if (empty($fileList)) { return true; } } diff --git a/application/Espo/Core/Utils/File/Permission.php b/application/Espo/Core/Utils/File/Permission.php index 0b19b338d8..0dad071f49 100644 --- a/application/Espo/Core/Utils/File/Permission.php +++ b/application/Espo/Core/Utils/File/Permission.php @@ -243,7 +243,10 @@ class Permission $count++; } - } else if (is_int((int) $octal)) { // Always true. @todo Fix. + } else if ( + /** @phpstan-ignore-next-line */ + is_int((int) $octal) // Always true. @todo Fix. + ) { $permission = [ 'file' => $octal, 'dir' => $octal, diff --git a/application/Espo/Core/Utils/Log.php b/application/Espo/Core/Utils/Log.php index 3988fcea6d..7e67ab6483 100644 --- a/application/Espo/Core/Utils/Log.php +++ b/application/Espo/Core/Utils/Log.php @@ -47,7 +47,7 @@ class Log implements LoggerInterface private Logger $logger; /** - * @param HandlerInterface[] $handlers + * @param list $handlers * @param callable[] $processors * @param ?DateTimeZone $timezone */ diff --git a/application/Espo/Core/Utils/Metadata/AdditionalBuilder/StreamUpdatedAtField.php b/application/Espo/Core/Utils/Metadata/AdditionalBuilder/StreamUpdatedAtField.php index de580610b0..407cfdce46 100644 --- a/application/Espo/Core/Utils/Metadata/AdditionalBuilder/StreamUpdatedAtField.php +++ b/application/Espo/Core/Utils/Metadata/AdditionalBuilder/StreamUpdatedAtField.php @@ -45,7 +45,7 @@ class StreamUpdatedAtField implements AdditionalBuilder $field = Field::STREAM_UPDATED_AT; foreach (get_object_vars($data->entityDefs) as $entityType => $entityDefsItem) { - $hasStream = $data->scopes?->$entityType?->stream ?? false; + $hasStream = $data->scopes?->$entityType->stream ?? false; if (!$hasStream) { continue; diff --git a/application/Espo/Core/Utils/Util.php b/application/Espo/Core/Utils/Util.php index 03b4522f47..8ec53c7a35 100644 --- a/application/Espo/Core/Utils/Util.php +++ b/application/Espo/Core/Utils/Util.php @@ -164,9 +164,10 @@ class Util /** * Merge arrays recursively. $newArray overrides $currentArray. * - * @param array $currentArray A source array. - * @param array $newArray A merge-array (priority is same as for array_merge()). - * @return array + * @template T of array + * @param T $currentArray A source array. + * @param T $newArray A merge-array (priority is same as for array_merge()). + * @return T */ public static function merge($currentArray, $newArray) { @@ -176,13 +177,16 @@ class Util $mergeIdentifier = '__APPEND__'; if (is_array($currentArray) && !is_array($newArray)) { + /** @var T */ return $currentArray; } else if (!is_array($currentArray) && is_array($newArray)) { - return $newArray; + /** @var T */ + return $newArray; /** @phpstan-ignore-line */ } else if ( (!is_array($currentArray) || empty($currentArray)) && (!is_array($newArray) || empty($newArray)) ) { + /** @var T */ return []; } @@ -482,26 +486,28 @@ class Util $elementArr[] = &$elem; for ($i = 0; $i <= $keyChainCount; $i++) { - if (is_array($elem) && array_key_exists($keyArr[$i], $elem)) { - if ($i == $keyChainCount) { - unset($elem[$keyArr[$i]]); + if (!array_key_exists($keyArr[$i], $elem)) { + continue; + } - if ($unsetParentEmptyArray) { - for ($j = count($elementArr); $j > 0; $j--) { - $pointer =& $elementArr[$j]; + if ($i == $keyChainCount) { + unset($elem[$keyArr[$i]]); - if (is_array($pointer) && empty($pointer)) { - $previous =& $elementArr[$j - 1]; - unset($previous[$keyArr[$j - 1]]); - } + if ($unsetParentEmptyArray) { + for ($j = count($elementArr); $j > 0; $j--) { + $pointer =& $elementArr[$j]; + + if (empty($pointer)) { + $previous =& $elementArr[$j - 1]; + + unset($previous[$keyArr[$j - 1]]); } } - } else if (is_array($elem[$keyArr[$i]])) { - $elem = &$elem[$keyArr[$i]]; - - $elementArr[] = &$elem; } + } else if (is_array($elem[$keyArr[$i]])) { + $elem = &$elem[$keyArr[$i]]; + $elementArr[] = &$elem; } } } diff --git a/application/Espo/EntryPoints/Image.php b/application/Espo/EntryPoints/Image.php index db18460e59..1c5b362400 100644 --- a/application/Espo/EntryPoints/Image.php +++ b/application/Espo/EntryPoints/Image.php @@ -48,6 +48,7 @@ use Espo\Core\Utils\Metadata; use Espo\Entities\Attachment; use GdImage; +use RuntimeException; use Throwable; class Image implements EntryPoint @@ -258,6 +259,10 @@ class Image implements EntryPoint } } + if ($targetWidth < 1 || $targetHeight < 1) { + throw new RuntimeException("No width or height."); + } + $targetImage = imagecreatetruecolor($targetWidth, $targetHeight); if ($targetImage === false) { @@ -378,7 +383,7 @@ class Image implements EntryPoint $orientation = $this->getOrientation($filePath); if ($orientation) { - $angle = array_values([0, 0, 0, 180, 0, 0, -90, 0, 90])[$orientation]; + $angle = [0, 0, 0, 180, 0, 0, -90, 0, 90][$orientation]; $targetImage = imagerotate($targetImage, $angle, 0) ?: $targetImage; } diff --git a/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php b/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php index 0577708935..9b64442bee 100644 --- a/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php +++ b/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php @@ -60,7 +60,7 @@ class CampaignTrackOpened implements EntryPoint { $id = $request->getQueryParam('id'); - if (!$id || !is_string($id)) { + if (!$id) { throw new BadRequest("No id."); } diff --git a/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php b/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php index 06b78877e0..f8ea27b3bc 100644 --- a/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php +++ b/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php @@ -72,7 +72,7 @@ class CampaignUrl implements EntryPoint $hash = $request->getQueryParam('hash') ?? null; $uid = $request->getQueryParam('uid') ?? null; - if (!$trackingUrlId || !is_string($trackingUrlId)) { + if (!$trackingUrlId) { throw new BadRequest("No tracking URL ID."); } @@ -88,7 +88,7 @@ class CampaignUrl implements EntryPoint } else if ($uid && $hash) { $this->processWithUniqueId($trackingUrl, $uid, $hash); } else { - if (!$queueItemId || !is_string($queueItemId)) { + if (!$queueItemId) { throw new BadRequest("No item ID."); } diff --git a/application/Espo/Modules/Crm/Jobs/SendEmailReminders.php b/application/Espo/Modules/Crm/Jobs/SendEmailReminders.php index c1f93d42de..d489502957 100644 --- a/application/Espo/Modules/Crm/Jobs/SendEmailReminders.php +++ b/application/Espo/Modules/Crm/Jobs/SendEmailReminders.php @@ -65,7 +65,7 @@ class SendEmailReminders implements JobDataLess $maxPortionSize = $this->config->get('emailReminderPortionSize') ?? self::MAX_PORTION_SIZE; $collection = $this->entityManager - ->getRDBRepository(Reminder::ENTITY_TYPE) + ->getRDBRepositoryByClass(Reminder::class) ->where([ 'type' => Reminder::TYPE_EMAIL, 'remindAt<=' => $now, @@ -74,7 +74,7 @@ class SendEmailReminders implements JobDataLess ->limit(0, $maxPortionSize) ->find(); - if (is_countable($collection) && count($collection) === 0) { + if (count($collection) === 0) { return; } diff --git a/application/Espo/Modules/Crm/Tools/Case/Distribution/LeastBusy.php b/application/Espo/Modules/Crm/Tools/Case/Distribution/LeastBusy.php index 41bf045b37..d3cbc6878a 100644 --- a/application/Espo/Modules/Crm/Tools/Case/Distribution/LeastBusy.php +++ b/application/Espo/Modules/Crm/Tools/Case/Distribution/LeastBusy.php @@ -32,20 +32,15 @@ namespace Espo\Modules\Crm\Tools\Case\Distribution; use Espo\Modules\Crm\Entities\CaseObj; use Espo\ORM\EntityManager; use Espo\Core\Utils\Metadata; - use Espo\Entities\User; use Espo\Entities\Team; class LeastBusy { - private EntityManager $entityManager; - private Metadata $metadata; - - public function __construct(EntityManager $entityManager, Metadata $metadata) - { - $this->entityManager = $entityManager; - $this->metadata = $metadata; - } + public function __construct( + private EntityManager $entityManager, + private Metadata $metadata + ) {} public function getUser(Team $team, ?string $targetUserPosition = null): ?User { @@ -64,7 +59,7 @@ class LeastBusy ->order('id') ->find(); - if (is_countable($userList) && count($userList) == 0) { + if (count($userList) === 0) { return null; } diff --git a/application/Espo/Modules/Crm/Tools/Case/Distribution/RoundRobin.php b/application/Espo/Modules/Crm/Tools/Case/Distribution/RoundRobin.php index fb99095b58..2d69dda270 100644 --- a/application/Espo/Modules/Crm/Tools/Case/Distribution/RoundRobin.php +++ b/application/Espo/Modules/Crm/Tools/Case/Distribution/RoundRobin.php @@ -31,18 +31,13 @@ namespace Espo\Modules\Crm\Tools\Case\Distribution; use Espo\Entities\User; use Espo\Entities\Team; - use Espo\Modules\Crm\Entities\CaseObj; use Espo\ORM\EntityManager; class RoundRobin { - private EntityManager $entityManager; - - public function __construct(EntityManager $entityManager) - { - $this->entityManager = $entityManager; - } + public function __construct(private EntityManager $entityManager) + {} public function getUser(Team $team, ?string $targetUserPosition = null): ?User { @@ -55,13 +50,13 @@ class RoundRobin } $userList = $this->entityManager - ->getRDBRepository(Team::ENTITY_TYPE) + ->getRDBRepositoryByClass(Team::class) ->getRelation($team, 'users') ->where($where) ->order('id') ->find(); - if (is_countable($userList) && count($userList) == 0) { + if (count($userList) === 0) { return null; } diff --git a/application/Espo/Modules/Crm/Tools/Lead/ConvertService.php b/application/Espo/Modules/Crm/Tools/Lead/ConvertService.php index 3226f90035..cb2b6f8dbc 100644 --- a/application/Espo/Modules/Crm/Tools/Lead/ConvertService.php +++ b/application/Espo/Modules/Crm/Tools/Lead/ConvertService.php @@ -55,7 +55,6 @@ use Espo\Modules\Crm\Entities\Opportunity; use Espo\Modules\Crm\Tools\Lead\Convert\Params; use Espo\Modules\Crm\Tools\Lead\Convert\Values; use Espo\ORM\Collection; -use Espo\ORM\Entity; use Espo\ORM\EntityManager; use Espo\ORM\Name\Attribute; use Espo\Repositories\Attachment as AttachmentRepository; @@ -281,7 +280,7 @@ class ConvertService } /** - * @param Entity[] $duplicateList + * @param object[] $duplicateList * @throws Forbidden * @throws BadRequest * @throws Conflict @@ -334,7 +333,7 @@ class ConvertService } /** - * @param Entity[] $duplicateList + * @param object[] $duplicateList * @throws Forbidden * @throws BadRequest * @throws Conflict @@ -391,7 +390,7 @@ class ConvertService } /** - * @param Entity[] $duplicateList + * @param object[] $duplicateList * @throws Forbidden * @throws BadRequest * @throws Conflict