In the WordPress core test suite the following assertion methods are available:
$this->assertNotWPError()
$this->assertWPError()
It would be great if this extension treated these methods as type-narrowing functions, so the following code would not throw an error in PHPStan:
$terms = wp_get_post_terms( $post_id, $taxonomy );
$this->assertNotWPError( $terms );
$this->assertCount( 0, $terms );
Currently this triggers the following error because $terms is assumed to be array|WP_Error on the last line.
[phpstan] Parameter #2 $haystack of method PHPUnit\Framework\Assert::assertCount() expects Countable|iterable, array|WP_Error given.
In the WordPress core test suite the following assertion methods are available:
$this->assertNotWPError()$this->assertWPError()It would be great if this extension treated these methods as type-narrowing functions, so the following code would not throw an error in PHPStan:
Currently this triggers the following error because
$termsis assumed to bearray|WP_Erroron the last line.