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

get_in fails when a key in the path has a value other than array #97

Open
davidPaymefy opened this issue Aug 20, 2024 · 0 comments
Open

Comments

@davidPaymefy
Copy link

davidPaymefy commented Aug 20, 2024

I believe get_in is all about safe navigation and this case should return the default value instead of failing with a TypeError.

$user = [
            'username' => 'Peter',
            'profile'  => null,
        ];

$this->assertSame('fakepass', get_in(['profile', 'password'], $user, 'fakepass'));

PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in

@davidPaymefy davidPaymefy changed the title get_in fails when value for a non final key is not an array get_in fails when a key in the path has a value other than array Aug 20, 2024
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

1 participant