Skip to content

Commit 0b40dfa

Browse files
authored
Describe how to exclude insight per particular method (#543)
1 parent c9c04b6 commit 0b40dfa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/insights/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,38 @@ For example:
5858
],
5959
```
6060

61+
## Exclude insight per particular method
62+
63+
Open the insight class and look for `private const NAME` constant.
64+
65+
> If the `NAME` constant doesn't exist, go to the `2nd option` paragraph (below).
66+
67+
Copy value of the `NAME` constant and open a class with method that you would like exclude insight for. In the phpDoc add `@phpcsSuppress` annotation.
68+
69+
#### Example
70+
71+
After running `vendor/bin/phpinsights` you saw an error:
72+
73+
```bash
74+
• [Code] Unused parameter:
75+
src/YourClass.php:19: Unused parameter $thisIsUnusedParameter.
76+
```
77+
78+
After verififcation [in documentation](https://phpinsights.com/insights/code.html#unused-parameter), you know that `\SlevomatCodingStandard\Sniffs\Functions\UnusedParameterSniff` class is responsible for the `[Code] Unused parameter` error and it contains `private const NAME = 'SlevomatCodingStandard.Functions.UnusedParameter’;`. Let's use it together with the `@phpcsSuppress` annotation:
79+
80+
```php
81+
final class YourClass
82+
{
83+
/**
84+
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
85+
*/
86+
public function yourMethod(array $thisIsUnusedParameter): void
87+
{
88+
// ...
89+
}
90+
}
91+
```
92+
6193
## Add Insights
6294

6395
If you create an Insight, or an Insight is not enabled, you can enable it in the `add` section.

0 commit comments

Comments
 (0)