Skip to content

Commit

Permalink
Added to documentation and tests that api can be used instead of `p…
Browse files Browse the repository at this point in the history
…salm-api`
  • Loading branch information
ygottschalk committed Mar 20, 2023
1 parent e86a55a commit f3a2182
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/annotating_code/supported_annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ 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 or method is used, even if no references to it can be
found. Unused issues will be suppressed.
Expand Down
17 changes: 17 additions & 0 deletions tests/UnusedCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,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 f3a2182

Please sign in to comment.