If in a Context that extends PageObjectContext I write:
private function getLoginPage(): LoginPage
{
return $this->getPage(LoginPage::class);
}
Both PHPStan and PHPStorm emit a warning. PHPStan warning message is: phpstan: Method Behat\Context\Ui\User\ChangePasswordContext::getLoginPage() should return Behat\Page\User\LoginPage but returns SensioLabs\Behat\PageObjectExtension\PageObject\Page.
My change allows static analysis to infer the right return type.
This PR solves the following issue.
If in a Context that extends PageObjectContext I write:
Both PHPStan and PHPStorm emit a warning. PHPStan warning message is:
phpstan: Method Behat\Context\Ui\User\ChangePasswordContext::getLoginPage() should return Behat\Page\User\LoginPage but returns SensioLabs\Behat\PageObjectExtension\PageObject\Page.
My change allows static analysis to infer the right return type.