-
-
Notifications
You must be signed in to change notification settings - Fork 930
Closed
Description
PHP 8.0 brings reworked type definitions and PhpStan utilize this new information.
Until now, when the PhpStan didn't know the type correctly, the code would handle it properly and we added @phpstan-ignore-line
annotation, which had supressed the PhpStan's missing knowledge. The PHP8 definition support however breaks this, since PhpStan begins reporting that the ignore comment ignores nothing.
Current solution - stick with phpstan-ignore and also add reportUnmatchedIgnoredErrors: false
configuration.
https://phpstan.org/r/417d57f1-4fe6-488a-91e8-7e7073f621eb
Possible solution: Introduce special ignore annotation that are checked only in the specific passed version:
@phpstan-ignore-line-until 8.0
- this ignore will be ignoring only in PHP versions < 8.0@phpstan-ignore-line-since 8.0
- this ignore will be ignoring only in PHP versions >= 8.0- no unmatched error is reported on PHP versions which does not match
The example above would look like
/**
* @param \PDOStatement<mixed> $statement
*/
function getType(\PDOStatement $statement): string
{
$meta = $statement->getColumnMeta(0);
if ($meta === false) { // @phpstan-ignore-line-until 8.0
throw new RuntimeException();
}
return $meta['type'] ?? '';
}
Metadata
Metadata
Assignees
Labels
No labels