type fixes

This commit is contained in:
Yuri Kuznetsov
2022-03-17 13:42:20 +02:00
parent d39376398a
commit cc89b69f18
3 changed files with 5 additions and 14 deletions
+3 -1
View File
@@ -34,7 +34,7 @@ class FieldUtil
private Metadata $metadata;
/**
* @var array<string,string[]>
* @var array<string,array<string,string[]>>
*/
private $fieldByTypeListCache = [];
@@ -181,6 +181,7 @@ class FieldUtil
}
if (!array_key_exists($type, $this->fieldByTypeListCache[$entityType])) {
/** @var array<string,array<string,mixed>> */
$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'], []));
}
@@ -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<string,class-string> */
$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);
@@ -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
);