-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Description
I'm not sure if this is the correct repo to open this issue, but it seems to be the best place...
What I'd like to implement (with some help, sure) is the ability to do the same thing done when assert()
is called but when using PHPUnit's assertions:
Some context:
We create contexts for Behat using PHPUnit's assertions and sometimes we have this kind of code:
public function thenSomethingMustHaveHappened(): void
{
$something = $this->lovelyService->doSomething(); // which has `?Something` as return type hint
Assert::assertNotNull($something);
Assert::assertSame('Something', $something->getSomething());
}
Then PHPstan complains:
------ --------------------------------------------------------------------------------------------------
Line SomethingContext.php
------ --------------------------------------------------------------------------------------------------
XX Calling method getSomething() on possibly null value of type Something|null.
------ --------------------------------------------------------------------------------------------------
However if assert($something !== null)
is used, things just work...
Of course we could simply use assert()
everywhere but we rather use a more friendly tool. So this leads us to two questions:
- is this interesting for phpstan?
- how can we implement this?
Metadata
Metadata
Assignees
Labels
No labels