Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Feb 22, 2022

@clxmstaab clxmstaab force-pushed the str-repeat branch 2 times, most recently from ed665c1 to 14b954c Compare February 22, 2022 09:13
}

if ($inputType instanceof ConstantStringType && $multiplierType instanceof ConstantIntegerType) {
return new ConstantStringType(str_repeat($inputType->getValue(), $multiplierType->getValue()));
Copy link
Member

Choose a reason for hiding this comment

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

The code will crash when analysing code like this: https://3v4l.org/XRaOj

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. added a test and made it return NeverType on negative multiplier

@ondrejmirtes ondrejmirtes merged commit f5b3cdf into phpstan:master Feb 22, 2022
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the str-repeat branch February 22, 2022 16:27
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.

Constant string in str_repeat

3 participants