Skip to content

Improve type for predefined constant #3054

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

Merged
merged 2 commits into from
May 9, 2024

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.

@@ -232,7 +232,7 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
return IntegerRangeType::fromInterval(1, null);
}
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 added 2 commits May 9, 2024 00:34

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@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
443 of 445 checks passed
@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.

None yet

3 participants