diff options
| author | 2023-04-17 08:30:21 +0200 | |
|---|---|---|
| committer | 2023-04-17 08:30:21 +0200 | |
| commit | f3760f138dcbaf7a2190336a0378cf1b2190c9f5 (patch) | |
| tree | 6fac8fbf9efd7aa74a8e3970ab70ccf85287b2cd /lib/Minz/Configuration.php | |
| parent | 41fa4e746df8c2e2399ed753b4994ca85cb21358 (diff) | |
Complete PHPStan Level 6 (#5305)
* Complete PHPStan Level 6
Fix https://github.com/FreshRSS/FreshRSS/issues/4112
And initiate PHPStan Level 7
* PHPStan Level 6 for tests
* Use phpstan/phpstan-phpunit
* Update to PHPStan version 1.10
* Fix mixed bug
* Fix mixed return bug
* Fix paginator bug
* Fix FreshRSS_UserConfiguration
* A couple more Minz_Configuration bug fixes
* A few trivial PHPStan Level 7 fixes
* A few more simple PHPStan Level 7
* More files passing PHPStan Level 7
Add interface to replace removed class from https://github.com/FreshRSS/FreshRSS/pull/5251
* A few more PHPStan Level 7 preparations
* A few last details
Diffstat (limited to 'lib/Minz/Configuration.php')
| -rw-r--r-- | lib/Minz/Configuration.php | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 4259c4052..d641d8994 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -3,7 +3,8 @@ /** * Manage configuration for the application. * @property-read string $base_url - * @property array<string|array<int,string>> $db + * @property array{'type'?:string,'host'?:string,'user'?:string,'password'?:string,'base'?:string,'prefix'?:string, + * 'connection_uri_params'?:string,'pdo_options'?:array<string|int,string|int|bool>} $db * @property-read string $disable_update * @property-read string $environment * @property array<string,bool> $extensions_enabled @@ -24,9 +25,10 @@ class Minz_Configuration { * @param string $namespace the name of the current configuration * @param string $config_filename the filename of the configuration * @param string $default_filename a filename containing default values for the configuration - * @param object $configuration_setter an optional helper to set values in configuration + * @param Minz_ConfigurationSetterInterface $configuration_setter an optional helper to set values in configuration */ - public static function register(string $namespace, string $config_filename, string $default_filename = null, object $configuration_setter = null): void { + public static function register(string $namespace, string $config_filename, string $default_filename = null, + Minz_ConfigurationSetterInterface $configuration_setter = null): void { self::$config_list[$namespace] = new static( $namespace, $config_filename, $default_filename, $configuration_setter ); @@ -92,9 +94,9 @@ class Minz_Configuration { /** * An object which help to set good values in configuration. - * @var object|null + * @var Minz_ConfigurationSetterInterface|null */ - private $configuration_setter = null; + private $configuration_setter; /** * Create a new Minz_Configuration object. @@ -102,9 +104,10 @@ class Minz_Configuration { * @param string $namespace the name of the current configuration. * @param string $config_filename the file containing configuration values. * @param string $default_filename the file containing default values, null by default. - * @param object $configuration_setter an optional helper to set values in configuration + * @param Minz_ConfigurationSetterInterface $configuration_setter an optional helper to set values in configuration */ - private final function __construct(string $namespace, string $config_filename, string $default_filename = null, object $configuration_setter = null) { + private final function __construct(string $namespace, string $config_filename, string $default_filename = null, + Minz_ConfigurationSetterInterface $configuration_setter = null) { $this->namespace = $namespace; $this->config_filename = $config_filename; $this->default_filename = $default_filename; @@ -127,16 +130,15 @@ class Minz_Configuration { /** * Set a configuration setter for the current configuration. - * @param object|null $configuration_setter the setter to call when modifying data. It - * must implement an handle($key, $value) method. + * @param Minz_ConfigurationSetterInterface|null $configuration_setter the setter to call when modifying data. */ - public function _configurationSetter(?object $configuration_setter): void { + public function _configurationSetter(?Minz_ConfigurationSetterInterface $configuration_setter): void { if (is_callable(array($configuration_setter, 'handle'))) { $this->configuration_setter = $configuration_setter; } } - public function configurationSetter(): object { + public function configurationSetter(): ?Minz_ConfigurationSetterInterface { return $this->configuration_setter; } @@ -181,11 +183,11 @@ class Minz_Configuration { * @param mixed $value the value to set. If null, the key is removed from the configuration. */ public function _param(string $key, $value = null): void { - if (!is_null($this->configuration_setter) && $this->configuration_setter->support($key)) { + if ($this->configuration_setter !== null && $this->configuration_setter->support($key)) { $this->configuration_setter->handle($this->data, $key, $value); } elseif (isset($this->data[$key]) && is_null($value)) { unset($this->data[$key]); - } elseif (!is_null($value)) { + } elseif ($value !== null) { $this->data[$key] = $value; } } |
