Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Symfony 7 #89

Merged
merged 11 commits into from
Dec 22, 2023
Merged
2 changes: 1 addition & 1 deletion .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
55 changes: 29 additions & 26 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -58,16 +58,19 @@ 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
uses: actions/checkout@v2

- 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
Expand All @@ -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
Expand All @@ -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 }}
8 changes: 8 additions & 0 deletions .phpstan/symfony_4.neon
Original file line number Diff line number Diff line change
@@ -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.#'
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions src/Command/UpdateDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class UpdateDatabaseCommand extends Command
private $downloader;

/**
* @var array[]
* @var array<string, ?array{url?: string|false, path?: string|false, locales?: string[], license?: ?string, edition?: string}>
*/
private $databases;

/**
* @param Downloader $downloader
* @param array[] $databases
* @param Downloader $downloader
* @param array<string, ?array{url?: string|false, path?: string|false, locales?: string[], license?: ?string, edition?: string}> $databases
*/
public function __construct(Downloader $downloader, array $databases)
{
Expand All @@ -57,7 +57,7 @@ protected function configure(): void
$databases_help .= sprintf(' * <info>%s</info>'.PHP_EOL, $name);
}

[$first, $second, ] = array_keys($this->databases);
[$first, $second] = array_keys($this->databases);

$help .= <<<EOT

Expand Down Expand Up @@ -105,10 +105,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
throw new \InvalidArgumentException(sprintf('Undefined "%s" database.', $database));
}

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'])
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));
}
Expand Down
40 changes: 20 additions & 20 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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']));
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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']));
Expand Down
10 changes: 6 additions & 4 deletions src/DependencyInjection/GpsLabGeoIP2Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ class GpsLabGeoIP2Extension extends Extension
private const SERVICE_NAME = 'geoip2.database.%s_reader';

/**
* @param array[] $configs
* @param ContainerBuilder $container
* @param array<array<mixed>> $configs
* @param ContainerBuilder $container
*
* @return void
*/
public function load(array $configs, ContainerBuilder $container): void
{
Expand Down Expand Up @@ -102,8 +104,8 @@ public function load(array $configs, ContainerBuilder $container): void
}

/**
* @param array[] $config
* @param ContainerBuilder $container
* @param array<array<mixed>> $config
* @param ContainerBuilder $container
*
* @return Configuration
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Reader/ReaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
class ReaderFactory
{
/**
* @var array[]
* @var array<string, ?array{url?: string|false, path?: string|false, locales?: string[], license?: ?string, edition?: string}>
*/
private $databases;

/**
* @var string
* @var class-string<Reader>
*/
private $reader_class;

/**
* @param array[] $databases
* @param string $reader_class
* @param array<string, ?array{url?: string|false, path?: string|false, locales?: string[], license?: ?string, edition?: string}> $databases
* @param class-string<Reader> $reader_class
*/
public function __construct(array $databases, string $reader_class = Reader::class)
{
Expand All @@ -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));
Expand Down
12 changes: 6 additions & 6 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<array<mixed>> $configs
*/
public function testBadConfigs(?string $cache_dir, array $configs): void
{
Expand All @@ -177,7 +177,7 @@ public function testBadConfigs(?string $cache_dir, array $configs): void
}

/**
* @return mixed[]
* @return array<array<mixed>>
*/
public function getConfigs(): iterable
{
Expand Down Expand Up @@ -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<array<mixed>> $configs
* @param array<array<mixed>> $expected
*/
public function testConfigs(?string $cache_dir, array $configs, array $expected): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Reader/ReaderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class ReaderFactoryTest extends TestCase
{
/**
* @return array[]
* @return list<list<?list<string>>>
*/
public function getLocales(): array
{
Expand Down
Loading