From 32d0df71b2b1d8b4ff6f9d6f11865038ec137da0 Mon Sep 17 00:00:00 2001 From: Imanalopher Date: Thu, 1 Feb 2018 23:59:51 +0600 Subject: [PATCH 1/2] I think using array better than call method_exists function --- Annotation/Route.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Annotation/Route.php b/Annotation/Route.php index 5b3cbeaa..a2d1729c 100644 --- a/Annotation/Route.php +++ b/Annotation/Route.php @@ -30,6 +30,7 @@ class Route private $methods = array(); private $schemes = array(); private $condition; + private $classMethods = array(); /** * @param array $data An array of key/value parameters @@ -38,14 +39,18 @@ class Route */ public function __construct(array $data) { - if (isset($data['value'])) { + $this->classMethods = get_class_methods(__CLASS__); + + if (isset($data['value'])) + { $data['path'] = $data['value']; unset($data['value']); } - foreach ($data as $key => $value) { - $method = 'set'.str_replace('_', '', $key); - if (!method_exists($this, $method)) { + foreach ($data as $key => $value) + { + $method = 'set'.ucfirst((str_replace('_', '', $key))); + if(!in_array($method, get_class_methods(__CLASS__))) { throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, get_class($this))); } $this->$method($value); From 5d1f9961489324d57e23fc9c3302b664d1d22825 Mon Sep 17 00:00:00 2001 From: Imanalopher Date: Fri, 2 Feb 2018 00:12:38 +0600 Subject: [PATCH 2/2] Add @param --- RequestContextAwareInterface.php | 1 + 1 file changed, 1 insertion(+) diff --git a/RequestContextAwareInterface.php b/RequestContextAwareInterface.php index df5b9fcd..7a275588 100644 --- a/RequestContextAwareInterface.php +++ b/RequestContextAwareInterface.php @@ -15,6 +15,7 @@ interface RequestContextAwareInterface { /** * Sets the request context. + * @param RequestContext $context */ public function setContext(RequestContext $context);