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

numeric-string is non considered non-empty-string #7265

Closed
staabm opened this issue May 19, 2022 · 2 comments · Fixed by phpstan/phpstan-src#1428
Closed

numeric-string is non considered non-empty-string #7265

staabm opened this issue May 19, 2022 · 2 comments · Fixed by phpstan/phpstan-src#1428
Labels
Milestone

Comments

@staabm
Copy link
Contributor

staabm commented May 19, 2022

Bug report

I have a method, for which I want to define a contract that it is returning a non-empty-string.

I consider it an implementation detail, that technically the method is returning a numeric-string.
Isn't a numeric-string always a non-empty-string and therefore this error should not appear?

Code snippet that reproduces the problem

https://phpstan.org/r/7a8ac4a2-9417-456c-9ec3-330a92d7fff2

expected no error

@mad-briller
Copy link
Contributor

i tried looking into this as it also affected me, but you beat me to the report by an hour :D

AccessoryNumericStringType does return yes for the isNonEmptyString() method already:
https://github.com/phpstan/phpstan-src/blob/1.7.x/src/Type/Accessory/AccessoryNumericStringType.php#L170

so i'm not sure where the issue lies

i also tried updating isSubTypeOf to return yes when $otherType was a non-empty-string but that broke other test cases, so not sure where to go from here

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants