Skip to content

Commit

Permalink
Improve readme, explain some test part
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal committed Aug 24, 2023
1 parent 280c6cd commit 2e0b694
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ parameters:
### forbidCheckedExceptionInCallable
- Denies throwing [checked exception](https://phpstan.org/blog/bring-your-exceptions-under-control) in callables (Closures and First class callables) as those cannot be tracked as checked by PHPStan analysis, because it is unknown when the callable is about to be called
- It allows configuration of functions/methods, where the callable is called immediately, those cases are allowed and are also added to [dynamic throw type extension](https://phpstan.org/developing-extensions/dynamic-throw-type-extensions) which causes those exceptions to be tracked properly in your codebase (!)
- By default, native functions like `array_map` are present (see above). So it is recommended not to overwrite the defaults here.
- By default, native functions like `array_map` are present. So it is recommended not to overwrite the defaults here (by `!` char).
- It allows configuration of functions/methods, where the callable is handling all thrown exceptions and it is safe to throw anything from there; this basically makes such calls ignored by this rule
- It ignores [implicitly thrown Throwable](https://phpstan.org/blog/bring-your-exceptions-under-control#what-does-absent-%40throws-above-a-function-mean%3F), so it most make sense with `implicitThrows: false` configuration
- It ignores [implicitly thrown Throwable](https://phpstan.org/blog/bring-your-exceptions-under-control#what-does-absent-%40throws-above-a-function-mean%3F)

```neon
parameters:
Expand All @@ -376,7 +376,7 @@ parameters:
'Symfony\Component\Console\Question::setValidator': 0 # symfony automatically converts all thrown exceptions to error output, so it is safe to throw anything here
```

- Make sure you have enabled [checked exception](https://phpstan.org/blog/bring-your-exceptions-under-control), otherwise, this rule does nothing. We recommend using following config:
- We recommend using following config for checked exceptions:
- Also, [bleedingEdge](https://phpstan.org/blog/what-is-bleeding-edge) enables proper analysis of dead types in multi-catch, so we recommend enabling even that

```neon
Expand Down
2 changes: 1 addition & 1 deletion tests/Rule/ForbidCheckedExceptionInCallableRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function getRule(): Rule
[],
[],
[],
$this->checkedExceptions,
$this->checkedExceptions, // everything is checked when no config is provided
),
$visitorConfig['services'][0]['arguments']['immediatelyCalledCallables'], // @phpstan-ignore-line ignore mixed access
$visitorConfig['services'][0]['arguments']['allowedCheckedExceptionCallables'], // @phpstan-ignore-line ignore mixed access
Expand Down

0 comments on commit 2e0b694

Please sign in to comment.