[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

Refactor ComposerPhpVersionFactory, ConstantResolver #3627

Merged
merged 4 commits into from
Nov 13, 2024

Conversation

staabm
Copy link
Contributor
@staabm staabm commented Nov 12, 2024

as requested in #3609 (review)

@staabm staabm marked this pull request as ready for review November 12, 2024 16:24
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

private ?PhpVersion $composerMinPhpVersion,
private ?PhpVersion $composerMaxPhpVersion,
private int|array|null $phpVersion,
private ?ComposerPhpVersionFactory $composerPhpVersionFactory,
Copy link
Member

Choose a reason for hiding this comment

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

Why is this nullable?

Copy link
Contributor Author

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

Copy link
Member

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.

) {
$minRelease = $this->composerMinPhpVersion->getPatchVersionId();
$maxRelease = $this->composerMaxPhpVersion->getPatchVersionId();
$minRelease = $this->getMinPhpVersion()->getPatchVersionId();
Copy link
Member

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.

@ondrejmirtes ondrejmirtes merged commit 5a132f1 into phpstan:2.0.x Nov 13, 2024
421 checks passed
@ondrejmirtes
Copy link
Member

Thank you! Now onto the diagnose command :)

@staabm staabm deleted the refactor-versions branch November 13, 2024 08:41
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