diff --git a/application/Espo/Core/Utils/DateTime.php b/application/Espo/Core/Utils/DateTime.php index 0c73dc1591..6da7557f12 100644 --- a/application/Espo/Core/Utils/DateTime.php +++ b/application/Espo/Core/Utils/DateTime.php @@ -46,13 +46,13 @@ class DateTime public const SYSTEM_DATE_FORMAT = 'Y-m-d'; - private ?string $dateFormat; + private string $dateFormat; - private ?string $timeFormat; + private string $timeFormat; private DateTimeZone $timezone; - private ?string $language; + private string $language; public function __construct( ?string $dateFormat = 'YYYY-MM-DD', @@ -94,7 +94,7 @@ class DateTime string $string, ?string $format = null, ?string $language = null - ): ?string { + ): string { $dateTime = DateTimeStd::createFromFormat('Y-m-d', $string); diff --git a/application/Espo/Core/Utils/File/Manager.php b/application/Espo/Core/Utils/File/Manager.php index b2e267646d..409d4a87f7 100644 --- a/application/Espo/Core/Utils/File/Manager.php +++ b/application/Espo/Core/Utils/File/Manager.php @@ -978,6 +978,7 @@ class Manager */ public function getDirName(string $path, bool $isFullPath = true, bool $useIsDir = true): string { + /** @var string */ $dirName = preg_replace('/\/$/i', '', $path); $dirName = ($useIsDir && is_dir($dirName)) ? @@ -1159,6 +1160,7 @@ class Manager $basePath .= $dirSeparator; } + /** @var string */ return preg_replace('/^'. preg_quote($basePath, $dirSeparator) . '/', '', $path); } diff --git a/application/Espo/Core/Utils/File/ZipArchive.php b/application/Espo/Core/Utils/File/ZipArchive.php index bd434a11d8..9c53983a03 100644 --- a/application/Espo/Core/Utils/File/ZipArchive.php +++ b/application/Espo/Core/Utils/File/ZipArchive.php @@ -33,11 +33,11 @@ use Espo\Core\Exceptions\Error; class ZipArchive { - private $fileManager; + private Manager $fileManager; - public function __construct(Manager $fileManager = null) + public function __construct(?Manager $fileManager = null) { - if (!isset($fileManager)) { + if ($fileManager === null) { $fileManager = new Manager(); } diff --git a/application/Espo/Core/Utils/Language.php b/application/Espo/Core/Utils/Language.php index 3ad7f1e785..b719ee23cc 100644 --- a/application/Espo/Core/Utils/Language.php +++ b/application/Espo/Core/Utils/Language.php @@ -58,7 +58,7 @@ class Language */ private $changedData = []; - private ?string $currentLanguage = null; + private string $currentLanguage; protected string $defaultLanguage = 'en_US'; diff --git a/application/Espo/Core/Utils/Layout.php b/application/Espo/Core/Utils/Layout.php index eeeeeb9df1..03b75cb587 100644 --- a/application/Espo/Core/Utils/Layout.php +++ b/application/Espo/Core/Utils/Layout.php @@ -113,6 +113,7 @@ class Layout protected function sanitizeInput(string $name): string { + /** @var string */ return preg_replace("([\.]{2,})", '', $name); } } diff --git a/application/Espo/Core/Utils/Metadata.php b/application/Espo/Core/Utils/Metadata.php index 375e933452..30946fc829 100644 --- a/application/Espo/Core/Utils/Metadata.php +++ b/application/Espo/Core/Utils/Metadata.php @@ -145,6 +145,8 @@ class Metadata $this->init(); } + assert($this->data !== null); + return $this->data; } @@ -175,6 +177,8 @@ class Metadata $this->init($reload); } + assert($this->data !== null); + if ($isJSON) { return Json::encode($this->data); } @@ -212,6 +216,8 @@ class Metadata $this->objInit($reload); } + assert($this->objData !== null); + return $this->objData; } diff --git a/application/Espo/Core/Utils/Module.php b/application/Espo/Core/Utils/Module.php index 91a38c61a5..1beb2f90d5 100644 --- a/application/Espo/Core/Utils/Module.php +++ b/application/Espo/Core/Utils/Module.php @@ -101,6 +101,8 @@ class Module $this->init(); } + assert($this->data !== null); + if ($key === null) { return $this->data; } @@ -110,7 +112,11 @@ class Module private function init(): void { - if ($this->useCache && $this->dataCache->has($this->cacheKey)) { + if ( + $this->useCache && + $this->dataCache && + $this->dataCache->has($this->cacheKey) + ) { /** @var array> */ $data = $this->dataCache->get($this->cacheKey); @@ -121,7 +127,7 @@ class Module $this->data = $this->loadData(); - if ($this->useCache) { + if ($this->useCache && $this->dataCache) { $this->dataCache->store($this->cacheKey, $this->data); } }