Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tysonphillips
Copy link
Member

…at implement the magic methods __call or __callStatic
Fixes #23

…at implement the magic methods __call or __callStatic
# see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/275
#
/*
$magicController = $this->getMockBuilder('Controller')
Copy link
Contributor

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])) {
Copy link
Contributor

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) {
Copy link
Contributor

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;
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

===?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants