-
Notifications
You must be signed in to change notification settings - Fork 545
Refactor ComposerPhpVersionFactory, ConstantResolver #3627
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
3cd6817 to
ae37f41
Compare
|
This pull request has been marked as ready for review. |
src/Analyser/ConstantResolver.php
Outdated
| private ?PhpVersion $composerMinPhpVersion, | ||
| private ?PhpVersion $composerMaxPhpVersion, | ||
| private int|array|null $phpVersion, | ||
| private ?ComposerPhpVersionFactory $composerPhpVersionFactory, |
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.
Why is this nullable?
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.
to allow creation of the ConstantResolver when the DI is not yet constructed
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.
Just pass new ComposerPhpVersionFactory with empty $composerAutoloaderProjectPaths there.
src/Analyser/ConstantResolver.php
Outdated
| ) { | ||
| $minRelease = $this->composerMinPhpVersion->getPatchVersionId(); | ||
| $maxRelease = $this->composerMaxPhpVersion->getPatchVersionId(); | ||
| $minRelease = $this->getMinPhpVersion()->getPatchVersionId(); |
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.
You're calling the getter multiple times and it always leads to creating new object. I'd just do if (in_array($resolvedConstantName, ['PHP_VERSION_ID', 'PHP_MAJOR_VERSION', 'PHP_MINOR_VERSION'])) and save it to a variable first, then use the variable. inside for each constant.
2ddbff8 to
38856cb
Compare
38856cb to
750aebf
Compare
750aebf to
73d0b16
Compare
|
Thank you! Now onto the diagnose command :) |
as requested in #3609 (review)