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

Using Bleeding Edge with constants visibility #4859

Closed
jdecool opened this issue Apr 15, 2021 · 7 comments · Fixed by phpstan/phpstan-src#495
Closed

Using Bleeding Edge with constants visibility #4859

jdecool opened this issue Apr 15, 2021 · 7 comments · Fixed by phpstan/phpstan-src#495

Comments

@jdecool
Copy link

jdecool commented Apr 15, 2021

Feature request

I'm using Bleeding Edge feature in my project which use an Enum library implementation (myclabs/php-enum).

In my project, I don't want to expose internal constants values.
So my Enum looks like that:

/**
 * @method static static FOO()
 * @method static static BAR()
 */
class MyEnum extends Enum
{
    private const FOO = 'foo';
    private const BAR = 'bar';
}

But those constants are detected as not being used event if the are (the library resolve it by using PHP magic methods).
Currently the only way to override this variables detection is to use the ReadWritePropertiesExtension interface, but it's not working with constants.

@enumag
Copy link
Contributor

enumag commented Apr 15, 2021

I'd recommend reporting this to https://github.com/timeweb/phpstan-enum instead. It's not a responsibility of PHPStan itself to account for special cases from various libraries. Cases like these should instead be taken care of by an extension in my opinion. Also you can always choose to ignore the error.

@ondrejmirtes
Copy link
Member

timeweb/phpstan-enum can't do anything about it as there isn't an extension interface to suppress this error in PHPStan. There would have to be some AlwaysUsedClassConstantsExtension to be able to get rid of it.

@jdecool
Copy link
Author

jdecool commented Apr 15, 2021

There would have to be some AlwaysUsedClassConstantsExtension to be able to get rid of it.

It would be great 👍🏼

Are you open to a PR that implement some like this ?

@ondrejmirtes
Copy link
Member

Yeah, sure, I'd like it!

@ondrejmirtes
Copy link
Member

Thanks to phpstan/phpstan-src#495 it's now possible to write a custom extension to describe this :)

@jdecool
Copy link
Author

jdecool commented Apr 17, 2021

Thanks for you work on this library :)

@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 May 19, 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