Skip to content

Commit 8cde7f4

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 5f106fc commit 8cde7f4

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

Photon.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function geocodeQuery(GeocodeQuery $query): Collection
7777
'lang' => $query->getLocale(),
7878
]);
7979

80-
$json = $this->executeQuery($url, $query->getLocale());
80+
$json = $this->executeQuery($url);
8181

8282
if (!isset($json->features) || empty($json->features)) {
8383
return new AddressCollection([]);
@@ -149,7 +149,9 @@ private function featureToAddress(\stdClass $feature): Location
149149
}
150150

151151
/** @var PhotonAddress $address */
152-
$address = $builder->build(PhotonAddress::class)
152+
$address = $builder->build(PhotonAddress::class);
153+
154+
$address = $address
153155
->withOSMId($properties->osm_id ?? null)
154156
->withOSMType($properties->osm_type ?? null)
155157
->withOSMTag(

Tests/IntegrationTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@
1919
*/
2020
class IntegrationTest extends ProviderIntegrationTest
2121
{
22-
protected $testAddress = true;
22+
protected bool $testAddress = true;
2323

24-
protected $testReverse = true;
24+
protected bool $testReverse = true;
2525

26-
protected $testIpv4 = false;
26+
protected bool $testIpv4 = false;
2727

28-
protected $testIpv6 = false;
28+
protected bool $testIpv6 = false;
2929

30-
protected $skippedTests = [
30+
protected array $skippedTests = [
3131
'testGeocodeQuery' => 'Photon API returns "Great George Street" for "10 Downing St, London, UK" query.',
3232
'testReverseQueryWithNoResults' => 'Photon API returns "Atlas Buoy 0.00E 0.00N" for reverse query at 0,0.',
3333
];
3434

3535
protected function createProvider(ClientInterface $httpClient)
3636
{
37-
return Photon::withKomootServer($httpClient, 'Geocoder PHP/Photon Provider/Integration Test');
37+
return Photon::withKomootServer($httpClient);
3838
}
3939

40-
protected function getCacheDir()
40+
protected function getCacheDir(): string
4141
{
4242
return __DIR__.'/.cached_responses';
4343
}
4444

45-
protected function getApiKey()
45+
protected function getApiKey(): string
4646
{
47-
return null;
47+
return '';
4848
}
4949
}

Tests/PhotonTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public function testGeocodeQuery()
6262
/** @var \Geocoder\Provider\Photon\Model\PhotonAddress $result */
6363
$result = $results->first();
6464
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
65-
$this->assertEquals(48.8631927, $result->getCoordinates()->getLatitude(), '', 0.00001);
66-
$this->assertEquals(2.3890894, $result->getCoordinates()->getLongitude(), '', 0.00001);
65+
$this->assertEqualsWithDelta(48.8631927, $result->getCoordinates()->getLatitude(), 0.00001);
66+
$this->assertEqualsWithDelta(2.3890894, $result->getCoordinates()->getLongitude(), 0.00001);
6767
$this->assertEquals('10', $result->getStreetNumber());
6868
$this->assertEquals('Avenue Gambetta', $result->getStreetName());
6969
$this->assertEquals('75020', $result->getPostalCode());
@@ -105,8 +105,8 @@ public function testReverseQuery()
105105
/** @var \Geocoder\Provider\Photon\Model\PhotonAddress $result */
106106
$result = $results->first();
107107
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
108-
$this->assertEquals(51.9982968, $result->getCoordinates()->getLatitude(), '', 0.00001);
109-
$this->assertEquals(9.998645, $result->getCoordinates()->getLongitude(), '', 0.00001);
108+
$this->assertEqualsWithDelta(51.9982968, $result->getCoordinates()->getLatitude(), 0.00001);
109+
$this->assertEqualsWithDelta(9.998645, $result->getCoordinates()->getLongitude(), 0.00001);
110110
$this->assertEquals('31195', $result->getPostalCode());
111111
$this->assertEquals('Lamspringe', $result->getLocality());
112112
$this->assertEquals('Deutschland', $result->getCountry()->getName());

0 commit comments

Comments
 (0)