diff --git a/app/config/services.yml b/app/config/services.yml index fc76142a9..c903a15af 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -146,9 +146,6 @@ services: autowire: true arguments: ["%qr_code_salt%"] - Afup\Site\Utils\Configuration: - autowire: true - Afup\Site\Utils\Pays: autowire: true diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 1f96be658..30c4b3e7c 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -205,66 +205,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/Afup/Pagination.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Binary operation "\\." between literal\\-string&non\\-falsy\\-string and mixed results in an error\\.$#', - 'identifier' => 'binaryOp.invalid', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'database_host\'\\|\'database_name\'\\|\'database_password\'\\|\'database_port\'\\|\'database_user\'\\|\'smtp_host\'\\|\'smtp_password\'\\|\'smtp_port\'\\|\'smtp_tls\'\\|\'smtp_username\' on 0\\|0\\.0\\|\'\'\\|\'0\'\\|array\\{\\}\\|array\\{database_host\\?\\: mixed, database_name\\?\\: mixed, database_password\\?\\: mixed, database_port\\?\\: mixed, database_user\\?\\: mixed, smtp_host\\?\\: mixed, smtp_password\\?\\: string, smtp_port\\?\\: mixed, \\.\\.\\.\\}\\|false\\|null\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'database_host\'\\|\'database_name\'\\|\'database_password\'\\|\'database_port\'\\|\'database_user\'\\|\'smtp_host\'\\|\'smtp_password\'\\|\'smtp_port\'\\|\'smtp_tls\'\\|\'smtp_username\' on 0\\|0\\.0\\|\'\'\\|\'0\'\\|array\\{\\}\\|array\\{database_host\\?\\: mixed, database_name\\?\\: mixed, database_user\\?\\: mixed, database_password\\?\\: mixed, database_port\\?\\: mixed, smtp_host\\?\\: mixed, smtp_port\\?\\: mixed, smtp_tls\\?\\: mixed, \\.\\.\\.\\}\\|false\\|null\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'parameters\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset mixed on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Afup\\\\Site\\\\Utils\\\\Configuration\\:\\:loadSymfonyParameters\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Afup\\\\Site\\\\Utils\\\\Configuration\\:\\:obtenir\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Afup\\\\Site\\\\Utils\\\\Configuration\\:\\:obtenir\\(\\) has parameter \\$cle with no type specified\\.$#', - 'identifier' => 'missingType.parameter', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property Afup\\\\Site\\\\Utils\\\\Configuration\\:\\:\\$values has no type specified\\.$#', - 'identifier' => 'missingType.property', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Configuration.php', -]; $ignoreErrors[] = [ 'message' => '#^Binary operation "\\." between mixed and \' \' results in an error\\.$#', 'identifier' => 'binaryOp.invalid', diff --git a/sources/Afup/Utils/Configuration.php b/sources/Afup/Utils/Configuration.php deleted file mode 100644 index 3a5d4a34b..000000000 --- a/sources/Afup/Utils/Configuration.php +++ /dev/null @@ -1,64 +0,0 @@ -loadSymfonyParameters(); - $parameters = [ - 'database_host', 'database_name', 'database_user', 'database_password', 'database_port', - 'smtp_host', 'smtp_port', 'smtp_tls', 'smtp_username', 'smtp_password', - ]; - - foreach ($parameters as $param) { - - // env var exist ? - if (false !== $value = getenv(strtoupper($param))) { - self::$values[$param] = $value; - } - - // override by parameter_ENV.yaml ? - if (isset($sfParameters[$param])) { - self::$values[$param] = $sfParameters[$param]; - } - } - } - - private function loadSymfonyParameters(): array - { - $parameters = []; - $basePath = __DIR__ . '/../../../app/config'; - - if (isset($_ENV['APP_ENV'])) { - $file = $basePath . '/config_' . $_ENV['APP_ENV'] . '.yml'; - if (is_file($file)) { - $values = Yaml::parseFile($file); - if (isset($values['parameters'])) { - $parameters = array_merge($parameters, $values['parameters']); - } - } - } - - return $parameters; - } - - public function obtenir($cle) - { - return self::$values[$cle] ?? null; - } -}