Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Fix type juggling #2

Merged
merged 1 commit into from
Apr 25, 2018
Merged

Fix type juggling #2

merged 1 commit into from
Apr 25, 2018

Conversation

devkpv
Copy link
Contributor

@devkpv devkpv commented Apr 23, 2016

If $key is int with value 0, we have true result for condition. It's wrong.

If $key is int with value 0, we have true result for condition. It's wrong.
@@ -74,7 +74,7 @@ public function setOptions(array $options)
continue;
}

if ($key == 'jsonrpc') {
if ('jsonrpc' == $key) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do what you think it does, a fact which is made clear when you add a test with the following:

$response->setOptions([0 => '2.0']);
Assert::assertNull($response->getVersion();

The above is identical to the previous code; it just swaps the sides of the comparison. What is required is to switch to the strict equality operator, ===.

I've added a test, and updated the patch.

@weierophinney weierophinney merged commit b726b93 into zendframework:master Apr 25, 2018
weierophinney added a commit that referenced this pull request Apr 25, 2018
weierophinney added a commit that referenced this pull request Apr 25, 2018
weierophinney added a commit that referenced this pull request Apr 25, 2018
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.

2 participants