From 3d8a567054e1b3201603a632d9ea3d2bb6d40c1e Mon Sep 17 00:00:00 2001 From: Arul Date: Thu, 7 Jun 2018 18:02:08 +0800 Subject: [PATCH] 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) --- src/Contract.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Contract.php b/src/Contract.php index b6c334a9..794da74d 100644 --- a/src/Contract.php +++ b/src/Contract.php @@ -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]; @@ -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]; @@ -621,4 +621,4 @@ public function getData() return $functionData; } } -} \ No newline at end of file +}