maxmind / GeoIP2-php

PHP API for GeoIP2 webservice client and database reader
https://maxmind.github.io/GeoIP2-php/
Apache License 2.0
2.3k stars 274 forks source link

Continent missing from City model #205

Closed AdrienPoupa closed 1 year ago

AdrienPoupa commented 1 year ago

Reading the documentation here: https://maxmind.github.io/GeoIP2-php/doc/v2.13.0/classes/GeoIp2-Model-City.html

I would assume that I can access the continent property from the City model.

However it is not present in the PHPDoc of the model, hence PHPStan and PHPStorm cannot see it:

Access to an undefined property GeoIp2\Record\Country::$continent.

This is kinda odd though because I can see that City extends Country, that has Continent defined. I think the IDE maps the country property of City to the record, not the model, so it cannot find the continent.

$reader = new GeoIp2\Database\Reader('/usr/share/GeoIP/GeoLite2-City.mmdb');
$record = $reader->city('someIP');

image

oschwald commented 1 year ago

You cannot access the continent from the country. You would access it with $record->continent->code. This is the same way you would access it if $record was a GeoIp2\Model\Country.

AdrienPoupa commented 1 year ago

I am not sure how I missed that, sorry 😮‍💨 thanks a lot!