-
Notifications
You must be signed in to change notification settings - Fork 129
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
Use strict comparison for onlyExpectedArguments #121
Conversation
@@ -114,7 +114,7 @@ public function verifyInvokedMultipleTimes($name, $times, $params = null) | |||
if (is_array($params)) { | |||
$equals = 0; | |||
foreach ($calls as $args) { | |||
if ($this->onlyExpectedArguments($params, $args) == $params) $equals++; | |||
if ($this->onlyExpectedArguments($params, $args) === $params) $equals++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline control structures are not allowed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
それもとからやん!!
@@ -153,7 +153,7 @@ public function verifyNeverInvoked($name, $params = null) | |||
if (empty($calls)) return; | |||
$params = ArgumentsFormatter::toString($params); | |||
foreach ($calls as $args) { | |||
if ($this->onlyExpectedArguments($params, $args) == $params) throw new fail(sprintf($this->neverInvoked, $this->className)); | |||
if ($this->onlyExpectedArguments($params, $args) === $params) throw new fail(sprintf($this->neverInvoked, $this->className)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline control structures are not allowed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
それもとからやん!!
@@ -153,7 +155,9 @@ public function verifyNeverInvoked($name, $params = null) | |||
if (empty($calls)) return; | |||
$params = ArgumentsFormatter::toString($params); | |||
foreach ($calls as $args) { | |||
if ($this->onlyExpectedArguments($params, $args) == $params) throw new fail(sprintf($this->neverInvoked, $this->className)); | |||
if ($this->onlyExpectedArguments($params, $args) === $params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line indented incorrectly; expected 16 spaces, found 17
if ($this->onlyExpectedArguments($params, $args) == $params) throw new fail(sprintf($this->neverInvoked, $this->className)); | ||
if ($this->onlyExpectedArguments($params, $args) === $params) { | ||
throw new fail(sprintf($this->neverInvoked, $this->className)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line indented incorrectly; expected 20 spaces, found 17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これも 元からやろ!!
} | ||
if (count($calls)) throw new fail(sprintf($this->neverInvoked, $this->className.$separator.$name)); | ||
if (is_array($params)) { | ||
if (empty($calls)) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline control structures are not allowed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (empty($calls)) {
return;
}
} | ||
return; | ||
} | ||
if (count($calls)) throw new fail(sprintf($this->neverInvoked, $this->className.$separator.$name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline control structures are not allowed
} | ||
if (count($calls)) throw new fail(sprintf($this->neverInvoked, $this->className.$separator.$name)); | ||
if (is_array($params)) { | ||
if (empty($calls)) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (empty($calls)) {
return;
}
指摘事項は修正済みです |
I will keep this open for a day or two to allow other contributors a chance to speak up, and to take a fresh look at it later. But at the moment it seems good to me. |
Thanks for the PR and for fixing the codestyle. |
Thank you!! 😄 |
以下の2箇所は
==
ではなく===
で比較しないと正しく無いのにテストをすり抜けるパターンが出てしまう下記は修正されているので、恐らくバグだろう
phpは0と文字列の比較は、
==
だとtrueになってしまう例えば引数の配列に0が入っていて、比較対象を文字列にした場合問題が起きる