diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 6077d60..4d4da05 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php-versions: ['7.4', '8.0', '8.1', '8.2'] + php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} steps: - uses: actions/checkout@v3 @@ -33,4 +33,4 @@ jobs: - name: Upload code coverage data if: ${{ matrix.php-versions == '7.4' }} - run: php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover \ No newline at end of file + run: php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover diff --git a/CHANGELOG.md b/CHANGELOG.md index f04acd0..6029a6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to `Config` will be documented in this file +## 3.2.0 - 2024-12-09 + +### Added +* PHP 8.3 and 8.4 to the build matrix (#164) + +### Fixed +* Fatal error when root is null in has() method (#159 and #160) +* PHP 8.4 deprecations implicitly marking parameter as nullable is deprecated (#163) + + ## 3.1.0 - 2022-12-20 ### Added diff --git a/src/AbstractConfig.php b/src/AbstractConfig.php index 5932eda..340ddf4 100644 --- a/src/AbstractConfig.php +++ b/src/AbstractConfig.php @@ -123,7 +123,7 @@ public function has($key) // nested case foreach ($segments as $segment) { - if (array_key_exists($segment, $root)) { + if (is_array($root) && array_key_exists($segment, $root)) { $root = $root[$segment]; continue; } else { diff --git a/src/Config.php b/src/Config.php index 8838e44..dad3b67 100644 --- a/src/Config.php +++ b/src/Config.php @@ -67,10 +67,10 @@ public static function load($values, $parser = null, $string = false) * Loads a Config instance. * * @param string|array $values Filenames or string with configuration - * @param ParserInterface $parser Configuration parser + * @param ?ParserInterface $parser Configuration parser * @param bool $string Enable loading from string */ - public function __construct($values, ParserInterface $parser = null, $string = false) + public function __construct($values, ?ParserInterface $parser = null, $string = false) { if ($string === true) { $this->loadFromString($values, $parser); @@ -85,11 +85,11 @@ public function __construct($values, ParserInterface $parser = null, $string = f * Loads configuration from file. * * @param string|array $path Filenames or directories with configuration - * @param ParserInterface $parser Configuration parser + * @param ?ParserInterface $parser Configuration parser * * @throws EmptyDirectoryException If `$path` is an empty directory */ - protected function loadFromFile($path, ParserInterface $parser = null) + protected function loadFromFile($path, ?ParserInterface $parser = null) { $paths = $this->getValidPath($path); $this->data = []; @@ -125,11 +125,11 @@ protected function loadFromFile($path, ParserInterface $parser = null) * Writes configuration to file. * * @param string $filename Filename to save configuration to - * @param WriterInterface $writer Configuration writer + * @param ?WriterInterface $writer Configuration writer * * @throws WriteException if the data could not be written to the file */ - public function toFile($filename, WriterInterface $writer = null) + public function toFile($filename, ?WriterInterface $writer = null) { if ($writer === null) { // Get file information diff --git a/tests/AbstractConfigTest.php b/tests/AbstractConfigTest.php index 551d246..e0fe945 100644 --- a/tests/AbstractConfigTest.php +++ b/tests/AbstractConfigTest.php @@ -247,6 +247,7 @@ public function testHasNestedKey() $this->assertTrue($this->config->has('application.runtime')); $this->assertFalse($this->config->has('application.not_exist')); $this->assertFalse($this->config->has('not_exist.name')); + $this->assertFalse($this->config->has('application.name.not_exist')); } /**