Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
php-version: '8.2'

@maximecolin maximecolin Jun 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linting is usually run on the highest supported PHP version. Is this change from 8.3 to 8.2 intentional? (8.3+ would catch recent deprecations better)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image
Setting PHP_CS_FIXER_IGNORE_ENV environment variable is deprecated and will be removed in 4.0, use unsupportedPhpVersionAllowed config instead.
You are running PHP CS Fixer on PHP 8.5.7, but the minimum PHP version supported by your project in composer.json is PHP 8.2. Executing PHP CS Fixer on newer PHP versions may introduce syntax or features not yet available in PHP 8.2, which could cause issues under that version. It is recommended to run PHP CS Fixer on PHP 8.2, to fit your project specifics.
If you need help while solving warnings, ask at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/discussions/, we will help you!


- name: 'Install dependencies'
run: |
Expand All @@ -42,37 +42,31 @@ jobs:
matrix:
include:
# Lowest deps
- name: 'Test lowest deps Symfony 5.4 [Linux, PHP 7.4]'
- name: 'Test lowest deps Symfony 6.4 [Linux, PHP 8.2]'
os: 'ubuntu-latest'
php: '7.4'
symfony: '5.4.*@dev'
php: '8.2'
symfony: '6.4.*'
composer-flags: '--prefer-lowest'
allow-unstable: true
allow-unstable: false

# Most recent versions
- name: 'Test Symfony 5.4 [Linux, PHP 8.0]'
os: 'ubuntu-latest'
php: '8.0'
symfony: '5.4.*@dev'
allow-unstable: true

- name: 'Test Symfony 6.0 [Linux, PHP 8.1]'
- name: 'Test Symfony 7.4 [Linux, PHP 8.2]'
os: 'ubuntu-latest'
php: '8.1'
symfony: '6.0.*@dev'
allow-unstable: true
php: '8.2'
symfony: '7.4.*'
allow-unstable: false

- name: 'Test next Symfony 6.4 [Linux, PHP 8.2]'
- name: 'Test Symfony 8.1 [Linux, PHP 8.5]'
os: 'ubuntu-latest'
php: '8.2'
symfony: '6.4.*@dev'
allow-unstable: true
php: '8.5'
symfony: '8.1.*'
allow-unstable: false

# Bleeding edge (unreleased dev versions where failures are allowed)
- name: 'Test next Symfony [Linux, PHP 8.3] (allowed failure)'
- name: 'Test next Symfony [Linux, PHP 8.5] (allowed failure)'
os: 'ubuntu-latest'
php: '8.3'
symfony: '7.0.*@dev'
php: '8.5'
symfony: '8@dev'
composer-flags: '--ignore-platform-req php'
allow-unstable: true
allow-failure: true
Expand All @@ -99,7 +93,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: 'Cache dependencies'
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-${{ hashFiles('**/composer.json') }}-flags-${{ matrix.composer-flags }}
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
'single_line_throw' => false,
'simplified_null_return' => false,
'void_return' => true,
'yoda_style' => [],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],

@maximecolin maximecolin Jun 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling yoda_style is a style change unrelated to SF8 support (scope creep). Nothing blocking, but it would ideally belong in a dedicated commit/PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was required by php-cs-fixer to configure it explicitly.

])
;
2 changes: 1 addition & 1 deletion Builders/FormKeyBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(
string $separator = '.',
string $root = 'form',
string $children = 'children',
string $prototype = 'prototype'
string $prototype = 'prototype',
) {
$this->separator = $separator;
$this->root = $root;
Expand Down
8 changes: 4 additions & 4 deletions DependencyInjection/ElaoFormTranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* ElaoFormTranslation extension
Expand All @@ -30,10 +30,10 @@ public function load(array $configs, ContainerBuilder $container): void
$config = $this->processConfiguration($configuration, $configs);

if ($config['enabled']) {
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));

$loader->load('services.xml');
$loader->load('forms.xml');
$loader->load('services.php');
$loader->load('forms.php');

$this->loadTreeConfig($container, $loader, $config);
}
Expand Down
2 changes: 1 addition & 1 deletion Form/Extension/TreeAwareExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function generateKey(FormView &$view, $key, $value): void
}

/**
* @param array<string,mixed> &$vars
* @param array<mixed> &$vars

@maximecolin maximecolin Jun 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This downgrade from array<string,mixed> to array<mixed> looks like an unnecessary loss of precision: $vars receives $view->vars, which is string-keyed. It also creates an inconsistency with optionEquals() just below, which keeps array<string,mixed>. Could you revert to array<string,mixed>? (and if phpstan was complaining, it's worth understanding why)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

$vars passed by reference so the method can change the type, and PropertyAccessor's setValue typed with object|array<mixed> which is looser

I added @param-out array<mixed> $vars which is ok by phpstan.

*/
protected function setVar(array &$vars, string $key, mixed $value): void
{
Expand Down
42 changes: 42 additions & 0 deletions Resources/config/forms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* This file is part of the ElaoFormTranslation bundle.
*
* Copyright (C) Elao
*
* @author Elao <contact@elao.com>
*/

use Elao\Bundle\FormTranslationBundle\Form\Extension\ButtonTypeExtension;
use Elao\Bundle\FormTranslationBundle\Form\Extension\ChoiceTypeExtension;
use Elao\Bundle\FormTranslationBundle\Form\Extension\CollectionTypeExtension;
use Elao\Bundle\FormTranslationBundle\Form\Extension\FormTypeExtension;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\FormType;

return static function (ContainerConfigurator $container): void {
$services = $container->services();

$services->set('elao.form_translation.extension.tree_aware_extension')
->abstract();

$services->set('elao.form_translation.extension.form_type_extension', FormTypeExtension::class)
->parent('elao.form_translation.extension.tree_aware_extension')
->tag('form.type_extension', ['extended-type' => FormType::class]);

$services->set('elao.form_translation.extension.collection_type_extension', CollectionTypeExtension::class)
->parent('elao.form_translation.extension.tree_aware_extension')
->tag('form.type_extension', ['extended-type' => CollectionType::class]);

$services->set('elao.form_translation.extension.button_type_extension', ButtonTypeExtension::class)
->parent('elao.form_translation.extension.tree_aware_extension')
->tag('form.type_extension', ['extended-type' => ButtonType::class]);

$services->set('elao.form_translation.extension.choice_type_extension', ChoiceTypeExtension::class)
->parent('elao.form_translation.extension.tree_aware_extension')
->tag('form.type_extension', ['extended-type' => ChoiceType::class]);
};
26 changes: 0 additions & 26 deletions Resources/config/forms.xml

This file was deleted.

21 changes: 21 additions & 0 deletions Resources/config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of the ElaoFormTranslation bundle.
*
* Copyright (C) Elao
*
* @author Elao <contact@elao.com>
*/

use Elao\Bundle\FormTranslationBundle\Builders\FormKeyBuilder;
use Elao\Bundle\FormTranslationBundle\Builders\FormTreeBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $container): void {
$services = $container->services();

$services->set('elao.form_translation.tree_builder', FormTreeBuilder::class);

$services->set('elao.form_translation.key_builder', FormKeyBuilder::class);
};
11 changes: 0 additions & 11 deletions Resources/config/services.xml

This file was deleted.

2 changes: 1 addition & 1 deletion Tests/FormTranslationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function setUp(): void
/**
* Get Form Type Extensions
*
* @return array<FormTypeExtensionInterface>
* @return array<FormTypeExtensionInterface<Extension\TreeAwareExtension>>
*/
protected function getTypeExtensions(): array
{
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
}
],
"require": {
"php": "^7.4|^8.0",
"symfony/framework-bundle": "^5.4|^6.0|^7.0",
"symfony/form": "^5.4|^6.0|^7.0",
"symfony/property-access": "^5.4|^6.0|^7.0"
"php": "^8.2",
"symfony/framework-bundle": "^6.4|^7.4|^8.0",
"symfony/form": "^6.4|^7.4|^8.0",
"symfony/property-access": "^6.4|^7.4|^8.0"
},
"require-dev": {
"ekino/phpstan-banned-code": "^1.0",
"ekino/phpstan-banned-code": "^3.2",
"friendsofphp/php-cs-fixer": "^3.10",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-symfony": "^1.2",
"symfony/phpunit-bridge": "^5.0",
"phpstan/phpstan-phpunit": "^1.1"
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.2",
"phpstan/phpstan-symfony": "^2.0",
"symfony/phpunit-bridge": "^6.0",
"phpstan/phpstan-phpunit": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading