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

Support for self::CONST_*_SUFFIX with suffixes #5534

Closed
Seldaek opened this issue Aug 26, 2021 · 4 comments · Fixed by phpstan/phpstan-src#658
Closed

Support for self::CONST_*_SUFFIX with suffixes #5534

Seldaek opened this issue Aug 26, 2021 · 4 comments · Fixed by phpstan/phpstan-src#658

Comments

@Seldaek
Copy link
Contributor

Seldaek commented Aug 26, 2021

Feature request

I tried using a const wildcard in the middle and it blew up on me :) I assumed this would just work but it appears to be only supported as a trailing wildcard. I'm not sure if there is a good reason for this or if it's just an omission, but it would be nice if wildcards were supported anywhere in the constant name IMO.

Happy to try and send a PR if you approve of the idea and can maybe point me in the right direction, as I am not familiar with the large codebase.

@staabm
Copy link
Contributor

staabm commented Aug 26, 2021

could you show us in a code sample what you expect on the https://phpstan.org/ sandbox?

@Seldaek
Copy link
Contributor Author

Seldaek commented Aug 26, 2021

Sure https://phpstan.org/r/b84f6dba-50dd-4e59-bd37-e83826e80d88 I expect no error here :)

As you can see I couldn't simply use FOO_* in this case as it would include other constants I am not interested in, forcing me to list all of them one by one as self::FOO_BAR_BAZ|self::FOO_BOO_BAZ|...

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Aug 27, 2021

This isn't to hard too do. Two places need to be modified:

  1. The parser part, original commit with * support is here: phpstan/phpdoc-parser@fde6cca
  2. TypeNodeResolver here in phpstan-src, original commit: phpstan/phpstan-src@730a902 (you can see the part with Strings::endsWith($constantName, '*') which needs modification)

Seldaek added a commit to Seldaek/phpstan-src that referenced this issue Sep 5, 2021
Seldaek added a commit to Seldaek/phpstan-src that referenced this issue Sep 5, 2021
Seldaek added a commit to Seldaek/phpstan-src that referenced this issue Sep 5, 2021
ondrejmirtes added a commit that referenced this issue Sep 12, 2021
phpstan/phpstan-src@1c6bb6b Add support for multiple wildcards in const type annotations, fixes #5534
@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 Oct 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants