Skip to content

Conversation

VincentLanglet
Copy link
Contributor

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.12.x. If your code is relevant on 1.11.x and you want it to be released sooner, please rebase your pull request and change its target to 1.11.x.

@VincentLanglet VincentLanglet changed the base branch from 1.12.x to 1.11.x August 9, 2024 10:37
Copy link
Contributor Author

@VincentLanglet VincentLanglet left a comment

Choose a reason for hiding this comment

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

Since you made #3192 you might want to review @staabm

return $singlePlaceholderEarlyReturn;
}

if ($allPatternsNonFalsy) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Early return to avoid the following computation.

$isNonEmpty = $allPatternsNonEmpty;
if (
count($formatStrings) === 0
!$isNonEmpty
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it's already known as non empty, we don't have to compute this.

!$isNonEmpty
&& $functionReflection->getName() === 'sprintf'
&& count($args) === 2
&& count($args) >= 2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a special case for sprintf($nonEmpty, $nonEmpty, $nonEmpty) but this can be extended to sprintf($nonEmpty, $nonEmpty, $nonEmpty) and so on.

continue;
}

if (!$scope->getType($arg->value)->toString()->isNonEmptyString()->yes()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The toString was added for things like IntegerRange which need to be casted before the isNonEmptyString check.

@ondrejmirtes
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants