From 58f819aeb9e845932bb1ed1f0259d512a981e9d8 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 4 Oct 2024 12:54:59 +0300 Subject: [PATCH] docs, cs --- install/core/Installer.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/install/core/Installer.php b/install/core/Installer.php index af215e5aec..46e0d4d3e4 100644 --- a/install/core/Installer.php +++ b/install/core/Installer.php @@ -27,9 +27,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ +use Doctrine\DBAL\Exception as DBALException; use Espo\Core\Application; use Espo\Core\Container; use Espo\Core\DataManager; +use Espo\Core\Exceptions\Error; use Espo\Core\InjectableFactory; use Espo\Core\ORM\DatabaseParamsFactory; use Espo\Core\Utils\Database\ConfigDataProvider; @@ -319,6 +321,10 @@ class Installer return $systemRequirementManager->getRequiredListByType($type, $requiredOnly, $additionalData); } + /** + * @throws DBALException + * @throws Exception + */ public function checkDatabaseConnection(array $rawParams, bool $createDatabase = false): void { $params = $this->databaseParamsFactory->createWithMergedAssoc($rawParams); @@ -336,6 +342,7 @@ class Installer throw $e; } + /** @noinspection RegExpRedundantEscape */ if ($dbname !== preg_replace('/[^A-Za-z0-9_\-@$#\(\)]+/', '', $dbname)) { throw new Exception("Bad database name."); } @@ -355,7 +362,7 @@ class Installer $schemaManager->createDatabase($platform->quoteIdentifier($dbname)); - $this->checkDatabaseConnection($rawParams, false); + $this->checkDatabaseConnection($rawParams); } } @@ -363,13 +370,13 @@ class Installer * Save data. * * @param array $saveData - * array( - * 'driver' => 'pdo_mysql', - * 'host' => 'localhost', - * 'dbname' => 'espocrm_test', - * 'user' => 'root', - * 'password' => '', - * ) + * [ + * 'driver' => 'pdo_mysql', + * 'host' => 'localhost', + * 'dbname' => 'espocrm_test', + * 'user' => 'root', + * 'password' => '', + * ] * @return bool */ public function saveData(array $saveData) @@ -425,6 +432,9 @@ class Installer return true; } + /** + * @throws Error + */ public function rebuild(): void { try { @@ -644,11 +654,6 @@ class Installer $paramType = $paramDefs['type'] ?? 'varchar'; switch ($paramType) { - case 'enumInt': - $normalizedParams[$name] = (int) $value;; - - break; - case 'enum': if ( isset($paramDefs['options']) && array_key_exists($value, $paramDefs['options']) || @@ -672,6 +677,7 @@ class Installer break; case 'int': + case 'enumInt': $normalizedParams[$name] = (int) $value; break;