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

errors even with allRules: false #185

Closed
gemal opened this issue Aug 25, 2022 · 12 comments · Fixed by #186
Closed

errors even with allRules: false #185

gemal opened this issue Aug 25, 2022 · 12 comments · Fixed by #186

Comments

@gemal
Copy link

gemal commented Aug 25, 2022

I just updated to strict v1.4.0 and I added:

includes:
    - vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
    strictRules:
        allRules: false

but now I'm getting this:

Variable property access on $this(App\Controller\AppController).

is this correct? I thought that allRules: false disabled all strict rules

@ondrejmirtes
Copy link
Member

Can you please post the code sample that reports this?

/cc @MartinMystikJonas

@gemal
Copy link
Author

gemal commented Aug 25, 2022

$this->{$model}->localeDetails['Country'] = $country['Country'];

doesn't allRules: false disable all the strict rules?

@ondrejmirtes
Copy link
Member

Yeah, it should, there's gonna be some misconfiguration that should be obvious by looking at rules.neon.

@MartinMystikJonas
Copy link
Contributor

I will check it

@gemal
Copy link
Author

gemal commented Aug 25, 2022

perhaps I dont understand the documentation
I used to have this in the phpstan.neon

services:
    -
        class: PHPStan\Rules\SwitchConditions\MatchingTypeInSwitchCaseConditionRule
        tags:
            - phpstan.rules.rule

then I updated strict and deleted it and replaced it with:

includes:
    - vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
    strictRules:
        allRules: false

and now all kind of errors

@ondrejmirtes
Copy link
Member

This is the problem:

tags:
- phpstan.rules.rule

Besides allRules: false you should also check the additional parameters (that are off by default in PHPStan core but strict-rules enable them too):

polluteScopeWithLoopInitialAssignments: false
polluteScopeWithAlwaysIterableForeach: false
checkAlwaysTrueCheckTypeFunctionCall: true
checkAlwaysTrueInstanceof: true
checkAlwaysTrueStrictComparison: true
checkAlwaysTrueLooseComparison: true
checkDynamicProperties: %featureToggles.bleedingEdge%
checkExplicitMixedMissingReturn: true
checkFunctionNameCase: true
checkInternalClassCaseSensitivity: true
reportMaybesInMethodSignatures: true
reportStaticMethodSignatures: true
reportMaybesInPropertyPhpDocTypes: true

@MartinMystikJonas
Copy link
Contributor

Yeah I found it too. I am already working on PR with fix.

@MartinMystikJonas
Copy link
Contributor

Should be fixed by PR #186

@gemal
Copy link
Author

gemal commented Aug 25, 2022

I tried to use 1.4.2 and even with allRules: false I get:

  153    PHPDoc type array of property App\Controller\AppController::$helpers is not the same as PHPDoc type mixed of overridden property
         Controller::$helpers.
         💡 You can fix 3rd party PHPDoc types with stub files:
            https://phpstan.org/user-guide/stub-files
            This error can be turned off by setting
            reportMaybesInPropertyPhpDocTypes: false in your ../phpstan.neon.

Parameter #2 $status (int) of method App\Controller\AppController::redirect() should be contravariant with parameter $status (array|int|string|null)
         of method Controller::redirect()

first one fixed by setting reportMaybesInPropertyPhpDocTypes:false but the other remain

@MartinMystikJonas
Copy link
Contributor

@gemal That could be probably fixed by reportMaybesInMethodSignatures: false but I am not sure without code example.

@MartinMystikJonas
Copy link
Contributor

@gemal Strict rules does not only add new rules (that could be disabled by allRules: false) but also modify settings of standard rules.

Here is complete list of settings modifications did by including strict rules:

	polluteScopeWithLoopInitialAssignments: false
	polluteScopeWithAlwaysIterableForeach: false
	checkAlwaysTrueCheckTypeFunctionCall: true
	checkAlwaysTrueInstanceof: true
	checkAlwaysTrueStrictComparison: true
	checkAlwaysTrueLooseComparison: true
	checkDynamicProperties: %featureToggles.bleedingEdge%
	checkExplicitMixedMissingReturn: true
	checkFunctionNameCase: true
	checkInternalClassCaseSensitivity: true
	reportMaybesInMethodSignatures: true
	reportStaticMethodSignatures: true
	reportMaybesInPropertyPhpDocTypes: true

You can switch them back to default if you do not want stricter settings enabled.

@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 Sep 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants