1.2.112. Cant Inherit Abstract Method¶
Inheriting abstract methods was made available in PHP 7.2. In previous versions, it emitted a fatal error.
<?php
abstract class A { abstract function bar(stdClass $x); }
abstract class B extends A { abstract function bar($x): stdClass; }
// Fatal error: Can't inherit abstract function A::bar()
?>
See also PHP RFC: Allow abstract function override.
1.2.112.2. Connex PHP features¶
1.2.112.2.1. Suggestions¶
Avoid inheriting abstract methods for compatibility beyond 7.2 (and older)
1.2.112.2.2. Specs¶
Short name |
Classes/CantInheritAbstractMethod |
Rulesets |
All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56, CompatibilityPHP70, CompatibilityPHP71 |
Exakat since |
0.11.8 |
PHP Version |
With PHP 7.2 and more recent |
Severity |
Critical |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |