You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive for covariant generic parameter #6139
PHPStan complains about passing a covariant parameter to another covariant parameter used in a contravariant position (but the parameter itself is covariant, so it's perfectly valid).
@@ @@+PHP 8.0 – 8.1 (1 error)+==========++21: Template type T is declared as covariant, but occurs in contravariant position in parameter element of method FormatLoader::addElement().++PHP 7.1 – 7.4 (3 errors)+==========++10: Method Element::render() has invalid return type mixed.+10: PHPDoc tag @return with type T is not subtype of native type mixed.
21: Template type T is declared as covariant, but occurs in contravariant position in parameter element of method FormatLoader::addElement().
Full report
PHP 8.0 – 8.1 (1 error)
Line
Error
21
Template type T is declared as covariant, but occurs in contravariant position in parameter element of method FormatLoader::addElement().
PHP 7.1 – 7.4 (3 errors)
Line
Error
10
Method Element::render() has invalid return type mixed.
10
PHPDoc tag @return with type T is not subtype of native type mixed.
21
Template type T is declared as covariant, but occurs in contravariant position in parameter element of method FormatLoader::addElement().
Activity
phpstan-bot commentedon Sep 4, 2024
@marcospassos After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.1 (1 error)
Template type T is declared as covariant, but occurs in contravariant position in parameter element of method FormatLoader::addElement().PHP 7.1 – 7.4 (3 errors)
Method Element::render() has invalid return type mixed.PHPDoc tag @return with type T is not subtype of native type mixed.Template type T is declared as covariant, but occurs in contravariant position in parameter element of method FormatLoader::addElement().Fix phpstan/phpstan#6139: False positive for covariant generic parameter