szepeviktor/phpstan-wordpress

Question: how to configure phpstan-wordpress to use Neutron Standard?

jcvignoli opened this issue · 8 comments

Hi,

I'm a phpcs user, using Neutron standard rules.

I've just started using phpstan and phpstan-wordress too. I'm quite new to these tools, I just copied-pasted your neon config files but I can't figure out how to make use of Neutron rules.

Could you kindly help me?

Thanks!

Hello Jean-Claude! Thank you for your question.
PHPCS and PHPStan are two completely different tools, there is no connection between them.

BTW I follow Neutron while writing this extension.

What you can do:

  • read the README
  • see files in /example folder
  • read PHPStan's documentation

Hi Victor @szepeviktor

Thanks for your quick reply!

I know these are two different tools. However, you mention in phpstan-wordpress readme that Neutron rules can be applied to phphstan-wordpress. I'd like to know how to configure it, I haven't found any example provided. You just mention it, and I can't find any readymade neon config.

Thanks!

The "Make your code testable" section contains some advises on :) how to make your code testable.

If you are not bound by PHP 5 consider following Neutron Standard

If you write your code following Neutron Standard your code will be more testable.

Please bear with me if I'm not understanding the obvious, but here is my phpstan.neon:

includes:
    - vendor/szepeviktor/phpstan-wordpress/extension.neon
    - vendor/phpstan/phpstan/conf/bleedingEdge.neon
    - vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
    level: max
    # WpThemeMagicPropertiesClassReflectionExtension needs WP_Theme
    scanFiles:
        - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
    paths:
        - src/
    excludePaths:
      analyse:
        - src/vendor/*

Since I've installed Neutron Standard rules, I guess these are not automatically included in phpstan, rigth?
Should I add/remove includes in the first lines?

Since I've installed Neutron Standard rules, I guess these are not automatically included in phpstan, rigth?

Neutron is for a completely different software called PHPCS.
PHPStan has no connection with PHPCS/Neutron.

I got it now. PhpStan doesn't rely on external rules.

Noted and thanks for your help and excellent library!

Neutron rules are for PHPCS, not external ones for PHPStan.