★ wanayoo — archive 1999 https://github.com/slimphp/Slim/pull/2110Nouvelle recherche | Portail wanayoo
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

@coveralls coveralls commented Dec 20, 2016

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 ghost commented Jan 25, 2017

gotta add full test coverage

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

@akrabat 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 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

…s://github.com/0x13a/Slim into feature-refactor-callable-resolver
@ghost ghost changed the title Refactor CallableResolver proposal Cleanup CallableResolver Jan 25, 2017
@ghost ghost reopened this Jan 25, 2017
@coveralls
Copy link

@coveralls coveralls commented Jan 25, 2017

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

@coveralls coveralls commented Jan 25, 2017

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 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];

This comment has been minimized.

@akrabat

akrabat Feb 6, 2017
Member

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?

This comment has been minimized.

@ghost

ghost Feb 7, 2017
Author

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? :)

This comment has been minimized.

@akrabat

akrabat Feb 7, 2017
Member

Double check performance too.

This comment has been minimized.

@ghost

ghost Feb 7, 2017
Author

do you have any benchmark suite ?

This comment has been minimized.

@akrabat

akrabat Feb 7, 2017
Member

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

@akrabat
Copy link
Member

@akrabat 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
2 of 3 checks passed
2 of 3 checks passed
coverage/coveralls Coverage decreased (-0.07%) to 97.862%
Details
Scrutinizer 3 updated code elements
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
akrabat added a commit that referenced this pull request Mar 18, 2017
@akrabat akrabat added this to the 3.8.0 milestone Mar 18, 2017
@akrabat
Copy link
Member

@akrabat 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 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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants