Skip to content

Improve type for predefined constant#3054

Merged
ondrejmirtes merged 2 commits intophpstan:1.11.xfrom
zonuexe:fix/constant-types
May 9, 2024
Merged

Improve type for predefined constant#3054
ondrejmirtes merged 2 commits intophpstan:1.11.xfrom
zonuexe:fix/constant-types

Conversation

@zonuexe
Copy link
Contributor

@zonuexe zonuexe commented May 8, 2024

All these constants are strings that are neither '' nor '0' and are replaced by AccessoryNonFalsyStringType.

}
if ($resolvedConstantName === '__COMPILER_HALT_OFFSET__') {
return IntegerRangeType::fromInterval(0, null);
return IntegerRangeType::fromInterval(1, null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Zero-byte PHP code itself cannot output __COMPILER_HALT_OFFSET__, so it is always >=1.

The minimum value is probably 48, but it looks unnatural, so leave it above 1.

@herndlm
Copy link
Contributor

herndlm commented May 8, 2024

I added those in what I think was my first ever phpstan contribution 😊

@zonuexe zonuexe force-pushed the fix/constant-types branch from ec58d6f to 201b626 Compare May 8, 2024 15:34
@ondrejmirtes ondrejmirtes merged commit 173587f into phpstan:1.11.x May 9, 2024
@ondrejmirtes
Copy link
Member

Thank you!

@zonuexe zonuexe deleted the fix/constant-types branch May 10, 2024 01:04
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