Bug report
Referring the the code snippet... It appears that PHPStan assumes that $person is always set. Given the method createPersonButCouldFail can throw an exception (and is annotated with @throws), this will not always be the case.
Code snippet that reproduces the problem
https://phpstan.org/r/671b1297-7856-4edf-871f-8f9e1d4f7169
Expected output
Expect 2 outcomes:
- Issue currently reported on line 22 (
If condition is always true) is not reported
- An issue is reported on line 27 (
Cannot call method aMethod() on Person|null.)