EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
type fixes
Yurii20a0ed41335b
diff --git a/application/Espo/Core/Authentication/Oidc/Login.php b/application/Espo/Core/Authentication/Oidc/Login.phpindex 3a9ec90773..8535f59164 100644--- a/application/Espo/Core/Authentication/Oidc/Login.php+++ b/application/Espo/Core/Authentication/Oidc/Login.php@@ -204,6 +204,7 @@ class Login implements LoginInterface}/**+ * @param non-empty-string $endpoint* @return array{?string, ?Result, ?string}*/private function requestToken(diff --git a/application/Espo/Core/Console/Commands/Upgrade.php b/application/Espo/Core/Console/Commands/Upgrade.phpindex 0a680f49a5..a0af48f625 100644--- a/application/Espo/Core/Console/Commands/Upgrade.php+++ b/application/Espo/Core/Console/Commands/Upgrade.php@@ -463,6 +463,9 @@ class Upgrade implements Commandreturn $data;}+ /**+ * @param non-empty-string $url+ */private function downloadFile(string $url): ?string{$localFilePath = 'data/upload/upgrades/' . Util::generateId() . '.zip';@@ -472,8 +475,16 @@ class Upgrade implements Commandif (is_file($url)) {copy($url, $localFilePath);} else {+ $fp = fopen($localFilePath, 'w');++ if ($fp === false) {+ echo "\nCould not open local file for writing.\n";++ return null;+ }+$options = [- CURLOPT_FILE => fopen($localFilePath, 'w'),+ CURLOPT_FILE => $fp,CURLOPT_TIMEOUT => 3600,CURLOPT_URL => $url,];@@ -481,9 +492,7 @@ class Upgrade implements Command$ch = curl_init();curl_setopt_array($ch, $options);-curl_exec($ch);-curl_close($ch);}diff --git a/application/Espo/Core/ExternalAccount/Clients/OAuth2Abstract.php b/application/Espo/Core/ExternalAccount/Clients/OAuth2Abstract.phpindex 5f294875e7..819ddfd4fc 100644--- a/application/Espo/Core/ExternalAccount/Clients/OAuth2Abstract.php+++ b/application/Espo/Core/ExternalAccount/Clients/OAuth2Abstract.php@@ -258,7 +258,7 @@ abstract class OAuth2Abstract implements IClient}/**- * @return string+ * @return non-empty-string*/protected function getPingUrl(){@@ -404,9 +404,9 @@ abstract class OAuth2Abstract implements IClient}/**- * @param string $url+ * @param non-empty-string $url* @param array<string, mixed>|string|null $params- * @param string $httpMethod+ * @param non-empty-string $httpMethod* @param ?string $contentType* @param bool $allowRenew* @return mixeddiff --git a/application/Espo/Core/ExternalAccount/OAuth2/Client.php b/application/Espo/Core/ExternalAccount/OAuth2/Client.phpindex 2ae5c90a4b..bd7ab9b7ef 100644--- a/application/Espo/Core/ExternalAccount/OAuth2/Client.php+++ b/application/Espo/Core/ExternalAccount/OAuth2/Client.php@@ -213,9 +213,9 @@ class Client}/**- * @param string $url+ * @param non-empty-string $url* @param array<string, mixed>|string|null $params- * @param string $httpMethod+ * @param non-empty-string $httpMethod* @param array<string, string> $httpHeaders* @return array{* result: array<string, mixed>|string,@@ -262,9 +262,9 @@ class Client}/**- * @param string $url+ * @param non-empty-string $url* @param array<string, mixed>|string|null $params- * @param string $httpMethod+ * @param non-empty-string $httpMethod* @param array<string, string> $httpHeaders* @return array{* result: array<string, mixed>|string,@@ -302,7 +302,9 @@ class Client$postFields = $params;}- $curlOptions[CURLOPT_POSTFIELDS] = $postFields;+ if ($postFields !== '' && $postFields !== null) {+ $curlOptions[CURLOPT_POSTFIELDS] = $postFields;+ }break;@@ -403,7 +405,7 @@ class Client}/**- * @param string $url+ * @param non-empty-string $url* @param string $grantType* @param array{* client_id?: string,diff --git a/application/Espo/Core/Formula/Processor.php b/application/Espo/Core/Formula/Processor.phpindex 8bbe95a03b..3577f8be83 100644--- a/application/Espo/Core/Formula/Processor.php+++ b/application/Espo/Core/Formula/Processor.php@@ -177,7 +177,7 @@ class Processor$evaluatedArguments = new EvaluatedArgumentList($rawEvaluatedArguments);if ($function instanceof FuncVariablesAware) {- $variables = new Variables($this->variables ?? (object) []);+ $variables = new Variables($this->variables);return $function->process($evaluatedArguments, $variables);}diff --git a/application/Espo/Core/Select/SearchParams.php b/application/Espo/Core/Select/SearchParams.phpindex 45fb99221e..4f1ee72333 100644--- a/application/Espo/Core/Select/SearchParams.php+++ b/application/Espo/Core/Select/SearchParams.php@@ -244,7 +244,6 @@ class SearchParams* With a primary filter.** @param string|null $primaryFilter- * @return $this*/public function withPrimaryFilter(?string $primaryFilter): self{diff --git a/application/Espo/Core/Utils/Database/Orm/Converter.php b/application/Espo/Core/Utils/Database/Orm/Converter.phpindex a3db5f6aa4..c999dedea8 100644--- a/application/Espo/Core/Utils/Database/Orm/Converter.php+++ b/application/Espo/Core/Utils/Database/Orm/Converter.php@@ -135,6 +135,7 @@ class Converter$this->entityDefs = $this->metadata->get('entityDefs');}+ /** @var array<string, mixed> */return $this->entityDefs;}diff --git a/application/Espo/Core/Utils/File/Permission.php b/application/Espo/Core/Utils/File/Permission.phpindex 5a503207a8..0817d0c50d 100644--- a/application/Espo/Core/Utils/File/Permission.php+++ b/application/Espo/Core/Utils/File/Permission.php@@ -237,8 +237,9 @@ class Permission$pKey = $rule[$count];}+ /** @phpstan-ignore-next-line empty.variable */if (!empty($pKey)) {- $permission[$pKey]= $val;+ $permission[$pKey] = $val;}$count++;diff --git a/application/Espo/Core/Utils/Util.php b/application/Espo/Core/Utils/Util.phpindex a7a4fbbf65..c19aa73c02 100644--- a/application/Espo/Core/Utils/Util.php+++ b/application/Espo/Core/Utils/Util.php@@ -890,14 +890,14 @@ class Util/*** Sanitize HTML code.*- * @param string|string[] $text A source.+ * @param string|array<string|int, mixed> $text A source.* @param string[] $permittedHtmlTags Allows only HTML tags without parameters like <p></p>, <br>, etc.- * @return string|string[]+ * @return string|array<string|int, mixed>*/public static function sanitizeHtml($text, $permittedHtmlTags = ['p', 'br', 'b', 'strong', 'pre']){if (is_array($text)) {- foreach ($text as $key => &$value) {+ foreach ($text as &$value) {$value = self::sanitizeHtml($value, $permittedHtmlTags);}diff --git a/application/Espo/EntryPoints/Image.php b/application/Espo/EntryPoints/Image.phpindex 60369984ce..fc4b99713f 100644--- a/application/Espo/EntryPoints/Image.php+++ b/application/Espo/EntryPoints/Image.php@@ -391,7 +391,7 @@ class Image implements EntryPoint$orientation = $this->getOrientation($filePath);if ($orientation) {- $angle = [0, 0, 0, 180, 0, 0, -90, 0, 90][$orientation];+ $angle = [0, 0, 0, 180, 0, 0, -90, 0, 90][$orientation] ?? 0;$targetImage = imagerotate($targetImage, $angle, 0) ?: $targetImage;}diff --git a/application/Espo/ORM/QueryComposer/BaseQueryComposer.php b/application/Espo/ORM/QueryComposer/BaseQueryComposer.phpindex b27fa61466..5ea05fd154 100644--- a/application/Espo/ORM/QueryComposer/BaseQueryComposer.php+++ b/application/Espo/ORM/QueryComposer/BaseQueryComposer.php@@ -2053,7 +2053,7 @@ abstract class BaseQueryComposer implements QueryComposer/*** @param string[]|array<string[]> $select- * @param string[] $explicitJoins+ * @param string[]|array<int, mixed>[] $explicitJoins* @param array<string, mixed> $params*/protected function getBelongsToJoinsPart(diff --git a/application/Espo/Tools/Attachment/UploadUrlService.php b/application/Espo/Tools/Attachment/UploadUrlService.phpindex ae7b4ec18a..90de15bd01 100644--- a/application/Espo/Tools/Attachment/UploadUrlService.php+++ b/application/Espo/Tools/Attachment/UploadUrlService.php@@ -66,6 +66,7 @@ class UploadUrlService/*** Upload an image from and URL and store as attachment.*+ * @param non-empty-string $url* @throws Forbidden* @throws Error*/@@ -111,7 +112,7 @@ class UploadUrlService}/**- * @param string $url+ * @param non-empty-string $url* @return ?array{string, string} A type and contents.*/private function getImageDataByUrl(string $url): ?array@@ -127,7 +128,7 @@ class UploadUrlService$httpHeaders = [];$httpHeaders[] = 'Expect:';- $opts[\CURLOPT_URL] = $url;+ $opts[\CURLOPT_URL] = $url;$opts[\CURLOPT_HTTPHEADER] = $httpHeaders;$opts[\CURLOPT_CONNECTTIMEOUT] = 10;$opts[\CURLOPT_TIMEOUT] = 10;diff --git a/application/Espo/Tools/WorkingTime/Extractor.php b/application/Espo/Tools/WorkingTime/Extractor.phpindex d9991b3e8f..1801976879 100644--- a/application/Espo/Tools/WorkingTime/Extractor.php+++ b/application/Espo/Tools/WorkingTime/Extractor.php@@ -36,6 +36,7 @@ use Espo\Tools\WorkingTime\Calendar\HavingRanges;use Espo\Core\Field\DateTime;use Espo\Core\Field\Date;+use LogicException;class Extractor{@@ -108,7 +109,7 @@ class Extractor}for ($i = count($list) - 1; $i >= 0; $i--) {- $pair = $list[$i];+ $pair = $list[$i] ?? throw new LogicException();if ($to->isGreaterThan($pair[1]) || $to->isEqualTo($pair[1])) {break;