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 f79df6c commit fc063aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
7 changes: 4 additions & 3 deletions Tests/GeoIP2AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use Geocoder\Provider\GeoIP2\GeoIP2Adapter;
use RuntimeException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
Expand Down Expand Up @@ -121,7 +122,7 @@ public function testReaderResponseIsJsonEncoded()
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject
* @return MockObject
*/
protected function getGeoIP2ProviderMock()
{
Expand All @@ -131,9 +132,9 @@ protected function getGeoIP2ProviderMock()
}

/**
* @param int $geoIP2Model (e.g. GeoIP2Adapter::GEOIP2_MODEL_CITY, ...)
* @param string $geoIP2Model (e.g. GeoIP2Adapter::GEOIP2_MODEL_CITY, ...)
*
* @return \PHPUnit_Framework_MockObject_MockObject
* @return MockObject
*/
protected function getGeoIP2ModelMock($geoIP2Model)
{
Expand Down
3 changes: 2 additions & 1 deletion Tests/GeoIP2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use GeoIp2\Exception\OutOfQueriesException;
use Geocoder\Exception\InvalidCredentials;
use Geocoder\Exception\QuotaExceeded;
use PHPUnit\Framework\MockObject\MockObject;

/**
* @author Jens Wiese <[email protected]>
Expand Down Expand Up @@ -261,7 +262,7 @@ public static function provideDataForTestingExceptions(): array
/**
* @param mixed $returnValue
*
* @return \PHPUnit_Framework_MockObject_MockObject|GeoIP2Adapter
* @return GeoIP2Adapter&MockObject
*/
private function getGeoIP2AdapterMock($returnValue = '')
{
Expand Down
14 changes: 7 additions & 7 deletions Tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
*/
class IntegrationTest extends ProviderIntegrationTest
{
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;

protected function createProvider(ClientInterface $httpClient)
{
Expand All @@ -38,13 +38,13 @@ protected function createProvider(ClientInterface $httpClient)
return new GeoIP2(new GeoIP2Adapter($reader));
}

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

protected function getApiKey()
protected function getApiKey(): string
{
return null;
return '';
}
}

0 comments on commit fc063aa

Please sign in to comment.