diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index 0b4b81f..0455409 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -17,7 +17,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.1 coverage: none tools: composer:v2, cs2pr, php-cs-fixer diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 41e7c27..7b23fd6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,37 +13,37 @@ jobs: fail-fast: false matrix: include: - - php: '7.1' + - php: '7.2' symfony: '2.8.*' - phpstan: .phpstan/default.neon - - php: '7.1' + phpstan: .phpstan/symfony_4.neon + - php: '7.2' symfony: '3.0.*' - phpstan: .phpstan/default.neon - - php: '7.1' + phpstan: .phpstan/symfony_4.neon + - php: '7.2' symfony: '3.1.*' - phpstan: .phpstan/default.neon - - php: '7.1' + phpstan: .phpstan/symfony_4.neon + - php: '7.2' symfony: '3.2.*' - phpstan: .phpstan/default.neon - - php: '7.1' + phpstan: .phpstan/symfony_4.neon + - php: '7.2' symfony: '3.3.*' - phpstan: .phpstan/default.neon - - php: '7.1' + phpstan: .phpstan/symfony_4.neon + - php: '7.2' symfony: '3.4.*' - phpstan: .phpstan/default.neon - - php: '7.1' + phpstan: .phpstan/symfony_4.neon + - php: '7.2' symfony: '4.0.*' - phpstan: .phpstan/default.neon - - php: '7.1' + phpstan: .phpstan/symfony_4.neon + - php: '7.2' symfony: '4.1.*' - phpstan: .phpstan/default.neon - - php: '7.1' + phpstan: .phpstan/symfony_4.neon + - php: '7.2' symfony: '4.2.*' phpstan: .phpstan/default.neon - - php: '7.1' + - php: '7.2' symfony: '4.3.*' phpstan: .phpstan/default.neon - - php: '7.1' + - php: '7.2' symfony: '4.4.*' phpstan: .phpstan/default.neon - php: '7.2' @@ -58,8 +58,11 @@ jobs: - php: '8.0' symfony: '5.2.*' phpstan: .phpstan/symfony_5.neon - - php: '8.0' - symfony: '6.0.*' + - php: '8.1' + symfony: '6.4.*' + phpstan: .phpstan/symfony_6.neon + - php: '8.2' + symfony: '7.0.*' phpstan: .phpstan/symfony_6.neon steps: - name: Checkout @@ -67,7 +70,7 @@ jobs: - name: Configure coverage driver id: coverage - run: echo ::set-output name=driver::$([ "${{ matrix.php }}" = "7.1" ] && echo "xdebug" || echo "pcov") + run: echo ::set-output name=driver::pcov - name: Install PHP with extensions uses: shivammathur/setup-php@v2 @@ -88,7 +91,7 @@ jobs: run: vendor/bin/phpunit --coverage-clover build/coverage-clover.xml - name: Send coverage results to Scrutinizer CI - if: matrix.php != '8.0' + if: matrix.php != '8.0' && matrix.php != '8.1' && matrix.php != '8.2' run: | wget https://scrutinizer-ci.com/ocular.phar php ocular.phar code-coverage:upload --format=php-clover build/coverage-clover.xml @@ -98,15 +101,15 @@ jobs: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_PARALLEL: true COVERALLS_FLAG_NAME: 'PHP ${{ matrix.php }} + ${{ matrix.symfony }}' - if: matrix.php != '8.0' + if: matrix.php != '8.0' && matrix.php != '8.1' && matrix.php != '8.2' run: | composer global require php-coveralls/php-coveralls php-coveralls -x build/coverage-clover.xml -o build/coveralls-upload.json -v - name: Install PHPStan run: | - composer global require phpstan/phpstan:"0.12.*" - composer global require phpstan/phpstan-phpunit:"0.12.*" + composer global require phpstan/phpstan:"1.10.*" + composer global require phpstan/phpstan-phpunit:"1.3.*" - name: Run PHPStan run: phpstan --memory-limit=1G analyse -c ${{ matrix.phpstan }} diff --git a/.phpstan/symfony_4.neon b/.phpstan/symfony_4.neon new file mode 100644 index 0000000..04134cd --- /dev/null +++ b/.phpstan/symfony_4.neon @@ -0,0 +1,8 @@ +# config for Symfony 2.8-4.1 + +includes: + - default.neon + +parameters: + ignoreErrors: + - '#Class Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder does not have a constructor and must be instantiated without any parameters.#' \ No newline at end of file diff --git a/composer.json b/composer.json index 4e9d4a4..26875ad 100644 --- a/composer.json +++ b/composer.json @@ -17,19 +17,19 @@ "require": { "ext-phar": "*", "ext-zlib": "*", - "php": ">=7.1.0", + "php": ">=7.2.0", "geoip2/geoip2": "~2.0", - "symfony/http-kernel": "~2.8|~3.0|~4.0|~5.0|~6.0", - "symfony/dependency-injection": "~2.8|~3.0|~4.0|~5.0|~6.0", - "symfony/expression-language": "~2.8|~3.0|~4.0|~5.0|~6.0", - "symfony/config": "~2.8|~3.0|~4.0|~5.0|~6.0", - "symfony/console": "~2.8|~3.0|~4.0|~5.0|~6.0", - "symfony/filesystem": "~2.8|~3.0|~4.0|~5.0|~6.0" + "symfony/http-kernel": "~2.8|~3.0|~4.0|~5.0|~6.0|~7.0", + "symfony/dependency-injection": "~2.8|~3.0|~4.0|~5.0|~6.0|~7.0", + "symfony/expression-language": "~2.8|~3.0|~4.0|~5.0|~6.0|~7.0", + "symfony/config": "~2.8|~3.0|~4.0|~5.0|~6.0|~7.0", + "symfony/console": "~2.8|~3.0|~4.0|~5.0|~6.0|~7.0", + "symfony/filesystem": "~2.8|~3.0|~4.0|~5.0|~6.0|~7.0" }, "require-dev": { "phpunit/phpunit": "~7.0|~8.0|~9.0", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12" + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-phpunit": "^1.3" }, "suggest": { "splitbrain/php-archive": "Greatly reduces memory usage for the geoip2:update command" diff --git a/src/Command/UpdateDatabaseCommand.php b/src/Command/UpdateDatabaseCommand.php index af41481..0471de8 100644 --- a/src/Command/UpdateDatabaseCommand.php +++ b/src/Command/UpdateDatabaseCommand.php @@ -26,13 +26,13 @@ class UpdateDatabaseCommand extends Command private $downloader; /** - * @var array[] + * @var array */ private $databases; /** - * @param Downloader $downloader - * @param array[] $databases + * @param Downloader $downloader + * @param array $databases */ public function __construct(Downloader $downloader, array $databases) { @@ -57,7 +57,7 @@ protected function configure(): void $databases_help .= sprintf(' * %s'.PHP_EOL, $name); } - [$first, $second, ] = array_keys($this->databases); + [$first, $second] = array_keys($this->databases); $help .= <<databases[$database]) || - !array_key_exists('path', $this->databases[$database]) || - !is_string($this->databases[$database]['url']) || - !is_string($this->databases[$database]['path']) + if (!array_key_exists('url', $this->databases[$database]) + || !array_key_exists('path', $this->databases[$database]) + || !is_string($this->databases[$database]['url']) + || !is_string($this->databases[$database]['path']) ) { throw new \InvalidArgumentException(sprintf('Invalid "%s" database config.', $database)); } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 36e145d..80cd13e 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -192,10 +192,10 @@ private function normalizeDefaultDatabase(NodeDefinition $root_node): void ->beforeNormalization() ->ifTrue(static function ($v): bool { return - is_array($v) && - !array_key_exists('default_database', $v) && - !empty($v['databases']) && - is_array($v['databases']); + is_array($v) + && !array_key_exists('default_database', $v) + && !empty($v['databases']) + && is_array($v['databases']); }) ->then(static function (array $v): array { $keys = array_keys($v['databases']); @@ -268,10 +268,10 @@ private function validateAvailableDefaultDatabase(NodeDefinition $root_node): vo ->validate() ->ifTrue(static function ($v): bool { return - is_array($v) && - array_key_exists('default_database', $v) && - !empty($v['databases']) && - !array_key_exists($v['default_database'], $v['databases']); + is_array($v) + && array_key_exists('default_database', $v) + && !empty($v['databases']) + && !array_key_exists($v['default_database'], $v['databases']); }) ->then(static function (array $v): array { $databases = implode('", "', array_keys($v['databases'])); @@ -292,10 +292,10 @@ private function allowGlobalLicense(NodeDefinition $root_node): void ->beforeNormalization() ->ifTrue(static function ($v): bool { return - is_array($v) && - array_key_exists('license', $v) && - array_key_exists('databases', $v) && - is_array($v['databases']); + is_array($v) + && array_key_exists('license', $v) + && array_key_exists('databases', $v) + && is_array($v['databases']); }) ->then(static function (array $v): array { foreach ($v['databases'] as $name => $database) { @@ -320,10 +320,10 @@ private function allowGlobalLocales(NodeDefinition $root_node): void ->beforeNormalization() ->ifTrue(static function ($v): bool { return - is_array($v) && - array_key_exists('locales', $v) && - array_key_exists('databases', $v) && - is_array($v['databases']); + is_array($v) + && array_key_exists('locales', $v) + && array_key_exists('databases', $v) + && is_array($v['databases']); }) ->then(static function (array $v): array { foreach ($v['databases'] as $name => $database) { @@ -386,10 +386,10 @@ private function normalizeUrl(NodeDefinition $database_node): void ->beforeNormalization() ->ifTrue(static function ($v): bool { return - is_array($v) && - !array_key_exists('url', $v) && - array_key_exists('license', $v) && - array_key_exists('edition', $v); + is_array($v) + && !array_key_exists('url', $v) + && array_key_exists('license', $v) + && array_key_exists('edition', $v); }) ->then(static function (array $v): array { $v['url'] = sprintf(self::URL, urlencode($v['edition']), urlencode($v['license'])); diff --git a/src/DependencyInjection/GpsLabGeoIP2Extension.php b/src/DependencyInjection/GpsLabGeoIP2Extension.php index e09fe1a..791c1cf 100644 --- a/src/DependencyInjection/GpsLabGeoIP2Extension.php +++ b/src/DependencyInjection/GpsLabGeoIP2Extension.php @@ -30,8 +30,10 @@ class GpsLabGeoIP2Extension extends Extension private const SERVICE_NAME = 'geoip2.database.%s_reader'; /** - * @param array[] $configs - * @param ContainerBuilder $container + * @param array> $configs + * @param ContainerBuilder $container + * + * @return void */ public function load(array $configs, ContainerBuilder $container): void { @@ -102,8 +104,8 @@ public function load(array $configs, ContainerBuilder $container): void } /** - * @param array[] $config - * @param ContainerBuilder $container + * @param array> $config + * @param ContainerBuilder $container * * @return Configuration */ diff --git a/src/Reader/ReaderFactory.php b/src/Reader/ReaderFactory.php index 107d29c..a8847d6 100644 --- a/src/Reader/ReaderFactory.php +++ b/src/Reader/ReaderFactory.php @@ -16,18 +16,18 @@ class ReaderFactory { /** - * @var array[] + * @var array */ private $databases; /** - * @var string + * @var class-string */ private $reader_class; /** - * @param array[] $databases - * @param string $reader_class + * @param array $databases + * @param class-string $reader_class */ public function __construct(array $databases, string $reader_class = Reader::class) { @@ -41,7 +41,7 @@ public function __construct(array $databases, string $reader_class = Reader::cla * * @return Reader */ - public function create(string $database, ?array $locales = null): Reader + public function create(string $database, array $locales = null): Reader { if (!array_key_exists($database, $this->databases)) { $databases = implode('", "', array_keys($this->databases)); diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 004066e..0f6c584 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -162,8 +162,8 @@ public function getBadConfigs(): iterable /** * @dataProvider getBadConfigs * - * @param string|null $cache_dir - * @param array[] $configs + * @param string|null $cache_dir + * @param array> $configs */ public function testBadConfigs(?string $cache_dir, array $configs): void { @@ -177,7 +177,7 @@ public function testBadConfigs(?string $cache_dir, array $configs): void } /** - * @return mixed[] + * @return array> */ public function getConfigs(): iterable { @@ -430,9 +430,9 @@ public function getConfigs(): iterable /** * @dataProvider getConfigs * - * @param string|null $cache_dir - * @param array[] $configs - * @param array[] $expected + * @param string|null $cache_dir + * @param array> $configs + * @param array> $expected */ public function testConfigs(?string $cache_dir, array $configs, array $expected): void { diff --git a/tests/Reader/ReaderFactoryTest.php b/tests/Reader/ReaderFactoryTest.php index 7988b9c..2614b8b 100644 --- a/tests/Reader/ReaderFactoryTest.php +++ b/tests/Reader/ReaderFactoryTest.php @@ -18,7 +18,7 @@ class ReaderFactoryTest extends TestCase { /** - * @return array[] + * @return list>> */ public function getLocales(): array {