diff options
Diffstat (limited to 'vendor/geoip2')
35 files changed, 985 insertions, 656 deletions
diff --git a/vendor/geoip2/geoip2/CHANGELOG.md b/vendor/geoip2/geoip2/CHANGELOG.md index 9881b4d..146b7a3 100644 --- a/vendor/geoip2/geoip2/CHANGELOG.md +++ b/vendor/geoip2/geoip2/CHANGELOG.md @@ -1,6 +1,47 @@ CHANGELOG
=========
+2.13.0 (2022-08-05)
+-------------------
+
+* The model class names are no longer constructed by concatenating strings.
+ This change was made to improve support for tools like PHP-Scoper.
+ Reported by Andrew Mead. GitHub #194.
+* Box 4.0.1 is now used to generate the `geoip2.phar` file.
+
+2.12.2 (2021-11-30)
+-------------------
+
+* The `geoip2.phar` now works when included from another directory.
+ Reported by Eduardo Ruiz. GitHub #179.
+
+2.12.1 (2021-11-23)
+-------------------
+
+* The `geoip2.phar` included in 2.12.0 would only work in CLI applications.
+ This was due to a change in Box 3.x. The Phar should now work in all
+ applications. This release only affects users of the Phar file.
+
+2.12.0 (2021-11-18)
+-------------------
+
+* Support for mobile country code (MCC) and mobile network codes (MNC) was
+ added for the GeoIP2 ISP and Enterprise databases as well as the GeoIP2
+ City and Insights web services. `$mobileCountryCode` and
+ `$mobileNetworkCode` properties were added to `GeoIp2\Model\Isp`
+ for the GeoIP2 ISP database and `GeoIp2\Record\Traits` for the Enterprise
+ database and the GeoIP2 City and Insights web services. We expect this data
+ to be available by late January, 2022.
+* `geoip2.phar` is now generated with Box 3.x.
+
+2.11.0 (2020-10-01)
+-------------------
+
+* IMPORTANT: PHP 7.2 or greater is now required.
+* Added the `isResidentialProxy` property to `GeoIp2\Model\AnonymousIP` and
+ `GeoIp2\Record\Traits`.
+* Additional type hints have been added.
+
2.10.0 (2019-12-12)
-------------------
diff --git a/vendor/geoip2/geoip2/README.md b/vendor/geoip2/geoip2/README.md index e4a74dc..7839743 100644 --- a/vendor/geoip2/geoip2/README.md +++ b/vendor/geoip2/geoip2/README.md @@ -1,409 +1,442 @@ -# GeoIP2 PHP API # - -## Description ## - -This package provides an API for the GeoIP2 -[web services](https://dev.maxmind.com/geoip/geoip2/web-services) and -[databases](https://dev.maxmind.com/geoip/geoip2/downloadable). The API also -works with the free -[GeoLite2 databases](https://dev.maxmind.com/geoip/geoip2/geolite2/). - -## Install via Composer ## - -We recommend installing this package with [Composer](https://getcomposer.org/). - -### Download Composer ### - -To download Composer, run in the root directory of your project: - -```bash -curl -sS https://getcomposer.org/installer | php -``` - -You should now have the file `composer.phar` in your project directory. - -### Install Dependencies ### - -Run in your project root: - -``` -php composer.phar require geoip2/geoip2:~2.0 -``` - -You should now have the files `composer.json` and `composer.lock` as well as -the directory `vendor` in your project directory. If you use a version control -system, `composer.json` should be added to it. - -### Require Autoloader ### - -After installing the dependencies, you need to require the Composer autoloader -from your code: - -```php -require 'vendor/autoload.php'; -``` - -## Install via Phar ## - -Although we strongly recommend using Composer, we also provide a -[phar archive](https://php.net/manual/en/book.phar.php) containing most of the -dependencies for GeoIP2. Our latest phar archive is available on -[our releases page](https://github.com/maxmind/GeoIP2-php/releases). - -### Install Dependencies ### - -In order to use the phar archive, you must have the PHP -[Phar extension](https://php.net/manual/en/book.phar.php) installed and -enabled. - -If you will be making web service requests, you must have the PHP -[cURL extension](https://php.net/manual/en/book.curl.php) -installed to use this archive. For Debian based distributions, this can -typically be found in the the `php-curl` package. For other operating -systems, please consult the relevant documentation. After installing the -extension you may need to restart your web server. - -If you are missing this extension, you will see errors like the following: - -``` -PHP Fatal error: Uncaught Error: Call to undefined function MaxMind\WebService\curl_version() -``` - -### Require Package ### - -To use the archive, just require it from your script: - -```php -require 'geoip2.phar'; -``` - -## Optional C Extension ## - -The [MaxMind DB API](https://github.com/maxmind/MaxMind-DB-Reader-php) -includes an optional C extension that you may install to dramatically increase -the performance of lookups in GeoIP2 or GeoLite2 databases. To install, please -follow the instructions included with that API. - -The extension has no effect on web-service lookups. - -## IP Geolocation Usage ## - -IP geolocation is inherently imprecise. Locations are often near the center of -the population. Any location provided by a GeoIP2 database or web service -should not be used to identify a particular address or household. - -## Database Reader ## - -### Usage ### - -To use this API, you must create a new `\GeoIp2\Database\Reader` object with -the path to the database file as the first argument to the constructor. You -may then call the method corresponding to the database you are using. - -If the lookup succeeds, the method call will return a model class for the -record in the database. This model in turn contains multiple container -classes for the different parts of the data such as the city in which the -IP address is located. - -If the record is not found, a `\GeoIp2\Exception\AddressNotFoundException` -is thrown. If the database is invalid or corrupt, a -`\MaxMind\Db\InvalidDatabaseException` will be thrown. - -See the API documentation for more details. - -### City Example ### - -```php -<?php -require_once 'vendor/autoload.php'; -use GeoIp2\Database\Reader; - -// This creates the Reader object, which should be reused across -// lookups. -$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-City.mmdb'); - -// Replace "city" with the appropriate method for your database, e.g., -// "country". -$record = $reader->city('128.101.101.101'); - -print($record->country->isoCode . "\n"); // 'US' -print($record->country->name . "\n"); // 'United States' -print($record->country->names['zh-CN'] . "\n"); // '美国' - -print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota' -print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN' - -print($record->city->name . "\n"); // 'Minneapolis' - -print($record->postal->code . "\n"); // '55455' - -print($record->location->latitude . "\n"); // 44.9733 -print($record->location->longitude . "\n"); // -93.2323 - -print($record->traits->network . "\n"); // '128.101.101.101/32' - -``` - -### Anonymous IP Example ### - -```php -<?php -require_once 'vendor/autoload.php'; -use GeoIp2\Database\Reader; - -// This creates the Reader object, which should be reused across -// lookups. -$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Anonymous-IP.mmdb'); - -$record = $reader->anonymousIp('128.101.101.101'); - -if ($record->isAnonymous) { print "anon\n"; } -print($record->ipAddress . "\n"); // '128.101.101.101' -print($record->network . "\n"); // '128.101.101.101/32' - -``` - -### Connection-Type Example ### - -```php -<?php -require_once 'vendor/autoload.php'; -use GeoIp2\Database\Reader; - -// This creates the Reader object, which should be reused across -// lookups. -$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Connection-Type.mmdb'); - -$record = $reader->connectionType('128.101.101.101'); - -print($record->connectionType . "\n"); // 'Corporate' -print($record->ipAddress . "\n"); // '128.101.101.101' -print($record->network . "\n"); // '128.101.101.101/32' - -``` - -### Domain Example ### - -```php -<?php -require_once 'vendor/autoload.php'; -use GeoIp2\Database\Reader; - -// This creates the Reader object, which should be reused across -// lookups. -$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Domain.mmdb'); - -$record = $reader->domain('128.101.101.101'); - -print($record->domain . "\n"); // 'umn.edu' -print($record->ipAddress . "\n"); // '128.101.101.101' -print($record->network . "\n"); // '128.101.101.101/32' - -``` - -### Enterprise Example ### - -```php -<?php -require_once 'vendor/autoload.php'; -use GeoIp2\Database\Reader; - -// This creates the Reader object, which should be reused across -// lookups. -$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Enterprise.mmdb'); - -// Use the ->enterprise method to do a lookup in the Enterprise database -$record = $reader->enterprise('128.101.101.101'); - -print($record->country->confidence . "\n"); // 99 -print($record->country->isoCode . "\n"); // 'US' -print($record->country->name . "\n"); // 'United States' -print($record->country->names['zh-CN'] . "\n"); // '美国' - -print($record->mostSpecificSubdivision->confidence . "\n"); // 77 -print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota' -print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN' - -print($record->city->confidence . "\n"); // 60 -print($record->city->name . "\n"); // 'Minneapolis' - -print($record->postal->code . "\n"); // '55455' - -print($record->location->accuracyRadius . "\n"); // 50 -print($record->location->latitude . "\n"); // 44.9733 -print($record->location->longitude . "\n"); // -93.2323 - -print($record->traits->network . "\n"); // '128.101.101.101/32' - -``` - -### ISP Example ### - -```php -<?php -require_once 'vendor/autoload.php'; -use GeoIp2\Database\Reader; - -// This creates the Reader object, which should be reused across -// lookups. -$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-ISP.mmdb'); - -$record = $reader->isp('128.101.101.101'); - -print($record->autonomousSystemNumber . "\n"); // 217 -print($record->autonomousSystemOrganization . "\n"); // 'University of Minnesota' -print($record->isp . "\n"); // 'University of Minnesota' -print($record->organization . "\n"); // 'University of Minnesota' - -print($record->ipAddress . "\n"); // '128.101.101.101' -print($record->network . "\n"); // '128.101.101.101/32' - -``` - -## Web Service Client ## - -### Usage ### - -To use this API, you must create a new `\GeoIp2\WebService\Client` -object with your `$accountId` and `$licenseKey`, then you call the method -corresponding to a specific end point, passing it the IP address you want to -look up. - -If the request succeeds, the method call will return a model class for the end -point you called. This model in turn contains multiple record classes, each of -which represents part of the data returned by the web service. - -If there is an error, a structured exception is thrown. - -See the API documentation for more details. - -### Example ### - -```php -<?php -require_once 'vendor/autoload.php'; -use GeoIp2\WebService\Client; - -// This creates a Client object that can be reused across requests. -// Replace "42" with your account ID and "license_key" with your license -// key. -$client = new Client(42, 'abcdef123456'); - -// Replace "city" with the method corresponding to the web service that -// you are using, e.g., "country", "insights". -$record = $client->city('128.101.101.101'); - -print($record->country->isoCode . "\n"); // 'US' -print($record->country->name . "\n"); // 'United States' -print($record->country->names['zh-CN'] . "\n"); // '美国' - -print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota' -print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN' - -print($record->city->name . "\n"); // 'Minneapolis' - -print($record->postal->code . "\n"); // '55455' - -print($record->location->latitude . "\n"); // 44.9733 -print($record->location->longitude . "\n"); // -93.2323 - -print($record->traits->network . "\n"); // '128.101.101.101/32' - -``` - -## Values to use for Database or Array Keys ## - -**We strongly discourage you from using a value from any `names` property as -a key in a database or array.** - -These names may change between releases. Instead we recommend using one of the -following: - -* `GeoIp2\Record\City` - `$city->geonameId` -* `GeoIp2\Record\Continent` - `$continent->code` or `$continent->geonameId` -* `GeoIp2\Record\Country` and `GeoIp2\Record\RepresentedCountry` - - `$country->isoCode` or `$country->geonameId` -* `GeoIp2\Record\Subdivision` - `$subdivision->isoCode` or `$subdivision->geonameId` - -### What data is returned? ### - -While many of the end points return the same basic records, the attributes -which can be populated vary between end points. In addition, while an end -point may offer a particular piece of data, MaxMind does not always have every -piece of data for any given IP address. - -Because of these factors, it is possible for any end point to return a record -where some or all of the attributes are unpopulated. - -See the -[GeoIP2 Precision web service docs](https://dev.maxmind.com/geoip/geoip2/web-services) -for details on what data each end point may return. - -The only piece of data which is always returned is the `ipAddress` -attribute in the `GeoIp2\Record\Traits` record. - -## Integration with GeoNames ## - -[GeoNames](https://www.geonames.org/) offers web services and downloadable -databases with data on geographical features around the world, including -populated places. They offer both free and paid premium data. Each -feature is unique identified by a `geonameId`, which is an integer. - -Many of the records returned by the GeoIP2 web services and databases -include a `geonameId` property. This is the ID of a geographical feature -(city, region, country, etc.) in the GeoNames database. - -Some of the data that MaxMind provides is also sourced from GeoNames. We -source things like place names, ISO codes, and other similar data from -the GeoNames premium data set. - -## Reporting data problems ## - -If the problem you find is that an IP address is incorrectly mapped, -please -[submit your correction to MaxMind](https://www.maxmind.com/en/correction). - -If you find some other sort of mistake, like an incorrect spelling, -please check the [GeoNames site](https://www.geonames.org/) first. Once -you've searched for a place and found it on the GeoNames map view, there -are a number of links you can use to correct data ("move", "edit", -"alternate names", etc.). Once the correction is part of the GeoNames -data set, it will be automatically incorporated into future MaxMind -releases. - -If you are a paying MaxMind customer and you're not sure where to submit -a correction, please -[contact MaxMind support](https://www.maxmind.com/en/support) for help. - -## Other Support ## - -Please report all issues with this code using the -[GitHub issue tracker](https://github.com/maxmind/GeoIP2-php/issues). - -If you are having an issue with a MaxMind service that is not specific -to the client API, please see -[our support page](https://www.maxmind.com/en/support). - -## Requirements ## - -This library requires PHP 5.6 or greater. - -This library also relies on the [MaxMind DB Reader](https://github.com/maxmind/MaxMind-DB-Reader-php). - -## Contributing ## - -Patches and pull requests are encouraged. All code should follow the PSR-2 -style guidelines. Please include unit tests whenever possible. You may obtain -the test data for the maxmind-db folder by running `git submodule update ---init --recursive` or adding `--recursive` to your initial clone, or from -https://github.com/maxmind/MaxMind-DB - -## Versioning ## - -The GeoIP2 PHP API uses [Semantic Versioning](https://semver.org/). - -## Copyright and License ## - -This software is Copyright (c) 2013-2019 by MaxMind, Inc. - -This is free software, licensed under the Apache License, Version 2.0. +# GeoIP2 PHP API #
+
+## Description ##
+
+This package provides an API for the GeoIP2 and GeoLite2
+[web services](https://dev.maxmind.com/geoip/docs/web-services?lang=en) and
+[databases](https://dev.maxmind.com/geoip/docs/databases?lang=en).
+
+## Install via Composer ##
+
+We recommend installing this package with [Composer](https://getcomposer.org/).
+
+### Download Composer ###
+
+To download Composer, run in the root directory of your project:
+
+```bash
+curl -sS https://getcomposer.org/installer | php
+```
+
+You should now have the file `composer.phar` in your project directory.
+
+### Install Dependencies ###
+
+Run in your project root:
+
+```sh
+php composer.phar require geoip2/geoip2:~2.0
+```
+
+You should now have the files `composer.json` and `composer.lock` as well as
+the directory `vendor` in your project directory. If you use a version control
+system, `composer.json` should be added to it.
+
+### Require Autoloader ###
+
+After installing the dependencies, you need to require the Composer autoloader
+from your code:
+
+```php
+require 'vendor/autoload.php';
+```
+
+## Install via Phar ##
+
+Although we strongly recommend using Composer, we also provide a
+[phar archive](https://php.net/manual/en/book.phar.php) containing most of the
+dependencies for GeoIP2. Our latest phar archive is available on
+[our releases page](https://github.com/maxmind/GeoIP2-php/releases).
+
+### Install Dependencies ###
+
+In order to use the phar archive, you must have the PHP
+[Phar extension](https://php.net/manual/en/book.phar.php) installed and
+enabled.
+
+If you will be making web service requests, you must have the PHP
+[cURL extension](https://php.net/manual/en/book.curl.php)
+installed to use this archive. For Debian based distributions, this can
+typically be found in the the `php-curl` package. For other operating
+systems, please consult the relevant documentation. After installing the
+extension you may need to restart your web server.
+
+If you are missing this extension, you will see errors like the following:
+
+```
+PHP Fatal error: Uncaught Error: Call to undefined function MaxMind\WebService\curl_version()
+```
+
+### Require Package ###
+
+To use the archive, just require it from your script:
+
+```php
+require 'geoip2.phar';
+```
+
+## Optional C Extension ##
+
+The [MaxMind DB API](https://github.com/maxmind/MaxMind-DB-Reader-php)
+includes an optional C extension that you may install to dramatically increase
+the performance of lookups in GeoIP2 or GeoLite2 databases. To install, please
+follow the instructions included with that API.
+
+The extension has no effect on web-service lookups.
+
+## IP Geolocation Usage ##
+
+IP geolocation is inherently imprecise. Locations are often near the center of
+the population. Any location provided by a GeoIP2 database or web service
+should not be used to identify a particular address or household.
+
+## Database Reader ##
+
+### Usage ###
+
+To use this API, you must create a new `\GeoIp2\Database\Reader` object with
+the path to the database file as the first argument to the constructor. You
+may then call the method corresponding to the database you are using.
+
+If the lookup succeeds, the method call will return a model class for the
+record in the database. This model in turn contains multiple container
+classes for the different parts of the data such as the city in which the
+IP address is located.
+
+If the record is not found, a `\GeoIp2\Exception\AddressNotFoundException`
+is thrown. If the database is invalid or corrupt, a
+`\MaxMind\Db\InvalidDatabaseException` will be thrown.
+
+See the API documentation for more details.
+
+### City Example ###
+
+```php
+<?php
+require_once 'vendor/autoload.php';
+use GeoIp2\Database\Reader;
+
+// This creates the Reader object, which should be reused across
+// lookups.
+$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-City.mmdb');
+
+// Replace "city" with the appropriate method for your database, e.g.,
+// "country".
+$record = $reader->city('128.101.101.101');
+
+print($record->country->isoCode . "\n"); // 'US'
+print($record->country->name . "\n"); // 'United States'
+print($record->country->names['zh-CN'] . "\n"); // '美国'
+
+print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota'
+print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN'
+
+print($record->city->name . "\n"); // 'Minneapolis'
+
+print($record->postal->code . "\n"); // '55455'
+
+print($record->location->latitude . "\n"); // 44.9733
+print($record->location->longitude . "\n"); // -93.2323
+
+print($record->traits->network . "\n"); // '128.101.101.101/32'
+
+```
+
+### Anonymous IP Example ###
+
+```php
+<?php
+require_once 'vendor/autoload.php';
+use GeoIp2\Database\Reader;
+
+// This creates the Reader object, which should be reused across
+// lookups.
+$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Anonymous-IP.mmdb');
+
+$record = $reader->anonymousIp('128.101.101.101');
+
+if ($record->isAnonymous) { print "anon\n"; }
+print($record->ipAddress . "\n"); // '128.101.101.101'
+print($record->network . "\n"); // '128.101.101.101/32'
+
+```
+
+### Connection-Type Example ###
+
+```php
+<?php
+require_once 'vendor/autoload.php';
+use GeoIp2\Database\Reader;
+
+// This creates the Reader object, which should be reused across
+// lookups.
+$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Connection-Type.mmdb');
+
+$record = $reader->connectionType('128.101.101.101');
+
+print($record->connectionType . "\n"); // 'Corporate'
+print($record->ipAddress . "\n"); // '128.101.101.101'
+print($record->network . "\n"); // '128.101.101.101/32'
+
+```
+
+### Domain Example ###
+
+```php
+<?php
+require_once 'vendor/autoload.php';
+use GeoIp2\Database\Reader;
+
+// This creates the Reader object, which should be reused across
+// lookups.
+$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Domain.mmdb');
+
+$record = $reader->domain('128.101.101.101');
+
+print($record->domain . "\n"); // 'umn.edu'
+print($record->ipAddress . "\n"); // '128.101.101.101'
+print($record->network . "\n"); // '128.101.101.101/32'
+
+```
+
+### Enterprise Example ###
+
+```php
+<?php
+require_once 'vendor/autoload.php';
+use GeoIp2\Database\Reader;
+
+// This creates the Reader object, which should be reused across
+// lookups.
+$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Enterprise.mmdb');
+
+// Use the ->enterprise method to do a lookup in the Enterprise database
+$record = $reader->enterprise('128.101.101.101');
+
+print($record->country->confidence . "\n"); // 99
+print($record->country->isoCode . "\n"); // 'US'
+print($record->country->name . "\n"); // 'United States'
+print($record->country->names['zh-CN'] . "\n"); // '美国'
+
+print($record->mostSpecificSubdivision->confidence . "\n"); // 77
+print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota'
+print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN'
+
+print($record->city->confidence . "\n"); // 60
+print($record->city->name . "\n"); // 'Minneapolis'
+
+print($record->postal->code . "\n"); // '55455'
+
+print($record->location->accuracyRadius . "\n"); // 50
+print($record->location->latitude . "\n"); // 44.9733
+print($record->location->longitude . "\n"); // -93.2323
+
+print($record->traits->network . "\n"); // '128.101.101.101/32'
+
+```
+
+### ISP Example ###
+
+```php
+<?php
+require_once 'vendor/autoload.php';
+use GeoIp2\Database\Reader;
+
+// This creates the Reader object, which should be reused across
+// lookups.
+$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-ISP.mmdb');
+
+$record = $reader->isp('128.101.101.101');
+
+print($record->autonomousSystemNumber . "\n"); // 217
+print($record->autonomousSystemOrganization . "\n"); // 'University of Minnesota'
+print($record->isp . "\n"); // 'University of Minnesota'
+print($record->organization . "\n"); // 'University of Minnesota'
+
+print($record->ipAddress . "\n"); // '128.101.101.101'
+print($record->network . "\n"); // '128.101.101.101/32'
+
+```
+
+## Database Updates ##
+
+You can keep your databases up to date with our
+[GeoIP Update program](https://github.com/maxmind/geoipupdate/releases).
+[Learn more about GeoIP Update on our developer
+portal.](https://dev.maxmind.com/geoip/updating-databases?lang=en)
+
+There is also a third-party tool for updating databases using PHP and
+Composer. MaxMind does not offer support for this tool or maintain it.
+[Learn more about the Geoip2 Update tool for PHP and Composer on its
+GitHub page.](https://github.com/tronovav/geoip2-update)
+
+## Web Service Client ##
+
+### Usage ###
+
+To use this API, you must create a new `\GeoIp2\WebService\Client`
+object with your `$accountId` and `$licenseKey`:
+
+```php
+$client = new Client(42, 'abcdef123456');
+```
+
+You may also call the constructor with additional arguments. The third argument
+specifies the language preferences when using the `->name` method on the model
+classes that this client creates. The fourth argument is additional options
+such as `host` and `timeout`.
+
+For instance, to call the GeoLite2 web service instead of the GeoIP2 web
+service:
+
+```php
+$client = new Client(42, 'abcdef123456', ['en'], ['host' => 'geolite.info']);
+```
+
+After creating the client, you may now call the method corresponding to a
+specific endpoint with the IP address to look up, e.g.:
+
+```php
+$record = $client->city('128.101.101.101');
+```
+
+If the request succeeds, the method call will return a model class for the
+endpoint you called. This model in turn contains multiple record classes, each
+of which represents part of the data returned by the web service.
+
+If there is an error, a structured exception is thrown.
+
+See the API documentation for more details.
+
+### Example ###
+
+```php
+<?php
+require_once 'vendor/autoload.php';
+use GeoIp2\WebService\Client;
+
+// This creates a Client object that can be reused across requests.
+// Replace "42" with your account ID and "license_key" with your license
+// key. Set the "host" to "geolite.info" in the fourth argument options
+// array to use the GeoLite2 web service instead of the GeoIP2 web
+// service.
+$client = new Client(42, 'abcdef123456');
+
+// Replace "city" with the method corresponding to the web service that
+// you are using, e.g., "country", "insights".
+$record = $client->city('128.101.101.101');
+
+print($record->country->isoCode . "\n"); // 'US'
+print($record->country->name . "\n"); // 'United States'
+print($record->country->names['zh-CN'] . "\n"); // '美国'
+
+print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota'
+print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN'
+
+print($record->city->name . "\n"); // 'Minneapolis'
+
+print($record->postal->code . "\n"); // '55455'
+
+print($record->location->latitude . "\n"); // 44.9733
+print($record->location->longitude . "\n"); // -93.2323
+
+print($record->traits->network . "\n"); // '128.101.101.101/32'
+
+```
+
+## Values to use for Database or Array Keys ##
+
+**We strongly discourage you from using a value from any `names` property as
+a key in a database or array.**
+
+These names may change between releases. Instead we recommend using one of the
+following:
+
+* `GeoIp2\Record\City` - `$city->geonameId`
+* `GeoIp2\Record\Continent` - `$continent->code` or `$continent->geonameId`
+* `GeoIp2\Record\Country` and `GeoIp2\Record\RepresentedCountry` -
+ `$country->isoCode` or `$country->geonameId`
+* `GeoIp2\Record\Subdivision` - `$subdivision->isoCode` or `$subdivision->geonameId`
+
+### What data is returned? ###
+
+While many of the end points return the same basic records, the attributes
+which can be populated vary between end points. In addition, while an end
+point may offer a particular piece of data, MaxMind does not always have every
+piece of data for any given IP address.
+
+Because of these factors, it is possible for any end point to return a record
+where some or all of the attributes are unpopulated.
+
+See the
+[GeoIP2 web service docs](https://dev.maxmind.com/geoip/docs/web-services?lang=en)
+for details on what data each end point may return.
+
+The only piece of data which is always returned is the `ipAddress`
+attribute in the `GeoIp2\Record\Traits` record.
+
+## Integration with GeoNames ##
+
+[GeoNames](https://www.geonames.org/) offers web services and downloadable
+databases with data on geographical features around the world, including
+populated places. They offer both free and paid premium data. Each
+feature is unique identified by a `geonameId`, which is an integer.
+
+Many of the records returned by the GeoIP2 web services and databases
+include a `geonameId` property. This is the ID of a geographical feature
+(city, region, country, etc.) in the GeoNames database.
+
+Some of the data that MaxMind provides is also sourced from GeoNames. We
+source things like place names, ISO codes, and other similar data from
+the GeoNames premium data set.
+
+## Reporting data problems ##
+
+If the problem you find is that an IP address is incorrectly mapped,
+please
+[submit your correction to MaxMind](https://www.maxmind.com/en/correction).
+
+If you find some other sort of mistake, like an incorrect spelling,
+please check the [GeoNames site](https://www.geonames.org/) first. Once
+you've searched for a place and found it on the GeoNames map view, there
+are a number of links you can use to correct data ("move", "edit",
+"alternate names", etc.). Once the correction is part of the GeoNames
+data set, it will be automatically incorporated into future MaxMind
+releases.
+
+If you are a paying MaxMind customer and you're not sure where to submit
+a correction, please
+[contact MaxMind support](https://www.maxmind.com/en/support) for help.
+
+## Other Support ##
+
+Please report all issues with this code using the
+[GitHub issue tracker](https://github.com/maxmind/GeoIP2-php/issues).
+
+If you are having an issue with a MaxMind service that is not specific
+to the client API, please see
+[our support page](https://www.maxmind.com/en/support).
+
+## Requirements ##
+
+This library requires PHP 7.2 or greater.
+
+This library also relies on the [MaxMind DB Reader](https://github.com/maxmind/MaxMind-DB-Reader-php).
+
+## Contributing ##
+
+Patches and pull requests are encouraged. All code should follow the PSR-2
+style guidelines. Please include unit tests whenever possible. You may obtain
+the test data for the maxmind-db folder by running `git submodule update
+--init --recursive` or adding `--recursive` to your initial clone, or from
+https://github.com/maxmind/MaxMind-DB
+
+## Versioning ##
+
+The GeoIP2 PHP API uses [Semantic Versioning](https://semver.org/).
+
+## Copyright and License ##
+
+This software is Copyright (c) 2013-2020 by MaxMind, Inc.
+
+This is free software, licensed under the Apache License, Version 2.0.
diff --git a/vendor/geoip2/geoip2/composer.json b/vendor/geoip2/geoip2/composer.json index 94669ff..59dffb1 100644 --- a/vendor/geoip2/geoip2/composer.json +++ b/vendor/geoip2/geoip2/composer.json @@ -13,15 +13,16 @@ }
],
"require": {
- "maxmind-db/reader": "~1.5",
- "maxmind/web-service-common": "~0.6",
- "php": ">=5.6",
+ "maxmind-db/reader": "~1.8",
+ "maxmind/web-service-common": "~0.8",
+ "php": ">=7.2",
"ext-json": "*"
},
"require-dev": {
- "friendsofphp/php-cs-fixer": "2.*",
- "phpunit/phpunit": "5.*",
- "squizlabs/php_codesniffer": "3.*"
+ "friendsofphp/php-cs-fixer": "3.*",
+ "phpunit/phpunit": "^8.0 || ^9.0",
+ "squizlabs/php_codesniffer": "3.*",
+ "phpstan/phpstan": "*"
},
"autoload": {
"psr-4": {
diff --git a/vendor/geoip2/geoip2/examples/benchmark.php b/vendor/geoip2/geoip2/examples/benchmark.php index 7af2a5d..a9273ed 100644 --- a/vendor/geoip2/geoip2/examples/benchmark.php +++ b/vendor/geoip2/geoip2/examples/benchmark.php @@ -1,25 +1,26 @@ -<?php - -require __DIR__ . '/../vendor/autoload.php'; - -use GeoIp2\Database\Reader; - -srand(0); - -$reader = new Reader('GeoIP2-City.mmdb'); -$count = 500000; -$startTime = microtime(true); -for ($i = 0; $i < $count; ++$i) { - $ip = long2ip(rand(0, pow(2, 32) - 1)); - try { - $t = $reader->city($ip); - } catch (\GeoIp2\Exception\AddressNotFoundException $e) { - } - if ($i % 10000 === 0) { - echo $i . ' ' . $ip . "\n"; - } -} -$endTime = microtime(true); - -$duration = $endTime - $startTime; -echo 'Requests per second: ' . $count / $duration . "\n"; +<?php
+
+require __DIR__ . '/../vendor/autoload.php';
+
+use GeoIp2\Database\Reader;
+
+srand(0);
+
+$reader = new Reader('GeoIP2-City.mmdb');
+$count = 500000;
+$startTime = microtime(true);
+for ($i = 0; $i < $count; ++$i) {
+ $ip = long2ip(rand(0, 2 ** 32 - 1));
+
+ try {
+ $t = $reader->city($ip);
+ } catch (\GeoIp2\Exception\AddressNotFoundException $e) {
+ }
+ if ($i % 10000 === 0) {
+ echo $i . ' ' . $ip . "\n";
+ }
+}
+$endTime = microtime(true);
+
+$duration = $endTime - $startTime;
+echo 'Requests per second: ' . $count / $duration . "\n";
diff --git a/vendor/geoip2/geoip2/src/Database/Reader.php b/vendor/geoip2/geoip2/src/Database/Reader.php index 9c33e3d..40d32bc 100644 --- a/vendor/geoip2/geoip2/src/Database/Reader.php +++ b/vendor/geoip2/geoip2/src/Database/Reader.php @@ -1,8 +1,19 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Database;
use GeoIp2\Exception\AddressNotFoundException;
+use GeoIp2\Model\AbstractModel;
+use GeoIp2\Model\AnonymousIp;
+use GeoIp2\Model\Asn;
+use GeoIp2\Model\City;
+use GeoIp2\Model\ConnectionType;
+use GeoIp2\Model\Country;
+use GeoIp2\Model\Domain;
+use GeoIp2\Model\Enterprise;
+use GeoIp2\Model\Isp;
use GeoIp2\ProviderInterface;
use MaxMind\Db\Reader as DbReader;
use MaxMind\Db\Reader\InvalidDatabaseException;
@@ -33,8 +44,19 @@ use MaxMind\Db\Reader\InvalidDatabaseException; */
class Reader implements ProviderInterface
{
+ /**
+ * @var DbReader
+ */
private $dbReader;
+
+ /**
+ * @var string
+ */
private $dbType;
+
+ /**
+ * @var array<string>
+ */
private $locales;
/**
@@ -48,8 +70,8 @@ class Reader implements ProviderInterface * is corrupt or invalid
*/
public function __construct(
- $filename,
- $locales = ['en']
+ string $filename,
+ array $locales = ['en']
) {
$this->dbReader = new DbReader($filename);
$this->dbType = $this->dbReader->metadata()->databaseType;
@@ -65,12 +87,11 @@ class Reader implements ProviderInterface * not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\City
*/
- public function city($ipAddress)
+ public function city(string $ipAddress): City
{
- return $this->modelFor('City', 'City', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->modelFor(City::class, 'City', $ipAddress);
}
/**
@@ -82,12 +103,11 @@ class Reader implements ProviderInterface * not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Country
*/
- public function country($ipAddress)
+ public function country(string $ipAddress): Country
{
- return $this->modelFor('Country', 'Country', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->modelFor(Country::class, 'Country', $ipAddress);
}
/**
@@ -99,13 +119,12 @@ class Reader implements ProviderInterface * not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\AnonymousIp
*/
- public function anonymousIp($ipAddress)
+ public function anonymousIp(string $ipAddress): AnonymousIp
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'AnonymousIp',
+ AnonymousIp::class,
'GeoIP2-Anonymous-IP',
$ipAddress
);
@@ -120,13 +139,12 @@ class Reader implements ProviderInterface * not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Asn
*/
- public function asn($ipAddress)
+ public function asn(string $ipAddress): Asn
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'Asn',
+ Asn::class,
'GeoLite2-ASN',
$ipAddress
);
@@ -141,13 +159,12 @@ class Reader implements ProviderInterface * not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\ConnectionType
*/
- public function connectionType($ipAddress)
+ public function connectionType(string $ipAddress): ConnectionType
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'ConnectionType',
+ ConnectionType::class,
'GeoIP2-Connection-Type',
$ipAddress
);
@@ -162,13 +179,12 @@ class Reader implements ProviderInterface * not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Domain
*/
- public function domain($ipAddress)
+ public function domain(string $ipAddress): Domain
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'Domain',
+ Domain::class,
'GeoIP2-Domain',
$ipAddress
);
@@ -183,12 +199,11 @@ class Reader implements ProviderInterface * not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Enterprise
*/
- public function enterprise($ipAddress)
+ public function enterprise(string $ipAddress): Enterprise
{
- return $this->modelFor('Enterprise', 'Enterprise', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->modelFor(Enterprise::class, 'Enterprise', $ipAddress);
}
/**
@@ -200,50 +215,47 @@ class Reader implements ProviderInterface * not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Isp
*/
- public function isp($ipAddress)
+ public function isp(string $ipAddress): Isp
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'Isp',
+ Isp::class,
'GeoIP2-ISP',
$ipAddress
);
}
- private function modelFor($class, $type, $ipAddress)
+ private function modelFor(string $class, string $type, string $ipAddress): AbstractModel
{
- list($record, $prefixLen) = $this->getRecord($class, $type, $ipAddress);
+ [$record, $prefixLen] = $this->getRecord($class, $type, $ipAddress);
$record['traits']['ip_address'] = $ipAddress;
$record['traits']['prefix_len'] = $prefixLen;
- $class = 'GeoIp2\\Model\\' . $class;
-
return new $class($record, $this->locales);
}
- private function flatModelFor($class, $type, $ipAddress)
+ private function flatModelFor(string $class, string $type, string $ipAddress): AbstractModel
{
- list($record, $prefixLen) = $this->getRecord($class, $type, $ipAddress);
+ [$record, $prefixLen] = $this->getRecord($class, $type, $ipAddress);
$record['ip_address'] = $ipAddress;
$record['prefix_len'] = $prefixLen;
- $class = 'GeoIp2\\Model\\' . $class;
return new $class($record);
}
- private function getRecord($class, $type, $ipAddress)
+ private function getRecord(string $class, string $type, string $ipAddress): array
{
if (strpos($this->dbType, $type) === false) {
- $method = lcfirst($class);
+ $method = lcfirst((new \ReflectionClass($class))->getShortName());
+
throw new \BadMethodCallException(
"The $method method cannot be used to open a {$this->dbType} database"
);
}
- list($record, $prefixLen) = $this->dbReader->getWithPrefixLen($ipAddress);
+ [$record, $prefixLen] = $this->dbReader->getWithPrefixLen($ipAddress);
if ($record === null) {
throw new AddressNotFoundException(
"The address $ipAddress is not in the database."
@@ -272,7 +284,7 @@ class Reader implements ProviderInterface *
* @return \MaxMind\Db\Reader\Metadata object for the database
*/
- public function metadata()
+ public function metadata(): DbReader\Metadata
{
return $this->dbReader->metadata();
}
@@ -280,7 +292,7 @@ class Reader implements ProviderInterface /**
* Closes the GeoIP2 database and returns the resources to the system.
*/
- public function close()
+ public function close(): void
{
$this->dbReader->close();
}
diff --git a/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php b/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php index 4e60c28..e5487b4 100644 --- a/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php +++ b/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
diff --git a/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php b/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php index 5f5725f..abbc515 100644 --- a/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php +++ b/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
diff --git a/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php b/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php index b15e5f4..3e75f6b 100644 --- a/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php +++ b/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
diff --git a/vendor/geoip2/geoip2/src/Exception/HttpException.php b/vendor/geoip2/geoip2/src/Exception/HttpException.php index c9fc8b8..a3a5a93 100644 --- a/vendor/geoip2/geoip2/src/Exception/HttpException.php +++ b/vendor/geoip2/geoip2/src/Exception/HttpException.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
@@ -9,13 +11,15 @@ class HttpException extends GeoIp2Exception {
/**
* The URI queried.
+ *
+ * @var string
*/
public $uri;
public function __construct(
- $message,
- $httpStatus,
- $uri,
+ string $message,
+ int $httpStatus,
+ string $uri,
\Exception $previous = null
) {
$this->uri = $uri;
diff --git a/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php b/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php index 63b6e42..4ab5e0c 100644 --- a/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php +++ b/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
@@ -10,14 +12,16 @@ class InvalidRequestException extends HttpException {
/**
* The code returned by the MaxMind web service.
+ *
+ * @var string
*/
public $error;
public function __construct(
- $message,
- $error,
- $httpStatus,
- $uri,
+ string $message,
+ string $error,
+ int $httpStatus,
+ string $uri,
\Exception $previous = null
) {
$this->error = $error;
diff --git a/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php b/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php index 16dc7b8..0d64d50 100644 --- a/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php +++ b/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
diff --git a/vendor/geoip2/geoip2/src/Model/AbstractModel.php b/vendor/geoip2/geoip2/src/Model/AbstractModel.php index 50f24b0..ba8dd84 100644 --- a/vendor/geoip2/geoip2/src/Model/AbstractModel.php +++ b/vendor/geoip2/geoip2/src/Model/AbstractModel.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
@@ -7,14 +9,15 @@ namespace GeoIp2\Model; */
abstract class AbstractModel implements \JsonSerializable
{
+ /**
+ * @var array<string, mixed>
+ */
protected $raw;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
$this->raw = $raw;
}
@@ -22,9 +25,9 @@ abstract class AbstractModel implements \JsonSerializable /**
* @ignore
*
- * @param mixed $field
+ * @return mixed
*/
- protected function get($field)
+ protected function get(string $field)
{
if (isset($this->raw[$field])) {
return $this->raw[$field];
@@ -39,12 +42,12 @@ abstract class AbstractModel implements \JsonSerializable /**
* @ignore
*
- * @param mixed $attr
+ * @return mixed
*/
- public function __get($attr)
+ public function __get(string $attr)
{
if ($attr !== 'instance' && property_exists($this, $attr)) {
- return $this->$attr;
+ return $this->{$attr};
}
throw new \RuntimeException("Unknown attribute: $attr");
@@ -52,15 +55,13 @@ abstract class AbstractModel implements \JsonSerializable /**
* @ignore
- *
- * @param mixed $attr
*/
- public function __isset($attr)
+ public function __isset(string $attr): bool
{
- return $attr !== 'instance' && isset($this->$attr);
+ return $attr !== 'instance' && isset($this->{$attr});
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return $this->raw;
}
diff --git a/vendor/geoip2/geoip2/src/Model/AnonymousIp.php b/vendor/geoip2/geoip2/src/Model/AnonymousIp.php index bf05b88..fb927ab 100644 --- a/vendor/geoip2/geoip2/src/Model/AnonymousIp.php +++ b/vendor/geoip2/geoip2/src/Model/AnonymousIp.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -17,6 +19,8 @@ use GeoIp2\Util; * to a hosting or VPN provider (see description of isAnonymousVpn property).
* @property-read bool $isPublicProxy This is true if the IP address belongs to
* a public proxy.
+ * @property-read bool $isResidentialProxy This is true if the IP address is
+ * on a suspected anonymizing network and belongs to a residential ISP.
* @property-read bool $isTorExitNode This is true if the IP address is a Tor
* exit node.
* @property-read string $ipAddress The IP address that the data in the model is
@@ -27,20 +31,50 @@ use GeoIp2\Util; */
class AnonymousIp extends AbstractModel
{
+ /**
+ * @var bool
+ */
protected $isAnonymous;
+
+ /**
+ * @var bool
+ */
protected $isAnonymousVpn;
+
+ /**
+ * @var bool
+ */
protected $isHostingProvider;
+
+ /**
+ * @var bool
+ */
protected $isPublicProxy;
+
+ /**
+ * @var bool
+ */
+ protected $isResidentialProxy;
+
+ /**
+ * @var bool
+ */
protected $isTorExitNode;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
@@ -48,6 +82,7 @@ class AnonymousIp extends AbstractModel $this->isAnonymousVpn = $this->get('is_anonymous_vpn');
$this->isHostingProvider = $this->get('is_hosting_provider');
$this->isPublicProxy = $this->get('is_public_proxy');
+ $this->isResidentialProxy = $this->get('is_residential_proxy');
$this->isTorExitNode = $this->get('is_tor_exit_node');
$ipAddress = $this->get('ip_address');
$this->ipAddress = $ipAddress;
diff --git a/vendor/geoip2/geoip2/src/Model/Asn.php b/vendor/geoip2/geoip2/src/Model/Asn.php index 09f746e..c28df26 100644 --- a/vendor/geoip2/geoip2/src/Model/Asn.php +++ b/vendor/geoip2/geoip2/src/Model/Asn.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -20,17 +22,30 @@ use GeoIp2\Util; */
class Asn extends AbstractModel
{
+ /**
+ * @var int|null
+ */
protected $autonomousSystemNumber;
+
+ /**
+ * @var string|null
+ */
protected $autonomousSystemOrganization;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
$this->autonomousSystemNumber = $this->get('autonomous_system_number');
diff --git a/vendor/geoip2/geoip2/src/Model/City.php b/vendor/geoip2/geoip2/src/Model/City.php index bf8e352..701e9db 100644 --- a/vendor/geoip2/geoip2/src/Model/City.php +++ b/vendor/geoip2/geoip2/src/Model/City.php @@ -1,13 +1,15 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
- * Model class for the data returned by GeoIP2 City web service and database.
+ * Model class for the data returned by City Plus web service and City
+ * database.
*
- * The only difference between the City and Insights model classes is which
- * fields in each record may be populated. See
- * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ * See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
+ * details.
*
* @property-read \GeoIp2\Record\City $city City data for the requested IP
* address.
@@ -31,28 +33,36 @@ class City extends Country {
/**
* @ignore
+ *
+ * @var \GeoIp2\Record\City
*/
protected $city;
+
/**
* @ignore
+ *
+ * @var \GeoIp2\Record\Location
*/
protected $location;
+
/**
* @ignore
+ *
+ * @var \GeoIp2\Record\Postal
*/
protected $postal;
+
/**
* @ignore
+ *
+ * @var array<\GeoIp2\Record\Subdivision>
*/
protected $subdivisions = [];
/**
* @ignore
- *
- * @param mixed $raw
- * @param mixed $locales
*/
- public function __construct($raw, $locales = ['en'])
+ public function __construct(array $raw, array $locales = ['en'])
{
parent::__construct($raw, $locales);
@@ -63,29 +73,28 @@ class City extends Country $this->createSubdivisions($raw, $locales);
}
- private function createSubdivisions($raw, $locales)
+ private function createSubdivisions(array $raw, array $locales): void
{
if (!isset($raw['subdivisions'])) {
return;
}
foreach ($raw['subdivisions'] as $sub) {
- array_push(
- $this->subdivisions,
+ $this->subdivisions[] =
new \GeoIp2\Record\Subdivision($sub, $locales)
- );
+ ;
}
}
/**
* @ignore
*
- * @param mixed $attr
+ * @return mixed
*/
- public function __get($attr)
+ public function __get(string $attr)
{
if ($attr === 'mostSpecificSubdivision') {
- return $this->$attr();
+ return $this->{$attr}();
}
return parent::__get($attr);
@@ -93,10 +102,8 @@ class City extends Country /**
* @ignore
- *
- * @param mixed $attr
*/
- public function __isset($attr)
+ public function __isset(string $attr): bool
{
if ($attr === 'mostSpecificSubdivision') {
// We always return a mostSpecificSubdivision, even if it is the
@@ -107,7 +114,7 @@ class City extends Country return parent::__isset($attr);
}
- private function mostSpecificSubdivision()
+ private function mostSpecificSubdivision(): \GeoIp2\Record\Subdivision
{
return empty($this->subdivisions) ?
new \GeoIp2\Record\Subdivision([], $this->locales) :
diff --git a/vendor/geoip2/geoip2/src/Model/ConnectionType.php b/vendor/geoip2/geoip2/src/Model/ConnectionType.php index 013e6c3..e55fda1 100644 --- a/vendor/geoip2/geoip2/src/Model/ConnectionType.php +++ b/vendor/geoip2/geoip2/src/Model/ConnectionType.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -18,16 +20,25 @@ use GeoIp2\Util; */
class ConnectionType extends AbstractModel
{
+ /**
+ * @var string|null
+ */
protected $connectionType;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
diff --git a/vendor/geoip2/geoip2/src/Model/Country.php b/vendor/geoip2/geoip2/src/Model/Country.php index 64d2650..67946b5 100644 --- a/vendor/geoip2/geoip2/src/Model/Country.php +++ b/vendor/geoip2/geoip2/src/Model/Country.php @@ -1,13 +1,13 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
* Model class for the data returned by GeoIP2 Country web service and database.
*
- * The only difference between the City and Insights model classes is which
- * fields in each record may be populated. See
- * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ * See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more details.
*
* @property-read \GeoIp2\Record\Continent $continent Continent data for the
* requested IP address.
@@ -26,24 +26,49 @@ namespace GeoIp2\Model; * the represented country differs from the country.
* @property-read \GeoIp2\Record\Traits $traits Data for the traits of the
* requested IP address.
+ * @property-read array $raw The raw data from the web service.
*/
class Country extends AbstractModel
{
+ /**
+ * @var \GeoIp2\Record\Continent
+ */
protected $continent;
+
+ /**
+ * @var \GeoIp2\Record\Country
+ */
protected $country;
+
+ /**
+ * @var array<string>
+ */
protected $locales;
+
+ /**
+ * @var \GeoIp2\Record\MaxMind
+ */
protected $maxmind;
+
+ /**
+ * @var \GeoIp2\Record\Country
+ */
protected $registeredCountry;
+
+ /**
+ * @var \GeoIp2\Record\RepresentedCountry
+ */
protected $representedCountry;
+
+ /**
+ * @var \GeoIp2\Record\Traits
+ */
protected $traits;
/**
* @ignore
- *
- * @param mixed $raw
- * @param mixed $locales
*/
- public function __construct($raw, $locales = ['en'])
+ public function __construct(array $raw, array $locales = ['en'])
{
parent::__construct($raw);
diff --git a/vendor/geoip2/geoip2/src/Model/Domain.php b/vendor/geoip2/geoip2/src/Model/Domain.php index 57982f7..df5e5cc 100644 --- a/vendor/geoip2/geoip2/src/Model/Domain.php +++ b/vendor/geoip2/geoip2/src/Model/Domain.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -18,16 +20,25 @@ use GeoIp2\Util; */
class Domain extends AbstractModel
{
+ /**
+ * @var string|null
+ */
protected $domain;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
diff --git a/vendor/geoip2/geoip2/src/Model/Enterprise.php b/vendor/geoip2/geoip2/src/Model/Enterprise.php index 7f153fa..48becc6 100644 --- a/vendor/geoip2/geoip2/src/Model/Enterprise.php +++ b/vendor/geoip2/geoip2/src/Model/Enterprise.php @@ -1,13 +1,14 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
* Model class for the data returned by GeoIP2 Enterprise database lookups.
*
- * The only difference between the City and Enterprise model classes is which
- * fields in each record may be populated. See
- * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ * See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
+ * details.
*/
class Enterprise extends City
{
diff --git a/vendor/geoip2/geoip2/src/Model/Insights.php b/vendor/geoip2/geoip2/src/Model/Insights.php index df3a54c..320ef85 100644 --- a/vendor/geoip2/geoip2/src/Model/Insights.php +++ b/vendor/geoip2/geoip2/src/Model/Insights.php @@ -1,13 +1,14 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
- * Model class for the data returned by GeoIP2 Precision: Insights web service.
+ * Model class for the data returned by GeoIP2 Insights web service.
*
- * The only difference between the City and Insights model classes is which
- * fields in each record may be populated. See
- * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ * See https://dev.maxmind.com/geoip/docs/web-services?lang=en for
+ * more details.
*/
class Insights extends City
{
diff --git a/vendor/geoip2/geoip2/src/Model/Isp.php b/vendor/geoip2/geoip2/src/Model/Isp.php index aa30f74..0f7a376 100644 --- a/vendor/geoip2/geoip2/src/Model/Isp.php +++ b/vendor/geoip2/geoip2/src/Model/Isp.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -14,6 +16,12 @@ use GeoIp2\Util; * address.
* @property-read string|null $isp The name of the ISP associated with the IP
* address.
+ * @property-read string|null $mobileCountryCode The [mobile country code
+ * (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
+ * the IP address and ISP.
+ * @property-read string|null $mobileNetworkCode The [mobile network code
+ * (MNC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
+ * the IP address and ISP.
* @property-read string|null $organization The name of the organization associated
* with the IP address.
* @property-read string $ipAddress The IP address that the data in the model is
@@ -24,25 +32,58 @@ use GeoIp2\Util; */
class Isp extends AbstractModel
{
+ /**
+ * @var int|null
+ */
protected $autonomousSystemNumber;
+
+ /**
+ * @var string|null
+ */
protected $autonomousSystemOrganization;
+
+ /**
+ * @var string|null
+ */
protected $isp;
+
+ /**
+ * @var string|null
+ */
+ protected $mobileCountryCode;
+
+ /**
+ * @var string|null
+ */
+ protected $mobileNetworkCode;
+
+ /**
+ * @var string|null
+ */
protected $organization;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
$this->autonomousSystemNumber = $this->get('autonomous_system_number');
$this->autonomousSystemOrganization =
$this->get('autonomous_system_organization');
$this->isp = $this->get('isp');
+ $this->mobileCountryCode = $this->get('mobile_country_code');
+ $this->mobileNetworkCode = $this->get('mobile_network_code');
$this->organization = $this->get('organization');
$ipAddress = $this->get('ip_address');
diff --git a/vendor/geoip2/geoip2/src/ProviderInterface.php b/vendor/geoip2/geoip2/src/ProviderInterface.php index 9162069..5d5209a 100644 --- a/vendor/geoip2/geoip2/src/ProviderInterface.php +++ b/vendor/geoip2/geoip2/src/ProviderInterface.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2;
interface ProviderInterface
@@ -9,12 +11,12 @@ interface ProviderInterface *
* @return \GeoIp2\Model\Country a Country model for the requested IP address
*/
- public function country($ipAddress);
+ public function country(string $ipAddress): Model\Country;
/**
* @param string $ipAddress an IPv4 or IPv6 address to lookup
*
* @return \GeoIp2\Model\City a City model for the requested IP address
*/
- public function city($ipAddress);
+ public function city(string $ipAddress): Model\City;
}
diff --git a/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php b/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php index 64bff36..d9fa371 100644 --- a/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php +++ b/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php @@ -1,18 +1,20 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
abstract class AbstractPlaceRecord extends AbstractRecord
{
+ /**
+ * @var array<string>
+ */
private $locales;
/**
* @ignore
- *
- * @param mixed $record
- * @param mixed $locales
*/
- public function __construct($record, $locales = ['en'])
+ public function __construct(?array $record, array $locales = ['en'])
{
$this->locales = $locales;
parent::__construct($record);
@@ -21,9 +23,9 @@ abstract class AbstractPlaceRecord extends AbstractRecord /**
* @ignore
*
- * @param mixed $attr
+ * @return mixed
*/
- public function __get($attr)
+ public function __get(string $attr)
{
if ($attr === 'name') {
return $this->name();
@@ -34,26 +36,25 @@ abstract class AbstractPlaceRecord extends AbstractRecord /**
* @ignore
- *
- * @param mixed $attr
*/
- public function __isset($attr)
+ public function __isset(string $attr): bool
{
if ($attr === 'name') {
- return $this->firstSetNameLocale() === null ? false : true;
+ return $this->firstSetNameLocale() !== null;
}
return parent::__isset($attr);
}
- private function name()
+ private function name(): ?string
{
$locale = $this->firstSetNameLocale();
+ // @phpstan-ignore-next-line
return $locale === null ? null : $this->names[$locale];
}
- private function firstSetNameLocale()
+ private function firstSetNameLocale(): ?string
{
foreach ($this->locales as $locale) {
if (isset($this->names[$locale])) {
diff --git a/vendor/geoip2/geoip2/src/Record/AbstractRecord.php b/vendor/geoip2/geoip2/src/Record/AbstractRecord.php index b2441ad..6c17ea5 100644 --- a/vendor/geoip2/geoip2/src/Record/AbstractRecord.php +++ b/vendor/geoip2/geoip2/src/Record/AbstractRecord.php @@ -1,17 +1,20 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
abstract class AbstractRecord implements \JsonSerializable
{
+ /**
+ * @var array<string, mixed>
+ */
private $record;
/**
* @ignore
- *
- * @param mixed $record
*/
- public function __construct($record)
+ public function __construct(?array $record)
{
$this->record = isset($record) ? $record : [];
}
@@ -19,42 +22,45 @@ abstract class AbstractRecord implements \JsonSerializable /**
* @ignore
*
- * @param mixed $attr
+ * @return mixed
*/
- public function __get($attr)
+ public function __get(string $attr)
{
// XXX - kind of ugly but greatly reduces boilerplate code
$key = $this->attributeToKey($attr);
if ($this->__isset($attr)) {
return $this->record[$key];
- } elseif ($this->validAttribute($attr)) {
+ }
+ if ($this->validAttribute($attr)) {
if (preg_match('/^is_/', $key)) {
return false;
}
return null;
}
+
throw new \RuntimeException("Unknown attribute: $attr");
}
- public function __isset($attr)
+ public function __isset(string $attr): bool
{
- return $this->validAttribute($attr) &&
- isset($this->record[$this->attributeToKey($attr)]);
+ return $this->validAttribute($attr)
+ && isset($this->record[$this->attributeToKey($attr)]);
}
- private function attributeToKey($attr)
+ private function attributeToKey(string $attr): string
{
return strtolower(preg_replace('/([A-Z])/', '_\1', $attr));
}
- private function validAttribute($attr)
+ private function validAttribute(string $attr): bool
{
+ // @phpstan-ignore-next-line
return \in_array($attr, $this->validAttributes, true);
}
- public function jsonSerialize()
+ public function jsonSerialize(): ?array
{
return $this->record;
}
diff --git a/vendor/geoip2/geoip2/src/Record/City.php b/vendor/geoip2/geoip2/src/Record/City.php index f2e1f61..ca0eebb 100644 --- a/vendor/geoip2/geoip2/src/Record/City.php +++ b/vendor/geoip2/geoip2/src/Record/City.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -16,7 +18,7 @@ namespace GeoIp2\Record; * @property-read string|null $name The name of the city based on the locales list
* passed to the constructor. This attribute is returned by all location
* services and databases.
- * @property-read array|null $names A array map where the keys are locale codes
+ * @property-read array|null $names An array map where the keys are locale codes
* and the values are names. This attribute is returned by all location
* services and databases.
*/
@@ -24,6 +26,8 @@ class City extends AbstractPlaceRecord {
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = ['confidence', 'geonameId', 'names'];
}
diff --git a/vendor/geoip2/geoip2/src/Record/Continent.php b/vendor/geoip2/geoip2/src/Record/Continent.php index 8495713..55b8397 100644 --- a/vendor/geoip2/geoip2/src/Record/Continent.php +++ b/vendor/geoip2/geoip2/src/Record/Continent.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -23,6 +25,8 @@ class Continent extends AbstractPlaceRecord {
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'code',
diff --git a/vendor/geoip2/geoip2/src/Record/Country.php b/vendor/geoip2/geoip2/src/Record/Country.php index 5ff810d..155d189 100644 --- a/vendor/geoip2/geoip2/src/Record/Country.php +++ b/vendor/geoip2/geoip2/src/Record/Country.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -29,6 +31,8 @@ class Country extends AbstractPlaceRecord {
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'confidence',
diff --git a/vendor/geoip2/geoip2/src/Record/Location.php b/vendor/geoip2/geoip2/src/Record/Location.php index 8de109f..54e43b9 100644 --- a/vendor/geoip2/geoip2/src/Record/Location.php +++ b/vendor/geoip2/geoip2/src/Record/Location.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -37,6 +39,8 @@ class Location extends AbstractRecord {
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'averageIncome',
diff --git a/vendor/geoip2/geoip2/src/Record/MaxMind.php b/vendor/geoip2/geoip2/src/Record/MaxMind.php index 0c2cdd3..33f6c7c 100644 --- a/vendor/geoip2/geoip2/src/Record/MaxMind.php +++ b/vendor/geoip2/geoip2/src/Record/MaxMind.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -14,6 +16,8 @@ class MaxMind extends AbstractRecord {
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = ['queriesRemaining'];
}
diff --git a/vendor/geoip2/geoip2/src/Record/Postal.php b/vendor/geoip2/geoip2/src/Record/Postal.php index 5c65923..229c234 100644 --- a/vendor/geoip2/geoip2/src/Record/Postal.php +++ b/vendor/geoip2/geoip2/src/Record/Postal.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -21,6 +23,8 @@ class Postal extends AbstractRecord {
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = ['code', 'confidence'];
}
diff --git a/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php b/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php index 270da93..39bf0c3 100644 --- a/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php +++ b/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -15,6 +17,11 @@ namespace GeoIp2\Record; */
class RepresentedCountry extends Country
{
+ /**
+ * @ignore
+ *
+ * @var array<string>
+ */
protected $validAttributes = [
'confidence',
'geonameId',
diff --git a/vendor/geoip2/geoip2/src/Record/Subdivision.php b/vendor/geoip2/geoip2/src/Record/Subdivision.php index 4ad4e7f..0534b94 100644 --- a/vendor/geoip2/geoip2/src/Record/Subdivision.php +++ b/vendor/geoip2/geoip2/src/Record/Subdivision.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -30,6 +32,8 @@ class Subdivision extends AbstractPlaceRecord {
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'confidence',
diff --git a/vendor/geoip2/geoip2/src/Record/Traits.php b/vendor/geoip2/geoip2/src/Record/Traits.php index f02c693..d725d98 100644 --- a/vendor/geoip2/geoip2/src/Record/Traits.php +++ b/vendor/geoip2/geoip2/src/Record/Traits.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
use GeoIp2\Util;
@@ -12,13 +14,13 @@ use GeoIp2\Util; * @property-read int|null $autonomousSystemNumber The autonomous system number
* associated with the IP address. See
* https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This attribute
- * is only available from the City and Insights web service and the GeoIP2
- * Enterprise database.
+ * is only available from the City Plus and Insights web services and the
+ * GeoIP2 Enterprise database.
* @property-read string|null $autonomousSystemOrganization The organization
* associated with the registered autonomous system number for the IP address.
* See https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This
- * attribute is only available from the City and Insights web service and the
- * GeoIP2 Enterprise database.
+ * attribute is only available from the City Plus and Insights web services and
+ * the GeoIP2 Enterprise database.
* @property-read string|null $connectionType The connection type may take the
* following values: "Dialup", "Cable/DSL", "Corporate", "Cellular".
* Additional values may be added in the future. This attribute is only
@@ -26,7 +28,7 @@ use GeoIp2\Util; * @property-read string|null $domain The second level domain associated with the
* IP address. This will be something like "example.com" or "example.co.uk",
* not "foo.example.com". This attribute is only available from the
- * City and Insights web service and the GeoIP2 Enterprise
+ * City Plus and Insights web services and the GeoIP2 Enterprise
* database.
* @property-read string $ipAddress The IP address that the data in the model
* is for. If you performed a "me" lookup against the web service, this
@@ -36,7 +38,7 @@ use GeoIp2\Util; * points.
* @property-read bool $isAnonymous This is true if the IP address belongs to
* any sort of anonymous network. This property is only available from GeoIP2
- * Precision Insights.
+ * Insights.
* @property-read bool $isAnonymousProxy *Deprecated.* Please see our GeoIP2
* Anonymous IP database
* (https://www.maxmind.com/en/geoip2-anonymous-ip-database) to determine
@@ -45,39 +47,49 @@ use GeoIp2\Util; * registered to an anonymous VPN provider. If a VPN provider does not register
* subnets under names associated with them, we will likely only flag their IP
* ranges using the isHostingProvider property. This property is only available
- * from GeoIP2 Precision Insights.
+ * from GeoIP2 Insights.
* @property-read bool $isHostingProvider This is true if the IP address belongs
* to a hosting or VPN provider (see description of isAnonymousVpn property).
- * This property is only available from GeoIP2 Precision Insights.
+ * This property is only available from GeoIP2 Insights.
* @property-read bool $isLegitimateProxy This attribute is true if MaxMind
* believes this IP address to be a legitimate proxy, such as an internal
* VPN used by a corporation. This attribute is only available in the GeoIP2
* Enterprise database.
* @property-read bool $isPublicProxy This is true if the IP address belongs to
- * a public proxy. This property is only available from GeoIP2 Precision
- * Insights.
+ * a public proxy. This property is only available from GeoIP2 Insights.
+ * @property-read bool $isResidentialProxy This is true if the IP address is
+ * on a suspected anonymizing network and belongs to a residential ISP. This
+ * property is only available from GeoIP2 Insights.
* @property-read bool $isSatelliteProvider *Deprecated.* Due to the
* increased coverage by mobile carriers, very few satellite providers now
* serve multiple countries. As a result, the output does not provide
* sufficiently relevant data for us to maintain it.
* @property-read bool $isTorExitNode This is true if the IP address is a Tor
- * exit node. This property is only available from GeoIP2 Precision Insights.
+ * exit node. This property is only available from GeoIP2 Insights.
* @property-read string|null $isp The name of the ISP associated with the IP
- * address. This attribute is only available from the City and Insights web
- * services and the GeoIP2 Enterprise database.
+ * address. This attribute is only available from the City Plus and Insights
+ * web services and the GeoIP2 Enterprise database.
* @property-read string $network The network in CIDR notation associated with
* the record. In particular, this is the largest network where all of the
* fields besides $ipAddress have the same value.
- * @property-read string|null $organization The name of the organization associated
- * with the IP address. This attribute is only available from the City and
+ * @property-read string|null $organization The name of the organization
+ * associated with the IP address. This attribute is only available from the
+ * City Plus and Insights web services and the GeoIP2 Enterprise database.
+ * @property-read string|null $mobileCountryCode The [mobile country code
+ * (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
+ * the IP address and ISP. This property is available from the City Plus and
* Insights web services and the GeoIP2 Enterprise database.
- * @property-read float|null $staticIPScore An indicator of how static or
+ * @property-read string|null $mobileNetworkCode The [mobile network code
+ * (MNC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
+ * the IP address and ISP. This property is available from the City Plus and
+ * Insights web services and the GeoIP2 Enterprise database.
+ * @property-read float|null $staticIpScore An indicator of how static or
* dynamic an IP address is. This property is only available from GeoIP2
- * Precision Insights.
+ * Insights.
* @property-read int|null $userCount The estimated number of users sharing
* the IP/network during the past 24 hours. For IPv4, the count is for the
* individual IP. For IPv6, the count is for the /64 network. This property is
- * only available from GeoIP2 Precision Insights.
+ * only available from GeoIP2 Insights.
* @property-read string|null $userType <p>The user type associated with the IP
* address. This can be one of the following values:</p>
* <ul>
@@ -85,6 +97,7 @@ use GeoIp2\Util; * <li>cafe
* <li>cellular
* <li>college
+ * <li>consumer_privacy_network
* <li>content_delivery_network
* <li>dialup
* <li>government
@@ -106,6 +119,8 @@ class Traits extends AbstractRecord {
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'autonomousSystemNumber',
@@ -120,8 +135,11 @@ class Traits extends AbstractRecord 'isLegitimateProxy',
'isp',
'isPublicProxy',
+ 'isResidentialProxy',
'isSatelliteProvider',
'isTorExitNode',
+ 'mobileCountryCode',
+ 'mobileNetworkCode',
'network',
'organization',
'staticIpScore',
@@ -129,9 +147,9 @@ class Traits extends AbstractRecord 'userType',
];
- public function __construct($record)
+ public function __construct(?array $record)
{
- if (!isset($record['network']) && isset($record['ip_address']) && isset($record['prefix_len'])) {
+ if (!isset($record['network']) && isset($record['ip_address'], $record['prefix_len'])) {
$record['network'] = Util::cidr($record['ip_address'], $record['prefix_len']);
}
diff --git a/vendor/geoip2/geoip2/src/Util.php b/vendor/geoip2/geoip2/src/Util.php index ac6d14c..4f08744 100644 --- a/vendor/geoip2/geoip2/src/Util.php +++ b/vendor/geoip2/geoip2/src/Util.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2;
class Util
@@ -10,11 +12,8 @@ class Util *
* @internal
* @ignore
- *
- * @param mixed $ipAddress
- * @param mixed $prefixLen
*/
- public static function cidr($ipAddress, $prefixLen)
+ public static function cidr(string $ipAddress, int $prefixLen): string
{
$ipBytes = inet_pton($ipAddress);
$networkBytes = str_repeat("\0", \strlen($ipBytes));
diff --git a/vendor/geoip2/geoip2/src/WebService/Client.php b/vendor/geoip2/geoip2/src/WebService/Client.php index bebca56..c84d409 100644 --- a/vendor/geoip2/geoip2/src/WebService/Client.php +++ b/vendor/geoip2/geoip2/src/WebService/Client.php @@ -1,5 +1,7 @@ <?php
+declare(strict_types=1);
+
namespace GeoIp2\WebService;
use GeoIp2\Exception\AddressNotFoundException;
@@ -8,13 +10,16 @@ use GeoIp2\Exception\GeoIp2Exception; use GeoIp2\Exception\HttpException;
use GeoIp2\Exception\InvalidRequestException;
use GeoIp2\Exception\OutOfQueriesException;
+use GeoIp2\Model\City;
+use GeoIp2\Model\Country;
+use GeoIp2\Model\Insights;
use GeoIp2\ProviderInterface;
use MaxMind\WebService\Client as WsClient;
/**
- * This class provides a client API for all the GeoIP2 Precision web services.
- * The services are Country, City, and Insights. Each service returns a
- * different set of data about an IP address, with Country returning the
+ * This class provides a client API for all the GeoIP2 web services.
+ * The services are Country, City Plus, and Insights. Each service returns
+ * a different set of data about an IP address, with Country returning the
* least data and Insights the most.
*
* Each web service is represented by a different model class, and these model
@@ -43,11 +48,22 @@ use MaxMind\WebService\Client as WsClient; */
class Client implements ProviderInterface
{
+ /**
+ * @var array<string>
+ */
private $locales;
+
+ /**
+ * @var WsClient
+ */
private $client;
+
+ /**
+ * @var string
+ */
private static $basePath = '/geoip/v2.1';
- const VERSION = 'v2.10.0';
+ public const VERSION = 'v2.13.0';
/**
* Constructor.
@@ -57,7 +73,10 @@ class Client implements ProviderInterface * @param array $locales list of locale codes to use in name property
* from most preferred to least preferred
* @param array $options array of options. Valid options include:
- * * `host` - The host to use when querying the web service.
+ * * `host` - The host to use when querying the web
+ * service. To query the GeoLite2 web service
+ * instead of the GeoIP2 web service, set the
+ * host to `geolite.info`.
* * `timeout` - Timeout in seconds.
* * `connectTimeout` - Initial connection timeout in seconds.
* * `proxy` - The HTTP proxy to use. May include a schema, port,
@@ -65,15 +84,16 @@ class Client implements ProviderInterface * `http://username:password@127.0.0.1:10`.
*/
public function __construct(
- $accountId,
- $licenseKey,
- $locales = ['en'],
- $options = []
+ int $accountId,
+ string $licenseKey,
+ array $locales = ['en'],
+ array $options = []
) {
$this->locales = $locales;
// This is for backwards compatibility. Do not remove except for a
// major version bump.
+ // @phpstan-ignore-next-line
if (\is_string($options)) {
$options = ['host' => $options];
}
@@ -87,13 +107,13 @@ class Client implements ProviderInterface $this->client = new WsClient($accountId, $licenseKey, $options);
}
- private function userAgent()
+ private function userAgent(): string
{
return 'GeoIP2-API/' . self::VERSION;
}
/**
- * This method calls the GeoIP2 Precision: City service.
+ * This method calls the City Plus service.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
@@ -108,23 +128,22 @@ class Client implements ProviderInterface * @throws \GeoIp2\Exception\InvalidRequestException} if your request was received by the web service but is
* invalid for some other reason. This may indicate an issue
* with this API. Please report the error to MaxMind.
- * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
- * This could indicate a problem with the connection between
- * your server and the web service or that the web service
- * returned an invalid document or 500 error code
- * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
- * class to the above exceptions. It will be thrown directly
- * if a 200 status code is returned but the body is invalid.
- *
- * @return \GeoIp2\Model\City
+ * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
+ * This could indicate a problem with the connection between
+ * your server and the web service or that the web service
+ * returned an invalid document or 500 error code
+ * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
+ * class to the above exceptions. It will be thrown directly
+ * if a 200 status code is returned but the body is invalid.
*/
- public function city($ipAddress = 'me')
+ public function city(string $ipAddress = 'me'): City
{
- return $this->responseFor('city', 'City', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->responseFor('city', City::class, $ipAddress);
}
/**
- * This method calls the GeoIP2 Precision: Country service.
+ * This method calls the Country service.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
@@ -138,24 +157,23 @@ class Client implements ProviderInterface * @throws \GeoIp2\Exception\InvalidRequestException} if your request was received by the web service but is
* invalid for some other reason. This may indicate an
* issue with this API. Please report the error to MaxMind.
- * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error
- * code or message was returned. This could indicate a problem
- * with the connection between your server and the web service
- * or that the web service returned an invalid document or 500
- * error code.
- * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent class to the above exceptions. It
- * will be thrown directly if a 200 status code is returned but
- * the body is invalid.
- *
- * @return \GeoIp2\Model\Country
+ * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error
+ * code or message was returned. This could indicate a problem
+ * with the connection between your server and the web service
+ * or that the web service returned an invalid document or 500
+ * error code.
+ * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent class to the above exceptions. It
+ * will be thrown directly if a 200 status code is returned but
+ * the body is invalid.
*/
- public function country($ipAddress = 'me')
+ public function country(string $ipAddress = 'me'): Country
{
- return $this->responseFor('country', 'Country', $ipAddress);
+ return $this->responseFor('country', Country::class, $ipAddress);
}
/**
- * This method calls the GeoIP2 Precision: Insights service.
+ * This method calls the Insights service. Insights is only supported by
+ * the GeoIP2 web service. The GeoLite2 web service does not support it.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
@@ -170,27 +188,27 @@ class Client implements ProviderInterface * @throws \GeoIp2\Exception\InvalidRequestException} if your request was received by the web service but is
* invalid for some other reason. This may indicate an
* issue with this API. Please report the error to MaxMind.
- * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
- * This could indicate a problem with the connection between
- * your server and the web service or that the web service
- * returned an invalid document or 500 error code
- * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
- * class to the above exceptions. It will be thrown directly
- * if a 200 status code is returned but the body is invalid.
- *
- * @return \GeoIp2\Model\Insights
+ * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
+ * This could indicate a problem with the connection between
+ * your server and the web service or that the web service
+ * returned an invalid document or 500 error code
+ * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
+ * class to the above exceptions. It will be thrown directly
+ * if a 200 status code is returned but the body is invalid.
*/
- public function insights($ipAddress = 'me')
+ public function insights(string $ipAddress = 'me'): Insights
{
- return $this->responseFor('insights', 'Insights', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->responseFor('insights', Insights::class, $ipAddress);
}
- private function responseFor($endpoint, $class, $ipAddress)
+ private function responseFor(string $endpoint, string $class, string $ipAddress): Country
{
$path = implode('/', [self::$basePath, $endpoint, $ipAddress]);
try {
- $body = $this->client->get('GeoIP2 ' . $class, $path);
+ $service = (new \ReflectionClass($class))->getShortName();
+ $body = $this->client->get('GeoIP2 ' . $service, $path);
} catch (\MaxMind\Exception\IpAddressNotFoundException $ex) {
throw new AddressNotFoundException(
$ex->getMessage(),
@@ -232,8 +250,6 @@ class Client implements ProviderInterface );
}
- $class = 'GeoIp2\\Model\\' . $class;
-
return new $class($body, $this->locales);
}
}
|