Skip to content

Commit 71919f8

Browse files
jbeliennorkunas
andauthored
Add PHPStan in CI (#1193)
* 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]>
1 parent 954ecce commit 71919f8

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

Tests/IP2LocationBinaryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public function testLocationResultContainsExpectedFieldsForAnAmericanIp()
6868
$result = $results->first();
6969
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
7070

71-
$this->assertEquals('37.405990600586', $result->getCoordinates()->getLatitude(), '', 0.001);
72-
$this->assertEquals('-122.07851409912', $result->getCoordinates()->getLongitude(), '', 0.001);
71+
$this->assertEqualsWithDelta(37.405990600586, $result->getCoordinates()->getLatitude(), 0.001);
72+
$this->assertEqualsWithDelta(-122.07851409912, $result->getCoordinates()->getLongitude(), 0.001);
7373
$this->assertNull($result->getBounds());
7474
$this->assertNull($result->getStreetNumber());
7575
$this->assertNull($result->getStreetName());
@@ -96,8 +96,8 @@ public function testLocationResultContainsExpectedFieldsForAChinaIp()
9696
$result = $results->first();
9797
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
9898

99-
$this->assertEquals('39.907501220703', $result->getCoordinates()->getLatitude(), '', 0.001);
100-
$this->assertEquals('116.39723205566', $result->getCoordinates()->getLongitude(), '', 0.001);
99+
$this->assertEqualsWithDelta(39.907501220703, $result->getCoordinates()->getLatitude(), 0.001);
100+
$this->assertEqualsWithDelta(116.39723205566, $result->getCoordinates()->getLongitude(), 0.001);
101101
$this->assertNull($result->getBounds());
102102
$this->assertNull($result->getStreetNumber());
103103
$this->assertNull($result->getStreetName());
@@ -124,8 +124,8 @@ public function testGeocodeWithRealIPv6()
124124
$result = $results->first();
125125
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
126126

127-
$this->assertEquals('37.386051', $result->getCoordinates()->getLatitude(), '', 0.001);
128-
$this->assertEquals('-122.083847', $result->getCoordinates()->getLongitude(), '', 0.001);
127+
$this->assertEqualsWithDelta(37.386051, $result->getCoordinates()->getLatitude(), 0.001);
128+
$this->assertEqualsWithDelta(-122.083847, $result->getCoordinates()->getLongitude(), 0.001);
129129
$this->assertNull($result->getBounds());
130130
$this->assertNull($result->getStreetNumber());
131131
$this->assertNull($result->getStreetName());

Tests/IntegrationTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@
2121
*/
2222
class IntegrationTest extends ProviderIntegrationTest
2323
{
24-
protected $skippedTests = [
25-
];
24+
protected array $skippedTests = [];
2625

27-
protected $testAddress = false;
26+
protected bool $testAddress = false;
2827

29-
protected $testReverse = false;
28+
protected bool $testReverse = false;
3029

31-
protected $testIpv6 = false;
30+
protected bool $testIpv6 = false;
3231

33-
protected $testHttpProvider = false;
32+
protected bool $testHttpProvider = false;
3433

3534
public static function setUpBeforeClass(): void
3635
{
@@ -47,13 +46,13 @@ protected function createProvider(ClientInterface $httpClient)
4746
return new IP2LocationBinary(__DIR__.'/fixtures/IP2LOCATION-LITE-DB9.IPV6.BIN', \IP2Location\Database::FILE_IO);
4847
}
4948

50-
protected function getCacheDir()
49+
protected function getCacheDir(): string
5150
{
5251
return __DIR__.'/.cached_responses';
5352
}
5453

55-
protected function getApiKey()
54+
protected function getApiKey(): string
5655
{
57-
return null;
56+
return '';
5857
}
5958
}

0 commit comments

Comments
 (0)