Skip to content
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

Remove unnecessary else #6714

Merged
merged 3 commits into from
Sep 21, 2017
Merged

Remove unnecessary else #6714

merged 3 commits into from
Sep 21, 2017

Conversation

guiajlopes
Copy link
Contributor

Just a small improvement in the code since the else is unnecessary on this case

@@ -751,7 +751,8 @@ public function walkSelectClause($selectClause)
foreach ($class->associationMappings as $assoc) {
if ( ! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) {
continue;
} else if ( !$addMetaColumns && !isset($assoc['id'])) {
}
if ( !$addMetaColumns && !isset($assoc['id'])) {
Copy link
Member

Choose a reason for hiding this comment

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

Add an empty line between logical blocks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Ocramius thanks, done!

} else if ( !$addMetaColumns && !isset($assoc['id'])) {
}

if ( !$addMetaColumns && !isset($assoc['id'])) {
Copy link
Member

Choose a reason for hiding this comment

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

@guiajlopes according to our CS we need spaces before AND after the negation operator, so this should be:

if ( ! $addMetaColumns && ! isset($assoc['id'])) {

Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to turn this into a single IF with an OR instead? Like:

if ( ! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)
    || ( ! $addMetaColumns && ! isset($assoc['id']))) {

I mean, both are fine... just wondering 😜

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lcobucci thanks for your review, make sense to turn in the same if statement

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @guiajlopes

@Ocramius Ocramius self-assigned this Sep 21, 2017
@Ocramius Ocramius added this to the 2.6.0 milestone Sep 21, 2017
@Ocramius Ocramius merged commit 1d5c87e into doctrine:master Sep 21, 2017
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.

None yet

3 participants