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

Piwik\Plugins\UserCountry\LocationProvider::getProviderById should return Object or false #8153

Closed
sebastianpiskorski opened this issue Jun 19, 2015 · 2 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@sebastianpiskorski
Copy link
Contributor

I think that returning Object or false in one method might be misleading since php allow to call method directly after earlier call without assigning result to variable like this LocationProvider::getCurrentProvider()->getInfo();

@mattab
Copy link
Member

mattab commented Jun 22, 2015

since php allow to call method directly after earlier call without assigning result to variable like this

PHP allows to call in this way, but it does not mean one should do it. One should check the instance is set before calling methods on an object instance. I guess getCurrentProvider should return null instead of false. What would you suggest instead? I guess throwing exception would be an alternative. since there is no real value to developer or user to change this at this stage, closing

@mattab mattab closed this as completed Jun 22, 2015
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Jun 22, 2015
@sebastianpiskorski
Copy link
Contributor Author

I think that throwing Exception would be proper solution here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

2 participants