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

Static Code Analysis with Php Inspections (EA Extended) #6121

Merged
merged 2 commits into from
Nov 26, 2016
Merged

Static Code Analysis with Php Inspections (EA Extended) #6121

merged 2 commits into from
Nov 26, 2016

Conversation

kalessil
Copy link
Contributor

@kalessil kalessil commented Nov 6, 2016

Couple of findings

@@ -180,6 +180,7 @@ public function convertDoctrine1Schema(array $fromPaths, $destPath, $toType, $nu
);
}
}
unset($dirName);
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if I like this inspection. $dirName is not used after this location: let the stack garbage collection do its job.

Copy link
Contributor Author

@kalessil kalessil Nov 6, 2016

Choose a reason for hiding this comment

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

It's more tricky: https://3v4l.org/QKOKH - here unset should clean the scope after foreach.

UPD: relevant only to foreach-values being a reference

Copy link
Member

Choose a reason for hiding this comment

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

I know why this is applied, it just doesn't make sense if the variables are unused. I'd rather prefer extracting the loop into a private method instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, good approach btw. Reverting the change.

@@ -1629,6 +1629,7 @@ protected function _validateAndCompleteOneToOneMapping(array $mapping)
? $joinColumn['fieldName']
: $joinColumn['name'];
}
unset($joinColumn);
Copy link
Member

Choose a reason for hiding this comment

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

Same as below: this inspection is (IMO) not a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverting. I also curious why it's not a good idea, why?

Copy link
Member

Choose a reason for hiding this comment

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

It's just an additional instruction (also to read - not worried about performance)

@Ocramius Ocramius added this to the 2.6.0 milestone Nov 6, 2016
@kalessil
Copy link
Contributor Author

kalessil commented Nov 25, 2016

@Ocramius : I reverted usset constructs here, but checks are still saying that you requested changes.

@Ocramius Ocramius self-assigned this Nov 26, 2016
@Ocramius
Copy link
Member

@kalessil thanks for this, merging!

@Ocramius Ocramius merged commit 8c38f57 into doctrine:master Nov 26, 2016
@kalessil kalessil deleted the sca branch November 26, 2016 07:32
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.

2 participants