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

Make it a PHPStan Extension #6

Closed
szepeviktor opened this issue Aug 28, 2020 · 6 comments
Closed

Make it a PHPStan Extension #6

szepeviktor opened this issue Aug 28, 2020 · 6 comments

Comments

@szepeviktor
Copy link
Contributor

szepeviktor commented Aug 28, 2020

"type": "phpstan-extension",

Why don't you make it an extension with sane defaults and easy configuration?

e.g. https://github.com/ekino/phpstan-banned-code/blob/master/composer.json#L3

@spaze
Copy link
Owner

spaze commented Aug 28, 2020

Thanks, I've learned about "type": "phpstan-extension" only earlier today, will add it.

I'm not sure what the defaults should be as every project is different but I'm open to suggestions. Also, what would you think an easy configuration should look like?

@spaze spaze closed this as completed in 8a526d4 Aug 28, 2020
@szepeviktor
Copy link
Contributor Author

I'm not sure what the defaults should be

In my fantasy/perfectionist world there are

https://github.com/szepeviktor/debian-server-tools/blob/f69faf72eac5c96f32721e35554cf321f49097e9/webserver/laravel/phpcs.xml#L21-L28

Here is a list of really bad ideas.

  • extract
  • eval
  • print and print_r
  • var_dump

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Aug 28, 2020

what would you think an easy configuration should look like?

That package has a relatively short config: types & functions.

https://github.com/ekino/phpstan-banned-code#advanced-usage

@spaze
Copy link
Owner

spaze commented Aug 28, 2020

I don't like this part of the config either:

    class: Spaze\PHPStan\Rules\Disallowed\MethodCalls
        tags:
            - phpstan.rules.rule
        arguments:

I'll think if this can be removed somehow. The DisallowedHelper will probably be removed from the manual config in #9. The rest of the config will stay (this extension also offers recommendations and can exclude paths, calls).

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Aug 28, 2020

I'll think if this can be removed somehow.

It is very simple.

  1. extension stuff goes into the standard extension.neon
    https://github.com/szepeviktor/phpstan-wordpress/blob/master/composer.json#L26-L32
  2. user stuff goes into the user's config in parameters:

@spaze
Copy link
Owner

spaze commented Aug 28, 2020

Thanks, that's how extensions work indeed.

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

No branches or pull requests

2 participants