Skip to content

Commit 1d7faf9

Browse files
committed
ForbidUselessNullableReturnRule: fix readme, working only for methods
1 parent eee2284 commit 1d7faf9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,20 @@ function example(MyClass $class) {
101101
```
102102

103103
### ForbidUselessNullableReturnRule
104-
- Denies marking function return type as nullable when null is never returned
104+
- Denies marking method return type as nullable when null is never returned
105105
- Recommended to be used together with `UselessPrivatePropertyDefaultValueRule` and `UselessPrivatePropertyNullabilityRule`
106106
```neon
107107
rules:
108108
- ShipMonk\PHPStan\Rule\ForbidUselessNullableReturnRule
109109
```
110110
```php
111-
function example(int $foo): ?int { // null never returned
112-
if ($foo < 0) {
113-
return 0;
111+
class Example {
112+
public function example(int $foo): ?int { // null never returned
113+
if ($foo < 0) {
114+
return 0;
115+
}
116+
return $foo;
114117
}
115-
return $foo;
116118
}
117119
```
118120

0 commit comments

Comments
 (0)