type fixes
This commit is contained in:
@@ -33,9 +33,9 @@ use Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
class Loader
|
||||
{
|
||||
private $namespaceLoader;
|
||||
private NamespaceLoader $namespaceLoader;
|
||||
|
||||
private $fileManager;
|
||||
private FileManager $fileManager;
|
||||
|
||||
public function __construct(NamespaceLoader $namespaceLoader, FileManager $fileManager)
|
||||
{
|
||||
@@ -43,6 +43,16 @@ class Loader
|
||||
$this->fileManager = $fileManager;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array{
|
||||
* psr-4?: array<string,mixed>,
|
||||
* psr-0?: array<string,mixed>,
|
||||
* classmap?: array<string,mixed>,
|
||||
* autoloadFileList?: array<string,mixed>,
|
||||
* files?: array<string,mixed>,
|
||||
* } $data
|
||||
*/
|
||||
public function register(array $data): void
|
||||
{
|
||||
/* load "psr-4", "psr-0", "classmap" */
|
||||
@@ -55,6 +65,9 @@ class Loader
|
||||
$this->registerFiles($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $data
|
||||
*/
|
||||
private function registerAutoloadFileList(array $data): void
|
||||
{
|
||||
$keyName = 'autoloadFileList';
|
||||
@@ -70,6 +83,9 @@ class Loader
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $data
|
||||
*/
|
||||
private function registerFiles(array $data): void
|
||||
{
|
||||
$keyName = 'files';
|
||||
|
||||
@@ -43,34 +43,50 @@ use Throwable;
|
||||
|
||||
class NamespaceLoader
|
||||
{
|
||||
private $classLoader;
|
||||
/**
|
||||
* @var ?array{
|
||||
* psr-4?: array<string,mixed>,
|
||||
* psr-0?: array<string,mixed>,
|
||||
* classmap?: array<string,mixed>,
|
||||
* }
|
||||
*/
|
||||
private $namespaces = null;
|
||||
|
||||
private $namespaces;
|
||||
/**
|
||||
* @var ?array<string,mixed>
|
||||
*/
|
||||
private $vendorNamespaces = null;
|
||||
|
||||
private $autoloadFilePath = 'vendor/autoload.php';
|
||||
private string $autoloadFilePath = 'vendor/autoload.php';
|
||||
|
||||
/**
|
||||
* @var array<string,string>
|
||||
*/
|
||||
private $namespacesPaths = [
|
||||
'psr-4' => 'vendor/composer/autoload_psr4.php',
|
||||
'psr-0' => 'vendor/composer/autoload_namespaces.php',
|
||||
'classmap' => 'vendor/composer/autoload_classmap.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string,string>
|
||||
*/
|
||||
private $methodNameMap = [
|
||||
'psr-4' => 'addPsr4',
|
||||
'psr-0' => 'add',
|
||||
];
|
||||
|
||||
private $vendorNamespaces;
|
||||
private string $cacheKey = 'autoloadVendorNamespaces';
|
||||
|
||||
private $cacheKey = 'autoloadVendorNamespaces';
|
||||
private ClassLoader $classLoader;
|
||||
|
||||
private $config;
|
||||
private Config $config;
|
||||
|
||||
private $dataCache;
|
||||
private DataCache $dataCache;
|
||||
|
||||
private $fileManager;
|
||||
private FileManager $fileManager;
|
||||
|
||||
private $log;
|
||||
private Log $log;
|
||||
|
||||
public function __construct(Config $config, DataCache $dataCache, FileManager $fileManager, Log $log)
|
||||
{
|
||||
@@ -82,6 +98,12 @@ class NamespaceLoader
|
||||
$this->classLoader = new ClassLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{
|
||||
* psr-4?: array<string,mixed>,
|
||||
* psr-0?: array<string,mixed>
|
||||
* } $data
|
||||
*/
|
||||
public function register(array $data): void
|
||||
{
|
||||
$this->addListToClassLoader($data);
|
||||
@@ -89,6 +111,13 @@ class NamespaceLoader
|
||||
$this->classLoader->register(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* psr-4?: array<string,mixed>,
|
||||
* psr-0?: array<string,mixed>,
|
||||
* classmap?: array<string,mixed>,
|
||||
* }
|
||||
*/
|
||||
private function loadNamespaces(string $basePath = ''): array
|
||||
{
|
||||
$namespaces = [];
|
||||
@@ -110,6 +139,14 @@ class NamespaceLoader
|
||||
return $namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array{
|
||||
* psr-4?: array<string,mixed>,
|
||||
* psr-0?: array<string,mixed>,
|
||||
* classmap?: array<string,mixed>,
|
||||
* }
|
||||
*/
|
||||
private function getNamespaces(): array
|
||||
{
|
||||
if (!$this->namespaces) {
|
||||
@@ -119,6 +156,9 @@ class NamespaceLoader
|
||||
return $this->namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function getNamespaceList(string $type): array
|
||||
{
|
||||
$namespaces = $this->getNamespaces();
|
||||
@@ -126,6 +166,9 @@ class NamespaceLoader
|
||||
return array_keys($namespaces[$type]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array<string,string> $path
|
||||
*/
|
||||
private function addNamespace(string $type, string $name, $path): void
|
||||
{
|
||||
if (!$this->namespaces) {
|
||||
@@ -152,6 +195,9 @@ class NamespaceLoader
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $data
|
||||
*/
|
||||
private function addListToClassLoader(array $data, bool $skipVendorNamespaces = false): void
|
||||
{
|
||||
foreach ($this->methodNameMap as $type => $methodName) {
|
||||
@@ -192,6 +238,9 @@ class NamespaceLoader
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
private function getVendorNamespaces(string $path): array
|
||||
{
|
||||
$useCache = $this->config->get('useCache');
|
||||
|
||||
@@ -38,8 +38,11 @@ use Espo\Core\Utils\File\ClassMap;
|
||||
*/
|
||||
class ClassFinder
|
||||
{
|
||||
private $classMap;
|
||||
private ClassMap $classMap;
|
||||
|
||||
/**
|
||||
* @var array<string,array<string,class-string>>
|
||||
*/
|
||||
private $dataHashMap = [];
|
||||
|
||||
public function __construct(ClassMap $classMap)
|
||||
|
||||
@@ -44,6 +44,9 @@ class ActionRenderer
|
||||
$this->clientManager = $clientManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?array<string,mixed> $data
|
||||
*/
|
||||
public function render(string $controller, string $action, ?array $data = null): string
|
||||
{
|
||||
$encodedData = Json::encode($data);
|
||||
|
||||
@@ -29,16 +29,14 @@
|
||||
|
||||
namespace Espo\Core\Utils\Client;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\File\Manager as FileManager,
|
||||
};
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
/**
|
||||
* @internal Also used by the installer w/o DI.
|
||||
*/
|
||||
class DevModeJsFileListProvider
|
||||
{
|
||||
private $fileManager;
|
||||
private FileManager $fileManager;
|
||||
|
||||
private const LIBS_FILE = 'frontend/libs.json';
|
||||
|
||||
@@ -78,6 +76,10 @@ class DevModeJsFileListProvider
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \stdClass[] $items
|
||||
* @return string[]
|
||||
*/
|
||||
private function getLibFileListFromItems(array $items): array
|
||||
{
|
||||
$list = [];
|
||||
|
||||
@@ -41,25 +41,25 @@ use Espo\Core\{
|
||||
*/
|
||||
class ClientManager
|
||||
{
|
||||
protected $mainHtmlFilePath = 'html/main.html';
|
||||
protected string $mainHtmlFilePath = 'html/main.html';
|
||||
|
||||
protected $runScript = "app.start();";
|
||||
protected string $runScript = "app.start();";
|
||||
|
||||
private $basePath = '';
|
||||
private string $basePath = '';
|
||||
|
||||
private $libsConfigPath = 'client/cfg/libs.json';
|
||||
private string $libsConfigPath = 'client/cfg/libs.json';
|
||||
|
||||
private $themeManager;
|
||||
private Config $config;
|
||||
|
||||
private $config;
|
||||
private ThemeManager $themeManager;
|
||||
|
||||
private $metadata;
|
||||
private Metadata $metadata;
|
||||
|
||||
private $fileManager;
|
||||
private FileManager $fileManager;
|
||||
|
||||
private $devModeJsFileListProvider;
|
||||
private DevModeJsFileListProvider $devModeJsFileListProvider;
|
||||
|
||||
private $module;
|
||||
private Module $module;
|
||||
|
||||
private const APP_DESCRIPTION = "EspoCRM - Open Source CRM application.";
|
||||
|
||||
@@ -98,11 +98,17 @@ class ClientManager
|
||||
return $this->config->get('cacheTimestamp', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $vars
|
||||
*/
|
||||
public function display(?string $runScript = null, ?string $htmlFilePath = null, array $vars = []): void
|
||||
{
|
||||
echo $this->render($runScript, $htmlFilePath, $vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $vars
|
||||
*/
|
||||
public function render(?string $runScript = null, ?string $htmlFilePath = null, array $vars = []): string
|
||||
{
|
||||
if (is_null($runScript)) {
|
||||
|
||||
Reference in New Issue
Block a user