Skip to content

Commit

Permalink
SF7 compat & Some cleanings (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
webda2l authored Jan 3, 2024
1 parent 50b8952 commit f3ddd0c
Show file tree
Hide file tree
Showing 18 changed files with 192 additions and 222 deletions.
78 changes: 30 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,40 @@ on: ["push", "pull_request"]

env:
COMPOSER_ALLOW_SUPERUSER: '1'
SYMFONY_PHPUNIT_VERSION: 9.5
SYMFONY_DEPRECATIONS_HELPER: max[self]=0

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
container:
image: php:7.4-alpine
image: php:8.3-alpine
options: >-
--tmpfs /tmp:exec
--tmpfs /var/tmp:exec
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Composer
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-composer-8.3-highest-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
${{ runner.os }}-composer-8.3-highest
- name: Validate Composer
run: composer validate
- name: Install xsl PHP extension
run: |
apk add $PHPIZE_DEPS libxslt-dev
docker-php-ext-install xsl
- name: Install highest dependencies with Composer
run: composer update --no-progress --no-suggest --ansi
- name: Disable PHP memory limit
run: echo 'memory_limit=-1' >> /usr/local/etc/php/php.ini
- name: Analyze
run: vendor/bin/phpqa --execution no-parallel --progress-delay=-1 --ansi
- name: Run CS-Fixer
run: vendor/bin/php-cs-fixer fix --dry-run --diff --format=checkstyle

phpunit:
name: PHPUnit (PHP ${{ matrix.php }} Deps ${{ matrix.dependencies }})
Expand All @@ -55,44 +50,35 @@ jobs:
strategy:
matrix:
php:
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
dependencies:
- 'lowest'
- 'highest'
include:
- php: '7.2'
dependencies: 'lowest'
phpunit-version: 8.5
- php: '7.3'
phpunit-version: 9.5
- php: '7.4'
phpunit-version: 9.5
- php: '8.0'
phpunit-version: 9.5
- php: '8.1'
phpunit-version: 9.5
phpunit-version: 10
- php: '8.2'
phpunit-version: 10
- php: '8.3'
phpunit-version: 10
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Composer
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install xsl PHP extension
run: |
apk add $PHPIZE_DEPS libxslt-dev
docker-php-ext-install xsl
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.dependencies }}
- name: Install lowest dependencies with Composer
if: matrix.dependencies == 'lowest'
run: composer update --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi
Expand All @@ -101,20 +87,20 @@ jobs:
run: composer update --no-progress --no-suggest --ansi
- name: Run tests with PHPUnit
env:
SYMFONY_PHPUNIT_VERSION: ${{ matrix.phpunit-version }}
SYMFONY_MAX_PHPUNIT_VERSION: ${{ matrix.phpunit-version }}
run: vendor/bin/simple-phpunit --colors=always

coverage:
name: Coverage (PHP ${{ matrix.php }})
name: Coverage (PHP 8.3)
runs-on: ubuntu-latest
container:
image: php:7.4-alpine
image: php:8.3-alpine
options: >-
--tmpfs /tmp:exec
--tmpfs /var/tmp:exec
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install pcov PHP extension
run: |
apk add $PHPIZE_DEPS
Expand All @@ -125,22 +111,18 @@ jobs:
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-composer-8.3-highest-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install xsl PHP extension
run: |
apk add $PHPIZE_DEPS libxslt-dev
docker-php-ext-install xsl
${{ runner.os }}-composer-8.3-highest
- name: Install highest dependencies with Composer
run: composer update --no-progress --no-suggest --ansi
- name: Run coverage with PHPUnit
run: vendor/bin/simple-phpunit --coverage-clover ./coverage.xml --colors=always
- name: Send code coverage report to Codecov.io
uses: codecov/codecov-action@v1.0.3 # 1.0.4+ uncompatible alpine :/
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
50 changes: 30 additions & 20 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,43 @@
file that was distributed with this source code.
HEADER;


$finder = (new PhpCsFixer\Finder())
->in(['src', 'tests'])
;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers())
->setRules([
'@DoctrineAnnotation' => true,
'@PHP70Migration' => true,
'@PHP70Migration:risky' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHP73Migration' => true,
'@PHPUnit75Migration:risky' => true,
'@PHP82Migration' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'date_time_immutable' => true,
'header_comment' => ['header' => $header],
'general_phpdoc_annotation_remove' => true,

// From https://github.com/symfony/demo/blob/main/.php-cs-fixer.dist.php
'linebreak_after_opening_tag' => true,
'list_syntax' => ['syntax' => 'short'],
'no_superfluous_phpdoc_tags' => true,
// 'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'php_unit_strict' => false,
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
'phpdoc_order' => true,
'strict_comparison' => true,
'strict_param' => true,
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays', 'parameters']],
'statement_indentation' => true,
'method_chaining_indentation' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline', 'attribute_placement' => 'ignore'],

PhpCsFixerCustomFixers\Fixer\ConstructorEmptyBracesFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\MultilineCommentOpeningClosingAloneFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\NoDuplicatedImportsFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\NoImportFromGlobalNamespaceFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\PhpdocSingleLineVarFixer::name() => true,
])
->setFinder(
(new PhpCsFixer\Finder())
->exclude(['vendor'])
->in(['src', 'tests'])
)
->setFinder($finder)
;
15 changes: 0 additions & 15 deletions .phpqa.yml

This file was deleted.

33 changes: 17 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@
}
],
"require": {
"php": ">=7.2.5",
"symfony/config": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/dependency-injection": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/doctrine-bridge": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/form": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/http-kernel": "^3.4.30|^4.3|^5.0|^6.0",
"doctrine/persistence": "^1.3|^2.0|^3.0"
"php": "^8.1",
"doctrine/persistence": "^1.3|^2.0|^3.0",
"symfony/config": "^5.4.30|^6.3.10|^7.0",
"symfony/dependency-injection": "^5.4.30|^6.3.10|^7.0",
"symfony/doctrine-bridge": "^5.4.30|^6.3.10|^7.0",
"symfony/form": "^5.4.30|^6.3.10|^7.0",
"symfony/http-kernel": "^5.4.30|^6.3.10|^7.0"
},
"require-dev": {
"doctrine/orm": "^2.7",
"edgedesign/phpqa": "^1.25",
"friendsofphp/php-cs-fixer": "^3.4.0",
"phpstan/phpstan": "^1.2.0",
"symfony/cache": "^5.4",
"symfony/phpunit-bridge": "^6.0",
"symfony/validator": "^3.4.30|^4.3|^5.0|^6.0",
"vimeo/psalm": "^4.15"
"doctrine/orm": "^2.15",
"friendsofphp/php-cs-fixer": "^3.45",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.18",
"phpstan/phpstan": "^1.10",
"rector/rector": "^0.18",
"symfony/cache": "^5.4.30|^6.3.10|^7.0",
"symfony/phpunit-bridge": "^5.4.30|^6.3.10|^7.0",
"symfony/validator": "^5.4.30|^6.3.10|^7.0",
"vimeo/psalm": "^5.18"
},
"suggest": {
"a2lix/translation-form-bundle": "For translation form"
Expand All @@ -45,7 +46,7 @@
"psalm"
],
"phpunit": [
"SYMFONY_PHPUNIT_VERSION=9.5 SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 simple-phpunit"
"SYMFONY_DEPRECATIONS_HELPER=max[self]=0 simple-phpunit"
]
},
"config": {
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.6/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="SYMFONY_PHPUNIT_VERSION" value="9" />
</php>

<listeners>
Expand Down
37 changes: 37 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Symfony\Set\SymfonyLevelSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Set\TwigSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->paths([
__DIR__.'/src',
__DIR__.'/tests',
]);
$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);

$rectorConfig->phpVersion(PhpVersion::PHP_82);
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_82,

DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
// DoctrineSetList::DOCTRINE_CODE_QUALITY,
DoctrineSetList::DOCTRINE_ORM_214,
DoctrineSetList::DOCTRINE_DBAL_30,

PHPUnitLevelSetList::UP_TO_PHPUNIT_91,
// PHPUnitSetList::PHPUNIT_CODE_QUALITY,
// PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
]);
};
4 changes: 1 addition & 3 deletions src/A2lixAutoFormBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@

use Symfony\Component\HttpKernel\Bundle\Bundle;

class A2lixAutoFormBundle extends Bundle
{
}
class A2lixAutoFormBundle extends Bundle {}
4 changes: 2 additions & 2 deletions src/DependencyInjection/A2lixAutoFormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class A2lixAutoFormExtension extends Extension
Expand All @@ -26,7 +26,7 @@ public function load(array $configs, ContainerBuilder $container): void
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), $configs);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('a2lix_form.xml');
$loader->load('object_info.xml');

Expand Down
4 changes: 1 addition & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->defaultValue(['id', 'locale', 'translatable'])
->beforeNormalization()
->ifString()
->then(function ($v) {
return preg_split('/\s*,\s*/', $v);
})
->then(static fn ($v) => preg_split('/\s*,\s*/', (string) $v))
->end()
->prototype('scalar')
->info('Global list of fields to exclude from form generation. (Default: id, locale, translatable)')->end()
Expand Down
Loading

0 comments on commit f3ddd0c

Please sign in to comment.