Skip to content

Enable PHP 8.0 support #1102

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

Merged
merged 8 commits into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PHP Composer

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0']
deps: ['low', 'high']
include:
- php-version: '7.3'

name: PHP ${{ matrix.php-version }} (${{ matrix.deps }})

steps:
- uses: actions/checkout@v2

- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: curl

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
if: ${{ matrix.deps == null }}
run: composer update --no-progress --prefer-dist
- name: Install dependencies (low)
if: ${{ matrix.deps == 'low' }}
run: composer update --no-progress --prefer-lowest --prefer-stable
- name: Install dependencies (high)
if: ${{ matrix.deps == 'high' }}
run: composer update --no-progress

- name: Run test suite
run: composer run-script test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ vendor/
composer.lock
composer.phar
phpunit.xml
.phpunit.result.cache
php-cs-fixer.phar
.puli/
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ cache:
matrix:
fast_finish: true
include:
- php: 8.0
env: deps="low"
- php: 8.0
env: deps="high"
- php: 7.4
env: deps="low"
- php: 7.4
env: deps="high"
- php: 7.2
- php: 7.3
- php: 7.4
- php: 8.0

before_install:
- |
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.3 || ^8.0",
"igorw/get-in": "^1.0",
"php-http/client-implementation": "^1.0",
"php-http/discovery": "^1.4",
"php-http/httplug": "^1.0",
"php-http/httplug": "^2.2",
"php-http/message-factory": "^1.0.2",
"php-http/promise": "^1.0",
"psr/http-message-implementation": "^1.0",
Expand All @@ -36,10 +36,10 @@
"geoip2/geoip2": "~2.0",
"nyholm/nsa": "^1.1",
"nyholm/psr7": "^1.0",
"php-http/curl-client": "^1.7",
"php-http/curl-client": "^2.2",
"php-http/message": "^1.0",
"php-http/mock-client": "^1.0",
"phpunit/phpunit": "^7.5",
"phpunit/phpunit": "^9.5",
"symfony/stopwatch": "~2.5"
},
"suggest": {
Expand Down
123 changes: 60 additions & 63 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,68 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
>
<php>
<!--
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
>
<coverage>
<include>
<directory>./src/</directory>
</include>
<exclude>
<directory>./src/Common/Tests</directory>
<directory>./src/Http/Tests</directory>
<directory>./src/Provider/*/Tests</directory>
<directory>./src/Common/vendor</directory>
<directory>./src/Http/vendor</directory>
<directory>./src/Provider/*/vendor</directory>
</exclude>
</coverage>
<php>
<!--
Turn this parameter to 'false' or comment it to bypass
the caching layer. See the `CachedResponseAdapter` class.
-->
<server name="USE_CACHED_RESPONSES" value="true" />

<!-- API Keys -->
<server name="ALGOLIA_API_KEY" value="YOUR_API_KEY" />
<server name="ALGOLIA_APP_ID" value="YOUR_APP_ID" />
<server name="BINGMAPS_API_KEY" value="YOUR_API_KEY" />
<server name="GEOIPS_API_KEY" value="YOUR_API_KEY" />
<server name="GEONAMES_USERNAME" value="YOUR_USERNAME" />
<server name="GOOGLE_GEOCODING_KEY" value="YOUR_GEOCODING_KEY" />
<server name="GRAPHHOPPER_API_KEY" value="YOUR_API_KEY" />
<server name="HERE_APP_CODE" value="YOUR_APP_CODE" />
<server name="HERE_APP_ID" value="YOUR_APP_ID" />
<server name="HERE_API_KEY" value="YOUR_API_KEY" />
<server name="IPINFODB_API_KEY" value="YOUR_API_KEY" />
<server name="IP2LOCATION_API_KEY" value="YOUR_API_KEY" />
<server name="IPSTACK_API_KEY" value="YOUR_API_KEY" />
<server name="LOCATIONIQ_API_KEY" value="YOUR_API_KEY" />
<server name="MAPBOX_GEOCODING_KEY" value="YOUR_GEOCODING_KEY" />
<server name="MAPQUEST_API_KEY" value="YOUR_API_KEY" />
<server name="MAPZEN_API_KEY" value="YOUR_MAPZEN_API_KEY" />
<server name="OPENCAGE_API_KEY" value="YOUR_GEOCODING_KEY" />
<server name="PICKPOINT_API_KEY" value="YOUR_API_KEY" />
<server name="TOMTOM_MAP_KEY" value="YOUR_MAP_KEY" />
<server name="GEOCODE_EARTH_API_KEY" value="YOUR_GEOCODE_EARTH_API_KEY" />
<server name="OPEN_ROUTE_SERVICE_API_KEY" value="YOUR_OPEN_ROUTE_SERVICE_API_KEY" />
<server name="AZURE_MAPS_SUBSCRIPTION_KEY" value="YOUR_AZURE_MAPS_SUBSCRIPTION_KEY" />
<!--<server name="MAXMIND_API_KEY" value="YOUR_API_KEY" />-->
</php>

<testsuites>
<testsuite name="Geocoder Test Suite">
<directory>./tests/</directory>
<directory>./src/Common/Tests/</directory>
<directory>./src/Http/Tests/</directory>
<directory>./src/Provider/*/Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src/</directory>
<exclude>
<directory>./src/Common/Tests</directory>
<directory>./src/Http/Tests</directory>
<directory>./src/Provider/*/Tests</directory>
<directory>./src/Common/vendor</directory>
<directory>./src/Http/vendor</directory>
<directory>./src/Provider/*/vendor</directory>
</exclude>
</whitelist>
</filter>
<server name="USE_CACHED_RESPONSES" value="true"/>
<!-- API Keys -->
<server name="ALGOLIA_API_KEY" value="YOUR_API_KEY"/>
<server name="ALGOLIA_APP_ID" value="YOUR_APP_ID"/>
<server name="BINGMAPS_API_KEY" value="YOUR_API_KEY"/>
<server name="GEOIPS_API_KEY" value="YOUR_API_KEY"/>
<server name="GEONAMES_USERNAME" value="YOUR_USERNAME"/>
<server name="GOOGLE_GEOCODING_KEY" value="YOUR_GEOCODING_KEY"/>
<server name="GRAPHHOPPER_API_KEY" value="YOUR_API_KEY"/>
<server name="HERE_APP_CODE" value="YOUR_APP_CODE"/>
<server name="HERE_APP_ID" value="YOUR_APP_ID"/>
<server name="HERE_API_KEY" value="YOUR_API_KEY"/>
<server name="IPINFODB_API_KEY" value="YOUR_API_KEY"/>
<server name="IP2LOCATION_API_KEY" value="YOUR_API_KEY"/>
<server name="IPSTACK_API_KEY" value="YOUR_API_KEY"/>
<server name="LOCATIONIQ_API_KEY" value="YOUR_API_KEY"/>
<server name="MAPBOX_GEOCODING_KEY" value="YOUR_GEOCODING_KEY"/>
<server name="MAPQUEST_API_KEY" value="YOUR_API_KEY"/>
<server name="MAPZEN_API_KEY" value="YOUR_MAPZEN_API_KEY"/>
<server name="OPENCAGE_API_KEY" value="YOUR_GEOCODING_KEY"/>
<server name="PICKPOINT_API_KEY" value="YOUR_API_KEY"/>
<server name="TOMTOM_MAP_KEY" value="YOUR_MAP_KEY"/>
<server name="GEOCODE_EARTH_API_KEY" value="YOUR_GEOCODE_EARTH_API_KEY"/>
<server name="OPEN_ROUTE_SERVICE_API_KEY" value="YOUR_OPEN_ROUTE_SERVICE_API_KEY"/>
<server name="AZURE_MAPS_SUBSCRIPTION_KEY" value="YOUR_AZURE_MAPS_SUBSCRIPTION_KEY"/>
<!--<server name="MAXMIND_API_KEY" value="YOUR_API_KEY" />-->
</php>
<testsuites>
<testsuite name="Geocoder Test Suite">
<directory>./src/Common/Tests/</directory>
<directory>./src/Http/Tests/</directory>
<directory>./src/Provider/*/Tests/</directory>
</testsuite>
</testsuites>
</phpunit>
10 changes: 5 additions & 5 deletions src/Common/Tests/Dumper/GeoArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GeoArrayTest extends TestCase
*/
private $dumper;

protected function setUp()
protected function setUp(): void
{
$this->dumper = new GeoArray();
}
Expand All @@ -47,7 +47,7 @@ public function testDump()

$result = $this->dumper->dump($address);

$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertEquals($expected, $result);
}

Expand All @@ -71,7 +71,7 @@ public function testDumpWithData()

$result = $this->dumper->dump($address);

$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertEquals($expected, $result);
}

Expand Down Expand Up @@ -107,7 +107,7 @@ public function testDumpWithBounds()

$result = $this->dumper->dump($address);

$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertEquals($expected, $result);
}

Expand Down Expand Up @@ -147,7 +147,7 @@ public function testDumpWithProperties()

$result = $this->dumper->dump($address);

$this->assertInternalType('array', $result);
$this->assertIsArray($result);
$this->assertEquals($expected, $result);
}
}
2 changes: 1 addition & 1 deletion src/Common/Tests/Dumper/GeoJsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GeoJsonTest extends TestCase
*/
private $dumper;

public function setUp()
public function setUp(): void
{
$this->dumper = new GeoJson();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Tests/Dumper/GpxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GpxTest extends TestCase
*/
private $dumper;

public function setUp()
public function setUp(): void
{
$this->dumper = new Gpx();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Tests/Dumper/KmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class KmlTest extends TestCase
*/
private $dumper;

public function setUp()
public function setUp(): void
{
$this->dumper = new Kml();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Tests/Dumper/WkbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WkbTest extends TestCase
*/
private $dumper;

public function setUp()
public function setUp(): void
{
$this->dumper = new Wkb();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Tests/Dumper/WktTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WktTest extends TestCase
*/
private $dumper;

public function setUp()
public function setUp(): void
{
$this->dumper = new Wkt();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Tests/Formatter/StringFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StringFormatterTest extends TestCase
*/
private $formatter;

public function setUp()
public function setUp(): void
{
$this->formatter = new StringFormatter();
}
Expand Down
2 changes: 2 additions & 0 deletions src/Common/Tests/Model/AddressCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class AddressCollectionTest extends TestCase
*/
public function testFirstOnEmpty()
{
$this->expectException(\Geocoder\Exception\CollectionIsEmpty::class);

$collection = new AddressCollection([]);
$collection->first();
}
Expand Down
19 changes: 8 additions & 11 deletions src/Common/Tests/ProviderAggregatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ProviderAggregatorTest extends TestCase
*/
protected $geocoder;

protected function setUp()
protected function setUp(): void
{
$this->geocoder = new ProviderAggregator();
}
Expand Down Expand Up @@ -82,22 +82,20 @@ public function testRegisterProviders()
$this->assertSame(['test' => $provider], NSA::getProperty($this->geocoder, 'providers'));
}

/**
* @expectedException \Geocoder\Exception\ProviderNotRegistered
* @expectedExceptionMessage Provider "non_existant" is not registered, so you cannot use it. Did you forget to register it or made a typo? Registered providers are: test1.
*/
public function testUsingNonExistantProviderShouldThrowAnException()
{
$this->expectException(\Geocoder\Exception\ProviderNotRegistered::class);
$this->expectExceptionMessage('Provider "non_existant" is not registered, so you cannot use it. Did you forget to register it or made a typo? Registered providers are: test1.');

$this->geocoder->registerProvider(new MockProvider('test1'));

$this->geocoder->using('non_existant');
}

/**
* @expectedException \Geocoder\Exception\ProviderNotRegistered
*/
public function testUsingAnEmptyProviderNameShouldThrowAnException()
{
$this->expectException(\Geocoder\Exception\ProviderNotRegistered::class);

$this->geocoder->using('');
}

Expand All @@ -119,11 +117,10 @@ public function testGetProviders()
$this->assertArrayHasKey('test2', $result);
}

/**
* @expectedException \RuntimeException
*/
public function testGetProvider()
{
$this->expectException(\RuntimeException::class);

NSA::invokeMethod($this->geocoder, 'getProvider', GeocodeQuery::create('foo'), [], null);
$this->fail('getProvider() should throw an exception');
}
Expand Down
Loading