Merge pull request #91 from Arul-/patch-2

Fix: method validation in both send and call
This commit is contained in:
Kuan-Cheng,Lai 2018-06-14 10:18:32 +08:00 committed by GitHub
commit d0559b8c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
} }
} }
} }