Skip to content

Conversation

@nayzo
Copy link

@nayzo nayzo commented Oct 1, 2020

No description provided.

@nayzo
Copy link
Author

nayzo commented Oct 1, 2020

Hello @minwork
Could you merge this fix and tag a new release please ?

@minwork
Copy link
Owner

minwork commented Oct 4, 2020

Hello,

thanks for the PR. Could you post an example when has is not behaving as expected which is the reason for those changes?
Also this case needs to be added to the tests to ensure it is handled correctly in the next versions.

@nayzo
Copy link
Author

nayzo commented Oct 4, 2020

Hello,

Sure here's an example:

$array = array('content' => 'some message!');

Arr::has($array, 'content.foo')

==> Warning: array_key_exists() expects parameter 2 to be array, string given

More details with a try catch:

foreach ($keysArray as $key) {
            try {
                if (!array_key_exists($key, $tmp)) {
                    return false;
                }
            } catch (\Exception $e) {
                var_dump($e->getMessage(), $key, $tmp, $keysArray);die;
            }
            $tmp = $tmp[$key];
        }

==>  "Warning: array_key_exists() expects parameter 2 to be array, string given" 
"foo" 
"some message!" 
{ [0]=> "content" [1]=> "foo" }

Hope it's more clear now.
Thanks.

@minwork
Copy link
Owner

minwork commented Oct 4, 2020

@nayzo Thanks for the example, resolved by #3

@nayzo
Copy link
Author

nayzo commented Oct 5, 2020

Could you tag a new Release ?

@minwork
Copy link
Owner

minwork commented Oct 5, 2020 via email

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

Successfully merging this pull request may close these issues.

2 participants