Skip to content

Commit

Permalink
readme: remove duplicated paragraph, improve (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal authored Jun 14, 2022
1 parent 452f53c commit 4209221
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ All you need to enable most of the rules is to register them [as documented in p
Some of them need some specific [rich parser node visitor](https://phpstan.org/blog/preprocessing-ast-for-custom-rules) to be registered as well.
Rarely, some rules are reliable only when some other rule is enabled.

### AllowNamedArgumentOnlyInAttributesRuleTest
- Allowes usage of named arguments only in native attributes
### AllowNamedArgumentOnlyInAttributesRule
- Allows usage of named arguments only in native attributes
- Before native attributes, we used [DisallowNamedArguments](https://github.com/slevomat/coding-standard#slevomatcodingstandardfunctionsdisallownamedarguments). But we used Doctrine annotations, which almost "require" named arguments when converted to native attributes.
- Requires NamedArgumentSourceVisitor to work
```neon
rules:
- ShipMonk\PHPStan\Rule\AllowNamedArgumentOnlyInAttributesRuleTest
- ShipMonk\PHPStan\Rule\AllowNamedArgumentOnlyInAttributesRule
services:
-
class: ShipMonk\PHPStan\Visitor\NamedArgumentSourceVisitor
Expand All @@ -47,6 +47,7 @@ class User {
### ForbidFetchOnMixedRule
- Denies property fetch on unknown type.
- Any property fetch assumes the caller is an object with such property and therefore, the typehint/phpdoc should be fixed.
- Similar to `ForbidMethodCallOnMixedRule`
```neon
rules:
- ShipMonk\PHPStan\Rule\ForbidFetchOnMixedRule
Expand Down Expand Up @@ -75,6 +76,7 @@ match ($enum) {
### ForbidMethodCallOnMixedRule
- Denies calling methods on unknown type.
- Any method call assumes the caller is an object with such method and therefore, the typehint/phpdoc should be fixed.
- Similar to `ForbidFetchOnMixedRule`
```neon
rules:
- ShipMonk\PHPStan\Rule\ForbidMethodCallOnMixedRule
Expand Down Expand Up @@ -114,19 +116,6 @@ function example(int $foo): ?int { // null never returned
}
```

### ForbidUnsetClassFieldRule
- Denies calling `unset` over class field as it causes un-initialization, see https://3v4l.org/V8uuP
- Null assignment should be used instead
```neon
rules:
- ShipMonk\PHPStan\Rule\ForbidUnsetClassFieldRule
```
```php
function example(MyClass $class) {
unset($class->field); // denied
}
```

### ForbidUnusedExceptionRule
- Reports forgotten exception throw (created or returned from function, but not used in any way)
- Requires `UnusedExceptionVisitor` to work
Expand Down

0 comments on commit 4209221

Please sign in to comment.