Skip to content

Commit

Permalink
Fix: method validation in both send and call
Browse files Browse the repository at this point in the history
Making sure method is a string and it exists under functions

I was trying to call a nonexistent method. Since I passed a string it went through without checking if it exists as a function or not

This commit fixes that by changing `&&` to `||` (or)
  • Loading branch information
Arul- authored Jun 7, 2018
1 parent be7403a commit 3d8a567
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Contract.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ public function send()
$method = array_splice($arguments, 0, 1)[0];
$callback = array_pop($arguments);

if (!is_string($method) && !isset($this->functions[$method])) {
throw new InvalidArgumentException('Please make sure the method is existed.');
if (!is_string($method) || !isset($this->functions[$method])) {
throw new InvalidArgumentException('Please make sure the method exists.');
}
$function = $this->functions[$method];

Expand Down Expand Up @@ -468,8 +468,8 @@ public function call()
$method = array_splice($arguments, 0, 1)[0];
$callback = array_pop($arguments);

if (!is_string($method) && !isset($this->functions[$method])) {
throw new InvalidArgumentException('Please make sure the method is existed.');
if (!is_string($method) || !isset($this->functions[$method])) {
throw new InvalidArgumentException('Please make sure the method exists.');
}
$function = $this->functions[$method];

Expand Down Expand Up @@ -621,4 +621,4 @@ public function getData()
return $functionData;
}
}
}
}

0 comments on commit 3d8a567

Please sign in to comment.