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

Readme: add PHPStan extra strictness section #188

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ShipMonk PHPStan rules
About **30 super-strict rules** we found useful in ShipMonk.
We tend to have PHPStan set up as strict as possible ([bleedingEdge](https://phpstan.org/blog/what-is-bleeding-edge), [strict-rules](https://github.com/phpstan/phpstan-strict-rules), [checkUninitializedProperties](https://phpstan.org/config-reference#checkuninitializedproperties), ...), but that still was not strict enough for us.
About **40 super-strict rules** we found useful in ShipMonk.
We tend to have PHPStan set up as strict as possible, but that still was not strict enough for us.
This set of rules should fill the missing gaps we found.

If you find some rules opinionated, you can easily disable them.
Expand Down Expand Up @@ -776,6 +776,22 @@ class Example
}
```

## Native PHPStan extra strictness
Some strict behaviour in PHPStan is not enabled by default, consider enabling extra strictness even there:

```neon
includes:
- phar://phpstan.phar/conf/config.levelmax.neon
- phar://phpstan.phar/conf/bleedingEdge.neon # https://phpstan.org/blog/what-is-bleeding-edge
- vendor/phpstan/phpstan-strict-rules/rules.neon # https://github.com/phpstan/phpstan-strict-rules
parameters:
checkImplicitMixed: true # https://phpstan.org/config-reference#checkimplicitmixed
checkBenevolentUnionTypes: true # https://phpstan.org/config-reference#checkbenevolentuniontypes
checkUninitializedProperties: true # https://phpstan.org/config-reference#checkuninitializedproperties
checkMissingCallableSignature: true # https://phpstan.org/config-reference#vague-typehints
checkTooWideReturnTypesInProtectedAndPublicMethods: true # https://phpstan.org/config-reference#checktoowidereturntypesinprotectedandpublicmethods
```

## Contributing
- Check your code by `composer check`
- Autofix coding-style by `composer fix:cs`
Expand Down