1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-03 10:07:52 +01:00
psalm/docs/running_psalm/issues/IfThisIsMismatch.md

35 lines
567 B
Markdown
Raw Normal View History

2020-07-14 20:00:22 +02:00
# IfThisIsMismatch
2021-09-22 10:26:21 +02:00
Emitted when the type in `@psalm-if-this-is` annotation cannot be contained by the object's actual type.
```php
<?php
/**
* @template T
*/
class a {
/**
* @var T
*/
private $data;
/**
* @param T $data
*/
public function __construct($data) {
$this->data = $data;
}
/**
* @psalm-if-this-is a<int>
*/
public function test(): void {
}
}
$i = new a(123);
$i->test();
$i = new a("test");
// IfThisIsMismatch - Class is not a<int> as required by psalm-if-this-is
$i->test();
```