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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.

$this->setVersion($value);
continue;
}
Expand Down