diff --git a/application/Espo/Core/Formula/Functions/ArrayGroup/JoinType.php b/application/Espo/Core/Formula/Functions/ArrayGroup/JoinType.php index 2eb79eac87..39e111086f 100644 --- a/application/Espo/Core/Formula/Functions/ArrayGroup/JoinType.php +++ b/application/Espo/Core/Formula/Functions/ArrayGroup/JoinType.php @@ -50,10 +50,6 @@ class JoinType extends BaseFunction $this->throwBadArgumentValue(2, 'string'); } - if (is_null($list)) { - return ''; - } - return implode($separator, $list); } } diff --git a/application/Espo/Core/Upgrades/Actions/Base.php b/application/Espo/Core/Upgrades/Actions/Base.php index 9bfff0bfbe..03a9c2ad2b 100644 --- a/application/Espo/Core/Upgrades/Actions/Base.php +++ b/application/Espo/Core/Upgrades/Actions/Base.php @@ -283,7 +283,7 @@ abstract class Base } /** - * @param never $data + * @param mixed $data * @return mixed */ abstract public function run($data); diff --git a/application/Espo/Core/Utils/File/Manager.php b/application/Espo/Core/Utils/File/Manager.php index 820e397c18..5a8c3bf8e8 100644 --- a/application/Espo/Core/Utils/File/Manager.php +++ b/application/Espo/Core/Utils/File/Manager.php @@ -904,6 +904,8 @@ class Manager /** * Check whether a path is a directory. + * + * @phpstan-impure */ public function isDir(string $dirPath): bool { @@ -912,6 +914,8 @@ class Manager /** * Check whether a file. + * + * @phpstan-impure */ public function isFile(string $path): bool { diff --git a/application/Espo/EntryPoints/Image.php b/application/Espo/EntryPoints/Image.php index 42a57b4d03..136785aeaa 100644 --- a/application/Espo/EntryPoints/Image.php +++ b/application/Espo/EntryPoints/Image.php @@ -238,9 +238,9 @@ class Image implements EntryPoint throw new Error(); } - list($originalWidth, $originalHeight) = getimagesize($filePath); + [$originalWidth, $originalHeight] = getimagesize($filePath); - list($width, $height) = $this->getSizes()[$size]; + [$width, $height] = $this->getSizes()[$size]; if ($originalWidth <= $width && $originalHeight <= $height) { $targetWidth = $originalWidth; @@ -249,19 +249,19 @@ class Image implements EntryPoint else { if ($originalWidth > $originalHeight) { $targetWidth = $width; - $targetHeight = $originalHeight / ($originalWidth / $width); + $targetHeight = (int) ($originalHeight / ($originalWidth / $width)); if ($targetHeight > $height) { $targetHeight = $height; - $targetWidth = $originalWidth / ($originalHeight / $height); + $targetWidth = (int) ($originalWidth / ($originalHeight / $height)); } } else { $targetHeight = $height; - $targetWidth = $originalWidth / ($originalHeight / $height); + $targetWidth = (int) ($originalWidth / ($originalHeight / $height)); if ($targetWidth > $width) { $targetWidth = $width; - $targetHeight = $originalHeight / ($originalWidth / $width); + $targetHeight = (int) ($originalHeight / ($originalWidth / $width)); } } } diff --git a/application/Espo/Modules/Crm/Hooks/Opportunity/Probability.php b/application/Espo/Modules/Crm/Hooks/Opportunity/Probability.php index 18135631bc..469b0c3648 100644 --- a/application/Espo/Modules/Crm/Hooks/Opportunity/Probability.php +++ b/application/Espo/Modules/Crm/Hooks/Opportunity/Probability.php @@ -66,10 +66,6 @@ class Probability implements BeforeSave $probability = $this->metadata ->get('entityDefs.Opportunity.fields.stage.probabilityMap.' . $stage) ?? 0; - if ($probability === null) { - return; - } - $entity->setProbability($probability); } } diff --git a/application/Espo/Repositories/Email.php b/application/Espo/Repositories/Email.php index c097de8f23..bb0cd545eb 100644 --- a/application/Espo/Repositories/Email.php +++ b/application/Espo/Repositories/Email.php @@ -69,14 +69,12 @@ class Email extends Database implements if (!empty($addressValue)) { $addressList = array_map( - function ($item) { - return trim($item); - }, + fn ($item) => trim($item), explode(';', $addressValue) ); $addressList = array_filter($addressList, function ($item) { - return filter_var($item, FILTER_VALIDATE_EMAIL); + return filter_var($item, FILTER_VALIDATE_EMAIL) !== false; }); $idList = $eaRepository->getIdListFormAddressList($addressList); diff --git a/application/Espo/Tools/EmailTemplate/Formatter.php b/application/Espo/Tools/EmailTemplate/Formatter.php index 613f94f9e3..75a707f738 100644 --- a/application/Espo/Tools/EmailTemplate/Formatter.php +++ b/application/Espo/Tools/EmailTemplate/Formatter.php @@ -37,6 +37,8 @@ use Espo\Core\Utils\DateTime as DateTimeUtil; use Espo\Core\Utils\NumberUtil; use Espo\Core\Utils\Language; +use Stringable; + class Formatter { private Metadata $metadata; @@ -163,7 +165,10 @@ class Formatter return $this->number->format($value); } - if (!is_string($value) && is_scalar($value) || is_callable([$value, '__toString'])) { + if ( + !is_string($value) && is_scalar($value) || + $value instanceof Stringable + ) { return strval($value); } diff --git a/composer.lock b/composer.lock index dcc7592ae1..a239447f36 100644 --- a/composer.lock +++ b/composer.lock @@ -6884,16 +6884,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.14", + "version": "1.10.57", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "d232901b09e67538e5c86a724be841bea5768a7c" + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d232901b09e67538e5c86a724be841bea5768a7c", - "reference": "d232901b09e67538e5c86a724be841bea5768a7c", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e", + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e", "shasum": "" }, "require": { @@ -6942,7 +6942,7 @@ "type": "tidelift" } ], - "time": "2023-04-19T13:47:27+00:00" + "time": "2024-01-24T11:51:34+00:00" }, { "name": "phpunit/php-code-coverage",