Skip to content

Fixed code examples and format in the DI component documentation #2013

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

Merged
merged 3 commits into from
Dec 26, 2012

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Dec 9, 2012

No description provided.

->addArgument('%mailer.transport%');
$container
->register('mailer', 'Mailer')
->addArgument('%mailer.transport%');
Copy link
Member

Choose a reason for hiding this comment

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

I like breaking it onto 2 lines, but I don't usually add extra spaces on the second line of a chained call. Any reason why you're doing this - is it in the core code somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the method returns itself each time and you have method chaining, I won't indent the second line, but if the method returns a new instance it is nice to indent the next line. We have done that in the component/config article too.

Copy link
Member

Choose a reason for hiding this comment

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

the only place where we use extra indentation levels when chaining in Symfony is when using the Symfony\Component\Config\Definition\TreeBuilder, to make the indentation reflect the tree structure (making it far more readable than 100 chained calls indented the same)

Copy link
Member

Choose a reason for hiding this comment

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

@wouterj, I see your point, and I don't think we have a super-clear standard here one way or another, but I'm personally -1 on the format. It makes more sense in the TreeBuilder because you actually have ->end() statements at each node - so you build up the tree (and indent), and then have to work your way back down the tree (with ->end()). In this case, we're not returning the same instance, but it's not that same tree structure.

Copy link
Member Author

Choose a reason for hiding this comment

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

@weaverryan ok, I will change it today.

weaverryan added a commit that referenced this pull request Dec 26, 2012
Fixed code examples and format in the DI component documentation
@weaverryan weaverryan merged commit f2dbd6b into symfony:2.0 Dec 26, 2012
@weaverryan
Copy link
Member

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants