-
Notifications
You must be signed in to change notification settings - Fork 523
Refactor providers to leverage ResultFactories - fix #232 #233
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
Refactor providers to leverage ResultFactories - fix #232 #233
Conversation
Looks good to me. One question though, should I consider this as a BC break? Or people don't use providers in a standalone way? |
When all providers will be rewritten, they will return all results so |
well, I won't bump a new major release just for fun. I was talking about using providers without the result factories, which could be a BC break in that case. |
Oh yes I see now. I never used providers without factories. Well, in this case, it will be a BC break ! |
@willdurand @baashi All providers are rewitten (except YahooProvider see #230). Tests are also updated. I just ran the test suite. Some tests are skipped or incomplete:
|
Alright, so let's remove the Yahoo provider first. The maxromanovsky/php-maxmind-geoip lib is annoying. If they don't fix their stuff by using |
I think one commit would be enough btw. |
I agree it's annoying :( Ok I'll remove YahooProvider and squash commits. |
@toin0u make a commit for the providers, and another one for the Yahoo provider removal |
@willdurand Rebased and squashed :) And there is an other PR for Yahoo provider. |
Test is fixed by #237 |
} else { | ||
$data = $json->geonames; | ||
|
||
if (!isset($data) || empty($data)) { |
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.
isset
isn't needed here.
Thanks for the review :) I'm not able to fix it right now, I'll do it tonight I think. |
No problem. Thanks for the PR and your awesome work 👍 |
Thanks for your comment :) 👍 |
Looks good to me. WDYT? |
* | ||
* @return array | ||
*/ | ||
protected function getResultArray(\Traversable $data) |
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.
The typehint looks weird. You are never traversing the data (so Traversable on it is useless) but you are accessing properties (not part of the interface)
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.
Mmm you're right. So do you recommend to not use any typehint here ?
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.
I would typehint \SimpleXmlElement
btw @willdurand, is it intended to use \SimpleXmlElement
in some providers and DOMDocument
in some others ?
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.
No it's not. Just a matter of choice from many contributors.
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.
@stof Thanks I'll update this.
What are the 13 skipped tests and the incomplete one? |
It's like this comment #233 (comment) Maybe you want me to rebase ? I can do it but it will be little bit later. |
No. I want to know if the maxmind-lib issue is fixed. |
I understand. Just for info, I ran the test suite with the last version of
|
this is annoying. I'm thinking about removing this lib.. |
I understand.. |
Mmm the problem is not only with redeclaring existing functions but also the set of define statements in The origin of the lib is here I guess: https://github.com/maxmind/geoip-api-php |
+1000 |
@willdurand :) |
I hoped it could be posible to keep their "not so good code" out of Geocoder. As I see it is not true. I would try to open issues on maxmind official repo. I would even do some PRs with fixes If they be really active and positve on required changes (function_exist\defined const checks or maybe renaming functions). I dont think I will be able to do it till monday. |
@makasim I understand you as well.. I think your provider is good but the library which your provider depends on should be improved to avoid problems. I'm pretty sure that @willdurand @Baachi agree with me. Maybe you can keep us in touch about your PRs and so on.. |
sure |
Why we don't use the offical library? |
I haven't found it |
I prefer the offical driver. I found this driver http://maxmind.github.io/GeoIP2-php/ . The driver looks really good, he supports the webclient and local database. But the driver is for geoIP2, i don't know if there is a big difference between geoIP and geoIP2. |
Indeed it looks much more better, but as stated on this page they do not add support of dowloadable databases, they dont even published them.
|
Apperantly This should be done:
|
Ah i don't saw these sentences, sorry. Remove the GeoIPProvider is a BC break, we can only mark it as deprecated. @willdurand WDYT? |
it's ok to remove it as of |
@@ -20,6 +20,11 @@ | |||
class ArcGISOnlineProvider extends AbstractProvider implements ProviderInterface | |||
{ | |||
/** | |||
* @var integer | |||
*/ | |||
const MAX_RESULTS = 5; |
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.
Is there a special reason why this value is immutable (for this and other providers)? Should be a mutable property, no?
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.
@havvg There isn't a special reason. I just thought it's "enough" to have 5 results as maximum.. We can make this property mutable if everybody agree.
Maybe it could be a new argument in the |
I agree - it's indeed the best place even if some providers don't return many results. |
Hmm.. I'm not sure on this. It would require adding a parameter to the $geocoder = new \Geocoder\Geocoder($provider);
// add some providers ..
$results = $geocoder
->using('bing_maps')
->limit(5)
->reverse([ 48.8630462, 2.3882487 ])
; |
@willdurand @havvg I think we almost agree ;) Maybe |
The PR with composer support was merged, it autoload's files (as it was in maxromanovsky's lib) but it also has conflict section with |
@makasim actually the lib should not conflict. It would be easy to declare functions/constants only if they don't exist. |
no it is not easy. The extension is not up to date and could be differ (last updated 2011) from current version of the lib (v1.13). So we cannot rely on the extension in all cases. Also if we declare function/constans check it would silently fallback to use the extension and if there is an error a developer would have to spent more time to investigate it. I dont see nothing against marking the ext as conflict. It is not official ext and it does seem like maintened. |
@makasim ok, I created a |
Refactor providers to leverage ResultFactories - fix #232
So I merged this PR into the master (which is |
oh and thank you @toin0u for your awesome work! |
You're welcome! |
@willdurand @Baachi What do you think ?