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

Why type: phpstan-extension is mandatory? #13

Closed
kylekatarnls opened this issue Aug 28, 2019 · 10 comments
Closed

Why type: phpstan-extension is mandatory? #13

kylekatarnls opened this issue Aug 28, 2019 · 10 comments

Comments

@kylekatarnls
Copy link

Hello, I'm considering adding an extension.neon in an existing library to help recognizing methods available via __call / __callStatic PHPStan can't recognize.

Extension's composer package type has to be set to phpstan-extension for this plugin to be able to recognize it.

The library itself is not a PHPStan extension (so I can't set type to phpstan-extension). But I would like than my library users who also use PHPStan get those methods recognized by PHPStan the easier way.

Creating an other package to handle the extension.neon + 1 small file seems overkill too.

And finally, I think having a extra.phpstan property is enough to recognize a library that includes PHPStan files. Why requiring this additional phpstan-extension flag?

Thanks.

@ondrejmirtes
Copy link
Member

I'm not sure. Is there a reason for the type @lookyman?

Anyway, phpstan/extension-installer can afford to be opinionated. It doesn't have to be used by everyone. You can always include your extension.neon manually in your project's phpstan.neon.

@jdeniau
Copy link
Contributor

jdeniau commented Oct 17, 2019

Hi,

I'm in the same situation here.
I am trying to create a phpstan extension for mapado/rest-client-sdk, and I would prefer include the phpstan files directly in the library because they are really coupled.

I think we can replace in https://github.com/phpstan/extension-installer/blob/master/src/Plugin.php#L85

- if ($package->getType() !== 'phpstan-extension') {
+ if ($package->getType() !== 'phpstan-extension' || !isset($package->getExtra()['phpstan']['includes'])) {

I am willing to make a PR if you are OK with this.

@ondrejmirtes
Copy link
Member

This condition is wrong, you need negated one.

@jdeniau
Copy link
Contributor

jdeniau commented Oct 17, 2019

This condition is wrong, you need negated one.

I updated the snippet 😉

@ondrejmirtes
Copy link
Member

Please use && instaed of ||. I will accept the PR.

@jdeniau
Copy link
Contributor

jdeniau commented Oct 18, 2019

@ondrejmirtes Done

@lookyman
Copy link
Collaborator

There really isn't a reason for the package type. I think I just wanted a safeguard for the installer to kick in. I'm fine with removing it.

@ondrejmirtes
Copy link
Member

I think it’s great for finding compatible packages on Packagist: https://packagist.org/explore/?type=phpstan-extension

But it should be optional in the definition.

@ondrejmirtes
Copy link
Member

Solved with #16.

@github-actions
Copy link

github-actions bot commented May 1, 2021

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 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants