Skip to content

Conversation

@alexander-schranz
Copy link
Contributor

Q A
Branch? 7.4
Bug fix? yes
New feature? yes
Deprecations? no
Issues Fix #...
License MIT

Why?

Currently all AbstractBundle run into:

Method CmsIg\Seal\Integration\Symfony\SealBundle::configure() has parameter $definition with generic class Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator but does not specify its types: T
 ------ -------------------------------------------------------------------------
  Line   src/SealBundle.php
 ------ -------------------------------------------------------------------------
  37     Method CmsIg\Seal\Integration\Symfony\SealBundle::configure() has
         parameter $definition with generic class
         Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator
         but does not specify its types: T
 ------ -------------------------------------------------------------------------

I not even sure what is the correct generic type here. If it is 'scalar' or 'array' so I think lot of people are not able to guess the correct one. So we should define the correct one for the AbstractBundle already.

PHPDoc was added in 8099cda by @nicolas-grekas

@carsonbot carsonbot added this to the 7.4 milestone Sep 22, 2025
@carsonbot carsonbot changed the title Define DefinitionConfigurator generic type for AbstractBundle Define DefinitionConfigurator generic type for AbstractBundle Sep 22, 2025
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I'd suggest going with this instead:

--- a/src/Symfony/Component/Config/Definition/Configurator/DefinitionConfigurator.php
+++ b/src/Symfony/Component/Config/Definition/Configurator/DefinitionConfigurator.php
@@ -17,7 +17,7 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder;
 use Symfony\Component\Config\Definition\Loader\DefinitionFileLoader;
 
 /**
- * @template T of 'array'|'variable'|'scalar'|'string'|'boolean'|'integer'|'float'|'enum'
+ * @template T of 'array'|'variable'|'scalar'|'string'|'boolean'|'integer'|'float'|'enum' = 'array'
  *
  * @author Yonel Ceruto <[email protected]>

@nicolas-grekas
Copy link
Member

Thank you @alexander-schranz.

@nicolas-grekas nicolas-grekas merged commit b8eaa4b into symfony:7.4 Sep 22, 2025
10 of 12 checks passed
@alexander-schranz alexander-schranz deleted the patch-10 branch September 22, 2025 07:33
nicolas-grekas added a commit that referenced this pull request Dec 5, 2025
…ander-schranz)

This PR was squashed before being merged into the 7.4 branch.

Discussion
----------

[Config] Define `TreeBuilder` default generic type

| Q             | A
| ------------- | ---
| Branch?       | 7.4
| Bug fix?      | yes
| New feature?  | no <!-- if yes, also update src/**/CHANGELOG.md -->
| Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md -->
| Issues        | Fix #... <!-- prefix each issue number with "Fix #"; no need to create an issue if none exists, explain below -->
| License       | MIT

The generics make sense internal but are very confusing for all people not knowing about internal behaviours and hard to guess whats corrct so we should provide defaults for them. Similar to #61805 add some defaults.

Stumbled over this during upgrade StofDoctrineExtensionBundle:

```
  14     Method Stof\DoctrineExtensionsBundle\DependencyInjection\Configuration::getConfigTreeBuilder() return type with generic class Symfony\Component\Config\Definition\Builder\TreeBuilder does not specify its types: T
         🪪  missingType.generics
  40     Method Stof\DoctrineExtensionsBundle\DependencyInjection\Configuration::getVendorNode() return type with generic class Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition does not specify its types: TParent
         🪪  missingType.generics
  67     Method Stof\DoctrineExtensionsBundle\DependencyInjection\Configuration::getClassNode() return type with generic class Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition does not specify its types: TParent
         🪪  missingType.generics
  121    Method Stof\DoctrineExtensionsBundle\DependencyInjection\Configuration::getSoftDeleteableNode() return type with generic class Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition does not specify its types: TParent
         🪪  missingType.generics
  136    Method Stof\DoctrineExtensionsBundle\DependencyInjection\Configuration::getUploadableNode() return type with generic class Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition does not specify its types: TParent
         🪪  missingType.generics
```

Commits
-------

d21ad61 [Config] Define `TreeBuilder` default generic type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants