-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Config] Deprecate TreeBuilder::root #31027
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
Conversation
src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php
Outdated
Show resolved
Hide resolved
8f24200
to
0d4689b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, please mention the deprecation in the component changelog file as well as in the upgrade files for 4.3 and 5.0.
0d4689b
to
ff6bc79
Compare
Status: Needs Review |
Thank you @gharlan. |
This PR was merged into the 4.3-dev branch. Discussion ---------- [Config] Deprecate TreeBuilder::root | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | | Fixed tickets | #29876 | License | MIT | Doc PR | — Alternative idea to #31015. Or is the `root` method still needed? It would look like this:  Commits ------- ff6bc79 Deprecate TreeBuilder::root
This makes compatibility for older versions much harder as you still need to call $treeBuilder = new TreeBuilder('rollerworks_password_strength');
$rootNode = $treeBuilder->root('rollerworks_password_strength'); // BC for Symfony < 4.2 What about checking if a name was already set in the constructor, and it equals the passed name. To ensure forward compatibility you still need to check if the $treeBuilder = new TreeBuilder('rollerworks_password_strength');
if (method_exists($treeBuilder, 'root')) {
$rootNode = $treeBuilder->root('rollerworks_password_strength'); // BC for Symfony < 4.2
} else {
$rootNode = $treeBuilder->getRootNode();
} |
As far as I know many libs already use |
Ah I completely missed #27476 😛 #27476 (comment) gives a good suggestion $treeBuilder = new TreeBuilder("my_node");
$rootNode = method_exists($treeBuilder, "getRootNode")
? $treeBuilder->getRootNode()
: $treeBuilder->root("my_node"); 👍 |
Alternative idea to #31015. Or is the
root
method still needed?It would look like this: