Skip to content

Commit

Permalink
Add PHPStan in CI (#1193)
Browse files Browse the repository at this point in the history
* Add PHPStan

* Update php.yml

* Update composer.json

* Fix PHPStan level 0

* Fix PHPStan level 1

* Update phpstan.neon

* Fix PHPStan level 2

* Update composer.json

* Fix PHPStan level 3

* Fix tests

* Fix PHPStan level 4

* Update src/Common/Tests/TimedGeocoderTest.php

Co-authored-by: Tomas Norkūnas <[email protected]>

* Update src/Provider/Cache/Tests/ProviderCacheTest.php

Co-authored-by: Tomas Norkūnas <[email protected]>

* Update src/Provider/Cache/Tests/ProviderCacheTest.php

Co-authored-by: Tomas Norkūnas <[email protected]>

* Update src/Provider/GeoIP2/Tests/GeoIP2Test.php

Co-authored-by: Tomas Norkūnas <[email protected]>

* Fix PHPStan level 5

* Normalize composer.json

* Rename analyse script

* Update composer.json

* Update IntegrationTest

* Update AlgoliaPlacesTest

* Update composer.json

* Update RequestInterface vs. getParsedResponse()

* Update src/Plugin/PluginProvider.php

Co-authored-by: Tomas Norkūnas <[email protected]>

* Update src/Plugin/PluginProvider.php

Co-authored-by: Tomas Norkūnas <[email protected]>

* Use PHPStan baseline instead of ignore

See https://phpstan.org/user-guide/baseline

---------

Co-authored-by: Tomas Norkūnas <[email protected]>
  • Loading branch information
jbelien and norkunas committed Jul 16, 2023
1 parent b5a8033 commit 3d24f04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
17 changes: 8 additions & 9 deletions Tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
*/
class IntegrationTest extends ProviderIntegrationTest
{
protected $skippedTests = [
];
protected array $skippedTests = [];

protected $testAddress = false;
protected bool $testAddress = false;

protected $testReverse = false;
protected bool $testReverse = false;

protected $testIpv6 = false;
protected bool $testIpv6 = false;

protected $testHttpProvider = false;
protected bool $testHttpProvider = false;

public static function setUpBeforeClass(): void
{
Expand All @@ -50,13 +49,13 @@ protected function createProvider(ClientInterface $httpClient)
return new MaxMindBinary(__DIR__.'/fixtures/GeoLiteCity.dat');
}

protected function getCacheDir()
protected function getCacheDir(): string
{
return __DIR__.'/.cached_responses';
}

protected function getApiKey()
protected function getApiKey(): string
{
return null;
return '';
}
}
8 changes: 4 additions & 4 deletions Tests/MaxMindBinaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public function testLocationResultContainsExpectedFieldsForAnAmericanIp()
$result = $results->first();
$this->assertInstanceOf('\Geocoder\Model\Address', $result);

$this->assertEquals('43.089200000000005', $result->getCoordinates()->getLatitude(), '', 0.001);
$this->assertEquals('-76.025000000000006', $result->getCoordinates()->getLongitude(), '', 0.001);
$this->assertEqualsWithDelta(43.089200000000005, $result->getCoordinates()->getLatitude(), 0.001);
$this->assertEqualsWithDelta(-76.025000000000006, $result->getCoordinates()->getLongitude(), 0.001);
$this->assertNull($result->getBounds());
$this->assertNull($result->getStreetNumber());
$this->assertNull($result->getStreetName());
Expand All @@ -100,8 +100,8 @@ public function testLocationResultContainsExpectedFieldsForASpanishIp()
$result = $results->first();
$this->assertInstanceOf('\Geocoder\Model\Address', $result);

$this->assertEquals('41.543299999999988', $result->getCoordinates()->getLatitude(), '', 0.001);
$this->assertEquals('2.1093999999999937', $result->getCoordinates()->getLongitude(), '', 0.001);
$this->assertEqualsWithDelta(41.543299999999988, $result->getCoordinates()->getLatitude(), 0.001);
$this->assertEqualsWithDelta(2.1093999999999937, $result->getCoordinates()->getLongitude(), 0.001);
$this->assertNull($result->getBounds());
$this->assertNull($result->getStreetNumber());
$this->assertNull($result->getStreetName());
Expand Down

0 comments on commit 3d24f04

Please sign in to comment.