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

testing nested key ->has on unmatched structure #159

Open
krills opened this issue Mar 1, 2023 · 0 comments · May be fixed by #160
Open

testing nested key ->has on unmatched structure #159

krills opened this issue Mar 1, 2023 · 0 comments · May be fixed by #160
Labels

Comments

@krills
Copy link

krills commented Mar 1, 2023

Assuming a config like
{"foo": "bar"}
Testing
$config->has('foo.bar.baz')
will throw PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, string given in /.../vendor/hassankhan/config/src/AbstractConfig.php:127

A simple fix to make has() return expected false in this case could be to add is_array($root) && .. before running the array_key_exists($segment, $root) statement

omniError added a commit to omniError/config that referenced this issue Mar 10, 2023
@omniError omniError linked a pull request Mar 10, 2023 that will close this issue
@DavidePastore DavidePastore added this to the future-release milestone Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants