Haehnchen / idea-php-phpunit-plugin

IntelliJ IDEA / PhpStorm PHPUnit Enhancement Plugin
MIT License
55 stars 11 forks source link

Restric types after assertion #53

Closed Jean85 closed 4 years ago

Jean85 commented 4 years ago

I'm using static analysis (PHPStan, Psalm) on my tests, and with the appropriate extensions they are able to restrict types after I've applied assertions.

$this->assertIsString($foo);
// $foo is string now

$this->assertIsInstanceOf(Bar::class, $foo);
// $foo is a Bar instance

Would it be possible to do the same here? It would enable autocomplete os such variables, and suppress warning due to unknown types.

Haehnchen commented 4 years ago

its not related to this plugin, the methods having the docblock describing the behavior.

https://github.com/Haehnchen/idea-php-generics-plugin you can look at this plugin; some docblock are already support.

King2500 commented 4 years ago

its not related to this plugin, the methods having the docblock describing the behavior.

How can you add PhpDoc yourself to methods for PHPUnit?

Haehnchen commented 4 years ago

PHPUnit is already having the docblock: https://github.com/sebastianbergmann/phpunit/blob/master/src/Framework/Assert.php#L1324

Jean85 commented 4 years ago

Thank you!