Skip to content

Fix Stateful::_fromState return typehint

Jiří Pudil requested to merge fix-fromstate-return-typehint into master

phpstan-strict-rules in projects using Stateful reports the following error:

Return type (MyStatefulClass) of method MyStatefulClass::_fromState() should be covariant with return type (static(Grifart\Stateful\Stateful)) of method Grifart\Stateful\Stateful::_fromState()

According to the reasoning here, this won't be fixed in PHPStan because with static, there is actually no way to ensure that LSP can't be violated. I suggest sticking with self which should be the way to go anyway once PHP 7.4 with covariant return types is released.

Merge request reports

Loading