Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Yaml] Warnings emitted if configuration file is empty #44

Closed
tomzx opened this issue Jun 24, 2015 · 1 comment
Closed

[Yaml] Warnings emitted if configuration file is empty #44

tomzx opened this issue Jun 24, 2015 · 1 comment

Comments

@tomzx
Copy link
Contributor

tomzx commented Jun 24, 2015

When constructing a new Config object, if the target file is empty, the following two warnings are emitted:

Warning: array_replace_recursive(): Argument #2 is not an array in src/Config.php on line 65
Warning: array_merge(): Argument #2 src/AbstractConfig.php on line 39

$this->data = array_replace_recursive($this->data, $parser->parse($path));

$this->data = array_replace_recursive($this->data, $parser->parse($path));

This is due to the fact that the Yaml parser will return null if the file is empty (thus not an array). An "easy" fix would be to cast the result of $parser->parse($path) to an array:

$this->data = array_replace_recursive($this->data, (array)$parser->parse($path));

What do you think?

@DavidePastore
Copy link
Collaborator

Nice catch! Can you create a PR with this check (and a related test)?

DavidePastore added a commit that referenced this issue Sep 1, 2015
hassankhan added a commit that referenced this issue Jan 23, 2016
* release/0.9.0:
  Updated `CHANGELOG.md`
  Close #55. Unset cache after a set (another case)
  Close #55. Unset cache after a set
  Fixed code sniffer errors
  Added unit tests for Iterator methods and implementation as a whole
  Fixed explanation in docblocks for current and key
  AbstractConfig implements Iterator; added declaration and five needed methods
  PSR-2
  Closed #44.
  Add documentation for all method
  Add all() method to AbstractConfig.php, ConfigInterface.php and add test. Close #48.
  Fix #49.
  Remove !$temp check to fix loading an empty array
  [ci skip] Names update
  Some refactoring in `Config`
  General fixes, updated tests
  Update .gitignore
  Remove remove ùethod
  Add has and remove methods
peter279k pushed a commit to open-source-contributions/config that referenced this issue May 8, 2021
…it/phpunit-8.1.3

Bump phpunit/phpunit from 8.1.2 to 8.1.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants