- Notifications
You must be signed in to change notification settings - Fork 13
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description:
The dependency analyzer seems to flag the normalizer argument in the OptionsResolver::setNormalizer method as an unknown class, even though it's a named argument. This appears to be a false positive caused by misinterpretation of named arguments as class names.
Steps to Reproduce:
-
Create the following PHP code:
<?php declare(strict_types=1); namespace App; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\OptionsResolver\OptionsResolver; use function array_merge; final class FooType extends ChoiceType { public function configureOptions(OptionsResolver $resolver): void { parent::configureOptions($resolver); $resolver->setNormalizer( option: 'attr', normalizer: static fn ($options, $value) => array_merge( ['foo' => 'bar'], $value, ), ); } }
-
Run the analyzer.
-
Observe the output:
Found 1 unknown class! (unable to autoload those, so we cannot check them) • normalizer in src/FooType.php:20 -
Update the method call to use positional arguments instead of named arguments:
$resolver->setNormalizer( 'attr', static fn ($options, $value) => array_merge( ['foo' => 'bar'], $value, ), );
-
Run the analyzer again. This time, no errors are reported.
Environment:
- PHP version: 8.3.11
symfony/formpackage version: 7.1.6symfony/options-resolverpackage version: 7.1.6- Composer Dependency Analyzer version: 1.8.0
janedbal
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working