Fix: method validation in both send and call
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)
This commit is contained in:
parent
be7403a00b
commit
3d8a567054
@ -422,8 +422,8 @@ class Contract
|
|||||||
$method = array_splice($arguments, 0, 1)[0];
|
$method = array_splice($arguments, 0, 1)[0];
|
||||||
$callback = array_pop($arguments);
|
$callback = array_pop($arguments);
|
||||||
|
|
||||||
if (!is_string($method) && !isset($this->functions[$method])) {
|
if (!is_string($method) || !isset($this->functions[$method])) {
|
||||||
throw new InvalidArgumentException('Please make sure the method is existed.');
|
throw new InvalidArgumentException('Please make sure the method exists.');
|
||||||
}
|
}
|
||||||
$function = $this->functions[$method];
|
$function = $this->functions[$method];
|
||||||
|
|
||||||
@ -468,8 +468,8 @@ class Contract
|
|||||||
$method = array_splice($arguments, 0, 1)[0];
|
$method = array_splice($arguments, 0, 1)[0];
|
||||||
$callback = array_pop($arguments);
|
$callback = array_pop($arguments);
|
||||||
|
|
||||||
if (!is_string($method) && !isset($this->functions[$method])) {
|
if (!is_string($method) || !isset($this->functions[$method])) {
|
||||||
throw new InvalidArgumentException('Please make sure the method is existed.');
|
throw new InvalidArgumentException('Please make sure the method exists.');
|
||||||
}
|
}
|
||||||
$function = $this->functions[$method];
|
$function = $this->functions[$method];
|
||||||
|
|
||||||
@ -621,4 +621,4 @@ class Contract
|
|||||||
return $functionData;
|
return $functionData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user