phpstan / phpstan-strict-rules

Extra strict and opinionated rules for PHPStan
MIT License
604 stars 48 forks source link

[1.5.0] Error after added `$bleedingEdge` constructor parameter #205

Closed adrenth closed 1 year ago

adrenth commented 1 year ago

After upgrading to v1.5.0 this error occurs when performing a phpstan analyze on my code:

> vendor/bin/phpstan analyse
Note: Using configuration file /var/www/html/phpstan.neon.dist.

In Resolver.php line 463:

  Service 'rules.190' (type of PHPStan\Rules\Operators\OperandsInArithmeticAdditionRule): Parameter $bleedingEdge in OperandsInArithmeticAdditionRule::__construct() has no class type or default value, so its value must be specified.  

Introduced in commit: https://github.com/phpstan/phpstan-strict-rules/commit/b7dd96a5503919a43b3cd06a2dced9d4252492f2

Line number: https://github.com/phpstan/phpstan-strict-rules/blame/b7dd96a5503919a43b3cd06a2dced9d4252492f2/src/Rules/Operators/OperandsInArithmeticAdditionRule.php#L24

Do I miss a new setting parameter in my configuration?

Contents of my /var/www/html/phpstan.neon.dist file:

includes:
    - ./[path-to-my-default-rules]/rules.neon

parameters:
    reportMaybesInPropertyPhpDocTypes: false
    checkGenericClassInNonGenericObjectType: false
    paths:
        - src
        - tests

Contents of my ./[path-to-my-default-rules]/rules.neon file:

includes:
    - includes/phpstan-strict-rules.neon

parameters:
    checkMissingIterableValueType: false
    level: 8
ondrejmirtes commented 1 year ago

You're probably registering your rules manually, putting them like this into your .neon, right?

rules:
    - PHPStan\Rules\Operators\OperandsInArithmeticAdditionRule

There's a better way. You need to include vendor/phpstan/phpstan-strict-rules/rules.neon from this repository and then use the configuration like this to enable/disable specific rules: https://github.com/phpstan/phpstan-strict-rules#disabling-rules

ondrejmirtes commented 1 year ago

I assume that includes/phpstan-strict-rules.neon wasn't written by us and that's why it's outdated...

adrenth commented 1 year ago

@ondrejmirtes I think you're right! We have included several .neon files in a separate package which we include. I will check if these files are up to date.

ondrejmirtes commented 1 year ago

You should always use the official ones, copying and pasting parts of the file is no longer encouraged.

github-actions[bot] commented 1 year ago

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.