-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated the router and dispatcher to accept routing to controllers th… #24
base: master
Are you sure you want to change the base?
Conversation
…at implement the magic methods __call or __callStatic
# see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/275 | ||
# | ||
/* | ||
$magicController = $this->getMockBuilder('Controller') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not create a test controller that uses magic methods and assert it works as example expected?
@@ -138,7 +138,7 @@ public static function dispatch($requestUri, $isCli = false) | |||
} | |||
|
|||
$result = null; | |||
if (method_exists($ctrl, $action)) { | |||
if (method_exists($ctrl, $action) || is_callable([$ctrl, $action])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it makes sense to just use 'is_callable'? Seems like that covers method_exists.
|| $reflectedObj->isSubclassOf($inheritsFrom) | ||
) | ||
); | ||
} catch (Exception $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What Exception instance is possible here? Should probably catch the most specific avalable.
@@ -218,6 +243,8 @@ public static function isCallable($obj, $method, $inheritsFrom = 'Controller') | |||
return true; | |||
} catch (ReflectionException $e) { | |||
return false; | |||
} catch (Exception $e) { | |||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what this catch adds.
&& !in_array(strtolower($method), $publicUncallables) | ||
&& ( | ||
$inheritsFrom === null | ||
|| $reflectedObj->getName() == $inheritsFrom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
===?
…at implement the magic methods __call or __callStatic
Fixes #23