Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

strict comparison for getting array value by key #45

Merged
merged 1 commit into from
May 17, 2019

Conversation

sethphillips
Copy link
Contributor

When getting errors, loose equality sometimes matches the 0 index of the array of errors and not the nested 'Errors' key. This results in an index 'Number' not found exception on $this->setErrorCode($errorInfo['Number']);

When getting errors, loose equality sometimes matches the 0 index of the array of errors and not the nested 'Errors' key.  This results in an index 'Number' not found exception on `$this->setErrorCode($errorInfo['Number']);`
@denizozsen
Copy link

+1 from me for this change! I was about to create a pull request for the same issue.

@denizozsen
Copy link

@sethphillips @VinceG While not strictly necessary, I would also suggest to use a strict equality check in line 439, to allow for fetching falsy values like 0, false, empty array, etc. I know this is not used right now, but could cause some head scratching in the future.

I.e. this:

        if ($return = $this->getValueByKey($each, $key)) {
            return $return;
        }

would become this:

        $return = $this->getValueByKey($each, $key);
        if ($return !== null) {
            return $return;
        }

@VinceG VinceG merged commit 134b73f into VinceG:master May 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants