From cc89b69f18dd773f86730a56a3f480479f5188f3 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 17 Mar 2022 13:42:20 +0200 Subject: [PATCH] type fixes --- application/Espo/Core/Utils/FieldUtil.php | 4 +++- application/Espo/Core/Utils/File/ClassMap.php | 11 ++--------- tests/unit/Espo/Core/Utils/File/ClassMapTest.php | 4 ---- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/application/Espo/Core/Utils/FieldUtil.php b/application/Espo/Core/Utils/FieldUtil.php index 8ebb185cac..05f2ef9e83 100644 --- a/application/Espo/Core/Utils/FieldUtil.php +++ b/application/Espo/Core/Utils/FieldUtil.php @@ -34,7 +34,7 @@ class FieldUtil private Metadata $metadata; /** - * @var array + * @var array> */ private $fieldByTypeListCache = []; @@ -181,6 +181,7 @@ class FieldUtil } if (!array_key_exists($type, $this->fieldByTypeListCache[$entityType])) { + /** @var array> */ $fieldDefs = $this->metadata->get(['entityDefs', $entityType, 'fields'], []); $list = []; @@ -257,6 +258,7 @@ class FieldUtil */ public function getEntityTypeFieldList(string $entityType): array { + /** @var string[] */ return array_keys($this->metadata->get(['entityDefs', $entityType, 'fields'], [])); } diff --git a/application/Espo/Core/Utils/File/ClassMap.php b/application/Espo/Core/Utils/File/ClassMap.php index 8a490be3d0..f66a08dd6d 100644 --- a/application/Espo/Core/Utils/File/ClassMap.php +++ b/application/Espo/Core/Utils/File/ClassMap.php @@ -35,7 +35,6 @@ use Espo\Core\{ Utils\Config, Utils\Module, Utils\DataCache, - Utils\Log, Utils\Module\PathProvider, }; @@ -51,8 +50,6 @@ class ClassMap private DataCache $dataCache; - private Log $log; - private PathProvider $pathProvider; public function __construct( @@ -60,14 +57,12 @@ class ClassMap Config $config, Module $module, DataCache $dataCache, - Log $log, PathProvider $pathProvider ) { $this->fileManager = $fileManager; $this->config = $config; $this->module = $module; $this->dataCache = $dataCache; - $this->log = $log; $this->pathProvider = $pathProvider; } @@ -91,11 +86,8 @@ class ClassMap $this->dataCache->has($cacheKey) && $this->config->get('useCache') ) { + /** @var array */ $data = $this->dataCache->get($cacheKey); - - if (!is_array($data)) { - $this->log->error("ClassParser: Non-array value stored in {$cacheKey}."); - } } if (is_array($data)) { @@ -150,6 +142,7 @@ class ClassMap foreach ($dirs as $dir) { if (file_exists($dir)) { + /** @var string[] */ $fileList = $this->fileManager->getFileList($dir, $subDirs, '\.php$', true); $this->fillHashFromFileList($fileList, $dir, $allowedMethods, $data); diff --git a/tests/unit/Espo/Core/Utils/File/ClassMapTest.php b/tests/unit/Espo/Core/Utils/File/ClassMapTest.php index 4c9801496b..1b981ca9d6 100644 --- a/tests/unit/Espo/Core/Utils/File/ClassMapTest.php +++ b/tests/unit/Espo/Core/Utils/File/ClassMapTest.php @@ -34,7 +34,6 @@ use tests\unit\ReflectionHelper; use Espo\Core\Utils\File\ClassMap; use Espo\Core\Utils\DataCache; use Espo\Core\Utils\File\Manager as FileManager; -use Espo\Core\Utils\Log; use Espo\Core\Utils\Config; use Espo\Core\Utils\Module; @@ -70,8 +69,6 @@ class ClassMapTest extends \PHPUnit\Framework\TestCase $this->dataCache = $this->createMock(DataCache::class); - $this->log = $this->createMock(Log::class); - $pathProvider = $this->createMock(PathProvider::class); $pathProvider @@ -103,7 +100,6 @@ class ClassMapTest extends \PHPUnit\Framework\TestCase $this->config, $this->module, $this->dataCache, - $this->log, $pathProvider );