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

Cleanup CallableResolver #2110

Merged
merged 4 commits into from Mar 18, 2017
Merged

Cleanup CallableResolver #2110

merged 4 commits into from Mar 18, 2017

Conversation

ghost
Copy link

@ghost ghost commented Dec 20, 2016

Hi There,

I was taking a look at the Callable Resolver and I've noticed how the indentation levels were nested and all coupled into one single method. I've also noticed how some checks and logic were
intrinsically structured.
Moreover the callable pattern, even though is not used anywhere else I think it's better to have it as a constant, since it's never going to change.
I've run the unit tests. Hope it's opened for discussions, glad to have your positive or negative feedback, thanks!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 97.862% when pulling 6ccc229 on 0x13a:feature-refactor-callable-resolver into 50f3eef on slimphp:3.x.

@ghost
Copy link
Author

ghost commented Jan 25, 2017

gotta add full test coverage

@ghost ghost closed this Jan 25, 2017
@akrabat
Copy link
Member

akrabat commented Jan 25, 2017

You can simply add to this branch and as you push, it'll re-run the CI tests

@ghost
Copy link
Author

ghost commented Jan 25, 2017

@akrabat yes thanks I know. Just wanted to keep the PR list clean, as it will take some time, before I can work on it. I will reopen it soon

@ghost ghost changed the title Refactor CallableResolver proposal Cleanup CallableResolver Jan 25, 2017
@ghost ghost reopened this Jan 25, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 97.862% when pulling fb96f3b on 0x13a:feature-refactor-callable-resolver into fb5356a on slimphp:3.x.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 97.862% when pulling 9000597 on 0x13a:feature-refactor-callable-resolver into fb5356a on slimphp:3.x.

@ghost ghost changed the title Cleanup CallableResolver [WIP] Cleanup CallableResolver Jan 25, 2017
@ghost
Copy link
Author

ghost commented Jan 30, 2017

The un-covered line here it seems to be like a dead code, and moreover it's not appearing on my local phpunit 4.8.33 running with PHP7 7.0.14, where I've 100% code coverage for the Slim Callable Resolver. Any ideas ?

protected function resolveCallable($class, $method = '__invoke')
{
if ($this->container->has($class)) {
return [$this->container->get($class), $method];
Copy link
Member

Choose a reason for hiding this comment

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

This changes the behaviour from the current code.

At the moment, when there isn't a method specified, we return the class object and let PHP resolve to __invoke. This code explicitly returns an array with the second parameter as "__invoke".

Are there any implications as a result of this change?

Copy link
Author

Choose a reason for hiding this comment

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

Hey,
I don’t think it’s going to affect the behaviour, since as we must return a valid callback, when a method is not provided, the class must be invokable.
Given that, we return a callable defined as array which has at index 0 the class and index 1 the method to be invoked, which we explicitly define to be __invoke’ https://3v4l.org/Uvj29

I’m going to test it deeply, but I’d say wouldn’t be an issue, isn’t it? :)

Copy link
Member

Choose a reason for hiding this comment

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

Double check performance too.

Copy link
Author

Choose a reason for hiding this comment

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

do you have any benchmark suite ?

Copy link
Member

Choose a reason for hiding this comment

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

I've asked around and general view is that it won't make any difference.

@akrabat
Copy link
Member

akrabat commented Feb 6, 2017

The un-covered line here it seems to be like a dead code, and moreover it's not appearing on my local phpunit 4.8.33 running with PHP7 7.0.14, where I've 100% code coverage for the Slim Callable Resolver. Any ideas ?

I can't see why that closing } is shown as not covered.

@akrabat akrabat self-assigned this Feb 6, 2017
@akrabat akrabat merged commit 9000597 into slimphp:3.x Mar 18, 2017
@akrabat akrabat added this to the 3.8.0 milestone Mar 18, 2017
@akrabat
Copy link
Member

akrabat commented Mar 18, 2017

Thanks.
It may be worth looking at the equivalent in 4.x and seeing if that can also be improved.

@akrabat akrabat changed the title [WIP] Cleanup CallableResolver Cleanup CallableResolver Mar 18, 2017
@ghost
Copy link
Author

ghost commented Mar 19, 2017

@akrabat someone already made some refactoring #2157

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