Skip to content

EspoCRM – Open Source CRM Application

ref

Yuri Kuznetsovb95c1c8878b4
diff --git a/application/Espo/Classes/AclPortal/Email/AccessChecker.php b/application/Espo/Classes/AclPortal/Email/AccessChecker.php
index 05e2820088..b924a64d81 100644
--- a/application/Espo/Classes/AclPortal/Email/AccessChecker.php
+++ b/application/Espo/Classes/AclPortal/Email/AccessChecker.php
@@ -70,7 +70,7 @@ class AccessChecker implements AccessEntityCREDSChecker
$userIdList = $entity->getLinkMultipleIdList('users');
- if (is_array($userIdList) && in_array($user->getId(), $userIdList)) {
+ if (in_array($user->getId(), $userIdList)) {
return true;
}
diff --git a/application/Espo/Classes/FieldValidators/CurrencyType.php b/application/Espo/Classes/FieldValidators/CurrencyType.php
index 2c07da27b1..58446f0318 100644
--- a/application/Espo/Classes/FieldValidators/CurrencyType.php
+++ b/application/Espo/Classes/FieldValidators/CurrencyType.php
@@ -96,6 +96,8 @@ class CurrencyType extends FloatType
$pad = str_pad('', $precision, '9');
+ assert(is_numeric($pad));
+
$limit = Currency::create($pad, 'USD');
if ($currency->compare($limit) === 1) {
diff --git a/application/Espo/Classes/TemplateHelpers/GoogleMaps.php b/application/Espo/Classes/TemplateHelpers/GoogleMaps.php
index b21fc083b3..b800e74da4 100644
--- a/application/Espo/Classes/TemplateHelpers/GoogleMaps.php
+++ b/application/Espo/Classes/TemplateHelpers/GoogleMaps.php
@@ -32,30 +32,26 @@ namespace Espo\Classes\TemplateHelpers;
use Espo\Core\Htmlizer\Helper;
use Espo\Core\Htmlizer\Helper\Data;
use Espo\Core\Htmlizer\Helper\Result;
-
use Espo\Core\Utils\Metadata;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\Log;
+use const CURLOPT_FOLLOWLOCATION;
+use const CURLOPT_HEADER;
+use const CURLOPT_HTTPHEADER;
+use const CURLOPT_RETURNTRANSFER;
+use const CURLOPT_TIMEOUT;
+use const CURLOPT_URL;
+use const CURLOPT_USERAGENT;
class GoogleMaps implements Helper
{
private const DEFAULT_SIZE = '400x400';
- private $metadata;
-
- private $config;
-
- private $log;
-
public function __construct(
- Metadata $metadata,
- Config $config,
- Log $log
- ) {
- $this->metadata = $metadata;
- $this->config = $config;
- $this->log = $log;
- }
+ private Metadata $metadata,
+ private Config $config,
+ private Log $log,
+ ) {}
public function render(Data $data): Result
{
@@ -194,6 +190,7 @@ class GoogleMaps implements Helper
}
/**
+ * @param non-empty-string $url
* @return string|bool
*/
private function getImage(string $url)
@@ -207,13 +204,13 @@ class GoogleMaps implements Helper
$c = curl_init();
- curl_setopt($c, \CURLOPT_URL, $url);
- curl_setopt($c, \CURLOPT_HTTPHEADER, $headers);
- curl_setopt($c, \CURLOPT_HEADER, 0);
- curl_setopt($c, \CURLOPT_USERAGENT, $agent);
- curl_setopt($c, \CURLOPT_TIMEOUT, 10);
- curl_setopt($c, \CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($c, \CURLOPT_FOLLOWLOCATION, 1);
+ curl_setopt($c, CURLOPT_URL, $url);
+ curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($c, CURLOPT_HEADER, false);
+ curl_setopt($c, CURLOPT_USERAGENT, $agent);
+ curl_setopt($c, CURLOPT_TIMEOUT, 10);
+ curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
$raw = curl_exec($c);
diff --git a/application/Espo/Core/Acl/Table/DefaultTable.php b/application/Espo/Core/Acl/Table/DefaultTable.php
index 4bcd519f54..2bd7a7f4c4 100644
--- a/application/Espo/Core/Acl/Table/DefaultTable.php
+++ b/application/Espo/Core/Acl/Table/DefaultTable.php
@@ -35,7 +35,6 @@ use Espo\Entities\User;
use Espo\Core\Acl\FieldData;
use Espo\Core\Acl\ScopeData;
use Espo\Core\Acl\Table;
-use Espo\Core\Utils\Config;
use Espo\Core\Utils\DataCache;
use Espo\Core\Utils\Metadata;
use stdClass;
@@ -219,7 +218,7 @@ class DefaultTable implements Table
$this->applyAdminMandatory($aclTable, $fieldTable);
}
- foreach ($aclTable as $scope => $data) {
+ foreach (get_object_vars($aclTable) as $scope => $data) {
if (is_string($data) && isset($aclTable->$data)) {
$aclTable->$scope = $aclTable->$data;
}
diff --git a/application/Espo/Core/AclManager.php b/application/Espo/Core/AclManager.php
index b7af052a08..da09901337 100644
--- a/application/Espo/Core/AclManager.php
+++ b/application/Espo/Core/AclManager.php
@@ -308,6 +308,7 @@ class AclManager
$checker = $this->getAccessChecker($scope);
+ /** @var non-falsy-string $methodName */
$methodName = 'checkEntity' . ucfirst($action);
$interface = $this->entityActionInterfaceMap[$action] ?? null;
@@ -322,7 +323,7 @@ class AclManager
/**
* Check 'read' access to a specific entity.
*
- * @throws NotImplemented.
+ * @throws NotImplemented
*/
public function checkEntityRead(User $user, Entity $entity): bool
{
diff --git a/application/Espo/Core/Binding/EspoBindingLoader.php b/application/Espo/Core/Binding/EspoBindingLoader.php
index d883629088..1ad020f3a4 100644
--- a/application/Espo/Core/Binding/EspoBindingLoader.php
+++ b/application/Espo/Core/Binding/EspoBindingLoader.php
@@ -73,6 +73,7 @@ class EspoBindingLoader implements BindingLoader
private function loadCustom(Binder $binder): void
{
+ /** @var class-string<BindingProcessor>|string $className */
$className = 'Espo\\Custom\\Binding';
if (!class_exists($className)) {
diff --git a/application/Espo/Core/Console/Commands/Extension.php b/application/Espo/Core/Console/Commands/Extension.php
index 511959a171..124e8e8bcd 100644
--- a/application/Espo/Core/Console/Commands/Extension.php
+++ b/application/Espo/Core/Console/Commands/Extension.php
@@ -248,11 +248,10 @@ class Extension implements Command
private function printList(IO $io): void
{
$collection = $this->entityManager
- ->getRDBRepository(ExtensionEntity::ENTITY_TYPE)
+ ->getRDBRepositoryByClass(ExtensionEntity::class)
->find();
- /** @noinspection PhpParamsInspection */
- $count = is_countable($collection) ? count($collection) : iterator_count($collection);
+ $count = count($collection);
/** @noinspection PhpIfWithCommonPartsInspection */
if ($count === 0) {
@@ -268,9 +267,9 @@ class Extension implements Command
$io->writeLine("");
foreach ($collection as $extension) {
- $isInstalled = $extension->get('isInstalled');
+ $isInstalled = $extension->isInstalled();
- $io->writeLine(' Name: ' . $extension->get(Field::NAME));
+ $io->writeLine(' Name: ' . $extension->getName());
$io->writeLine(' ID: ' . $extension->getId());
$io->writeLine(' Version: ' . $extension->getVersion());
$io->writeLine(' Installed: ' . ($isInstalled ? 'yes' : 'no'));
diff --git a/application/Espo/Core/Console/Commands/Upgrade.php b/application/Espo/Core/Console/Commands/Upgrade.php
index d95efe121d..bbc59141a0 100644
--- a/application/Espo/Core/Console/Commands/Upgrade.php
+++ b/application/Espo/Core/Console/Commands/Upgrade.php
@@ -495,13 +495,19 @@ class Upgrade implements Command
return null;
}
- /** @var string */
- return realpath($localFilePath);
+ $path = realpath($localFilePath);
+
+ assert($path !== false);
+
+ return $path;
}
private function isShellEnabled(): bool
{
- if (!function_exists('exec') || !is_callable('shell_exec')) {
+ if (
+ !function_exists('exec') ||
+ !is_callable('shell_exec') /** @phpstan-ignore-line */
+ ) {
return false;
}
diff --git a/application/Espo/Core/Container/ContainerBuilder.php b/application/Espo/Core/Container/ContainerBuilder.php
index c0fb4c0534..b55d93acbe 100644
--- a/application/Espo/Core/Container/ContainerBuilder.php
+++ b/application/Espo/Core/Container/ContainerBuilder.php
@@ -168,12 +168,14 @@ class ContainerBuilder
)
);
+ /** @var FileManager $fileManager */
$fileManager = $this->services['fileManager'] ?? (
new $this->fileManagerClassName(
$config->get('defaultPermissions')
)
);
+ /** @var DataCache $dataCache */
$dataCache = $this->services['dataCache'] ?? (
new $this->dataCacheClassName($fileManager)
);
diff --git a/application/Espo/Core/Container/ContainerConfiguration.php b/application/Espo/Core/Container/ContainerConfiguration.php
index 07dd27a272..fe239df4f2 100644
--- a/application/Espo/Core/Container/ContainerConfiguration.php
+++ b/application/Espo/Core/Container/ContainerConfiguration.php
@@ -39,8 +39,8 @@ class ContainerConfiguration implements Configuration
{
/**
* Log must be loaded before anything.
- * @phpstan-ignore-next-line
* @noinspection PhpPropertyOnlyWrittenInspection
+ * @phpstan-ignore-next-line
*/
private Log $log;
diff --git a/application/Espo/Core/Controllers/Base.php b/application/Espo/Core/Controllers/Base.php
index b178e17d84..e4a910d881 100644
--- a/application/Espo/Core/Controllers/Base.php
+++ b/application/Espo/Core/Controllers/Base.php
@@ -63,12 +63,12 @@ abstract class Base
private $container;
/**
- * @var User;
+ * @var User
*/
protected $user;
/**
- * @var Acl;
+ * @var Acl
*/
protected $acl;
@@ -161,12 +161,11 @@ abstract class Base
}
/**
- * @return void;
+ * @return void
* @deprecated
*/
protected function checkControllerAccess()
{
- return;
}
/**