From 706cb66021ff8c1f45fdf1b339b2dfd62855b5f3 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 17 Mar 2022 15:14:41 +0200 Subject: [PATCH] type fixes --- .../Core/Utils/AdminNotificationManager.php | 4 ++-- application/Espo/Core/Utils/Autoload.php | 5 ++++- .../Core/Utils/Autoload/NamespaceLoader.php | 18 +++++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/application/Espo/Core/Utils/AdminNotificationManager.php b/application/Espo/Core/Utils/AdminNotificationManager.php index e076ede206..56c91d8f7d 100644 --- a/application/Espo/Core/Utils/AdminNotificationManager.php +++ b/application/Espo/Core/Utils/AdminNotificationManager.php @@ -78,7 +78,7 @@ class AdminNotificationManager $notificationList[] = [ 'id' => 'cronIsNotConfigured', 'type' => 'cronIsNotConfigured', - 'message' => $this->language->translate('cronIsNotConfigured', 'messages', 'Admin'), + 'message' => $this->language->translateLabel('cronIsNotConfigured', 'messages', 'Admin'), ]; } } @@ -87,7 +87,7 @@ class AdminNotificationManager $instanceNeedingUpgrade = $this->getInstanceNeedingUpgrade(); if (!empty($instanceNeedingUpgrade)) { - $message = $this->language->translate('newVersionIsAvailable', 'messages', 'Admin'); + $message = $this->language->translateLabel('newVersionIsAvailable', 'messages', 'Admin'); $notificationList[] = [ 'id' => 'newVersionIsAvailable', diff --git a/application/Espo/Core/Utils/Autoload.php b/application/Espo/Core/Utils/Autoload.php index 944b3a7b53..b230c98faf 100644 --- a/application/Espo/Core/Utils/Autoload.php +++ b/application/Espo/Core/Utils/Autoload.php @@ -94,7 +94,10 @@ class Autoload $useCache = $this->config->get('useCache'); if ($useCache && $this->dataCache->has($this->cacheKey)) { - $this->data = $this->dataCache->get($this->cacheKey); + /** @var ?array */ + $data = $this->dataCache->get($this->cacheKey); + + $this->data = $data; return; } diff --git a/application/Espo/Core/Utils/Autoload/NamespaceLoader.php b/application/Espo/Core/Utils/Autoload/NamespaceLoader.php index f7bdcde641..e16735c165 100644 --- a/application/Espo/Core/Utils/Autoload/NamespaceLoader.php +++ b/application/Espo/Core/Utils/Autoload/NamespaceLoader.php @@ -60,7 +60,7 @@ class NamespaceLoader private string $autoloadFilePath = 'vendor/autoload.php'; /** - * @var array + * @var array<'psr-4'|'psr-0'|'classmap',string> */ private $namespacesPaths = [ 'psr-4' => 'vendor/composer/autoload_psr4.php', @@ -69,7 +69,7 @@ class NamespaceLoader ]; /** - * @var array + * @var array<'psr-4'|'psr-0',string> */ private $methodNameMap = [ 'psr-4' => 'addPsr4', @@ -157,16 +157,18 @@ class NamespaceLoader } /** + * @param 'psr-4'|'psr-0'|'classmap' $type * @return string[] */ private function getNamespaceList(string $type): array { $namespaces = $this->getNamespaces(); - return array_keys($namespaces[$type]); + return array_keys($namespaces[$type] ?? []); } /** + * @param 'psr-4'|'psr-0'|'classmap' $type * @param string|array $path */ private function addNamespace(string $type, string $name, $path): void @@ -178,6 +180,9 @@ class NamespaceLoader $this->namespaces[$type][$name] = (array) $path; } + /** + * @param 'psr-4'|'psr-0'|'classmap' $type + */ private function hasNamespace(string $type, string $name): bool { if (in_array($name, $this->getNamespaceList($type))) { @@ -249,11 +254,10 @@ class NamespaceLoader $this->vendorNamespaces = []; if ($useCache && $this->dataCache->has($this->cacheKey)) { - $this->vendorNamespaces = $this->dataCache->get($this->cacheKey); + /** @var ?array*/ + $cachedData = $this->dataCache->get($this->cacheKey); - if (!is_array($this->vendorNamespaces)) { - $this->vendorNamespaces = []; - } + $this->vendorNamespaces = $cachedData; } }