Provides additional rules for phpstan/phpstan
.
Run
$ composer require --dev alister/phpstan-rules
All of the rules provided (and used) by this library are included in src/LoggerContext/rules.neon
.
When you are using phpstan/extension-installer
, rules.neon
will be automatically included (To be confirmed).
Otherwise you need to include rules.neon
in your phpstan.neon
:
includes:
- vendor/alister/phpstan-rules/src/LoggerContext/rules.neon
parameters:
logger_context:
disallowed_namespaces:
- App\Entity
- App\DTOs
đź’ˇ You probably want to use these rules on top of the rules provided by:
This package provides the following rules for use with phpstan/phpstan
:
Alister\PHPStan\Rules\LoggerContext\KeyDotsRule
Alister\PHPStan\Rules\LoggerContext\ObjectAsValuesRule
LoggerContext\KeyDotsRule
// This would not be allowed:
$this->log->notice('The ID of a user:', ['user.id' => $user->getId()]); // key contains '.'
$this->log->notice('Logging this key as user_id is OK', ['user_id' => $user->getId()]);
This rule allows you to specify objects from namespaces should not be logged in their entirety. Scalar values are allowed, but not entire objects.
parameters:
logger_context:
disallowed_namespaces:
- App\Entity
// This would not be allowed:
$this->log->notice('here is a User object', ['user' => $user]); // $user is an object instance from \App\Entity namespace
$this->log->notice('Logging the user id is OK', ['user_id' => $user->getId()]);
Please have a look at CHANGELOG.md
.
Please have a look at CONTRIBUTING.md
.
Please have a look at CODE_OF_CONDUCT.md
.
This package is licensed using the MIT License.
Please have a look at LICENSE.md
.
The repository layout, workflow & tests, is based on ergebnis/phpstan-rules (originally licensed under MIT).