Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@gharlan
Copy link
Contributor

@gharlangharlan commentedApr 8, 2019
edited
Loading

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?yes
Tests pass?
Fixed tickets#29876
LicenseMIT
Doc PR

Alternative idea to#31015. Or is theroot method still needed?

It would look like this:

Screenshot 2019-04-09 01 15 04

@gharlangharlan changed the titleDeprecate TreeBuilder::root[Config] Deprecate TreeBuilder::rootApr 8, 2019
Copy link
Member

@xabbuhxabbuh left a 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.

@gharlangharlanforce-pushed thedeprecate-tree-builder-root branch from0d4689b toff6bc79CompareApril 9, 2019 10:34
@gharlan
Copy link
ContributorAuthor

Status: Needs Review

@fabpot
Copy link
Member

Thank you@gharlan.

@fabpotfabpot merged commitff6bc79 intosymfony:masterApr 9, 2019
fabpot added a commit that referenced this pull requestApr 9, 2019
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:![Screenshot 2019-04-09 01 15 04](https://user-images.githubusercontent.com/330436/55762865-fbd85900-5a64-11e9-9680-0870c85d1c09.png)Commits-------ff6bc79 Deprecate TreeBuilder::root
@gharlangharlan deleted the deprecate-tree-builder-root branchApril 9, 2019 20:23
@sstok
Copy link
Contributor

This makes compatibility for older versions much harder as you still need to callroot() in those cases, while passing the name to the constructor was was already possible.

$treeBuilder =newTreeBuilder('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.
In this case, return$this->root and do nothing, otherwise throw an deprecation instead.

To ensure forward compatibility you still need to check if theroot() method exists. But least you don't get any deprecation warnings.

$treeBuilder =newTreeBuilder('rollerworks_password_strength');if (method_exists($treeBuilder,'root')) {$rootNode =$treeBuilder->root('rollerworks_password_strength');// BC for Symfony < 4.2}else {$rootNode =$treeBuilder->getRootNode();}
Taluu and greg0ire reacted with thumbs up emoji

@gharlan
Copy link
ContributorAuthor

As far as I know many libs already usemethod_exists.

@sstok
Copy link
Contributor

Ah I completely missed#27476 😛

#27476 (comment) gives a good suggestion

$treeBuilder =newTreeBuilder("my_node");$rootNode =method_exists($treeBuilder,"getRootNode")    ?$treeBuilder->getRootNode()    :$treeBuilder->root("my_node");

👍

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@xabbuhxabbuhxabbuh approved these changes

@chalasrchalasrchalasr approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

8 participants

@gharlan@fabpot@sstok@nicolas-grekas@xabbuh@chalasr@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp