Skip to content

Commit

Permalink
Merge pull request #9544 from ygottschalk/doc/psalm-api-on-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Mar 20, 2023
2 parents b381f47 + 85a1c83 commit 0af503a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/annotating_code/supported_annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,9 @@ function (): Generator {
```
This annotation supports only generic types, meaning that e.g. `@psalm-yield string` would be ignored.

### `@psalm-api`
### `@api`, `@psalm-api`

Used to tell Psalm that a class is used, even if no references to it can be
Used to tell Psalm that a class or method is used, even if no references to it can be
found. Unused issues will be suppressed.

For example, in frameworks, controllers are often invoked "magically" without
Expand Down
17 changes: 17 additions & 0 deletions tests/UnusedCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,23 @@ public function b(): void {}
new A;
PHP,
],
'api with unused class' => [
'code' => <<<'PHP'
<?php
/** @api */
class A {}
PHP,
],
'api on unused public method' => [
'code' => <<<'PHP'
<?php
class A {
/** @api */
public function b(): void {}
}
new A;
PHP,
],
];
}

Expand Down

0 comments on commit 0af503a

Please sign in to comment.