1.2.681. Method Signature Must Be Compatible

Make sure methods signature are compatible.

PHP generates the infamous Fatal error at execution : Declaration of FooParent\:\:Bar() must be compatible with FooChildren\:\:Bar()

<?php

class x {
    function xa() {}
}

class xxx extends xx {
    function xa($a) {}
}

?>

1.2.681.1. Suggestions

  • Fix the child class method() signature.

  • Fix the parent class method() signature, after checking that it won’t affect the other children.

1.2.681.2. Specs

Short name

Classes/MethodSignatureMustBeCompatible

Rulesets

All, Analyze, Changed Behavior, LintButWontExec

Exakat since

1.2.9

PHP Version

All

Severity

Critical

Time To Fix

Quick (30 mins)

Precision

High

Features

typehint, type-covariance, type-contravariance

Note

This issue may lint but will not run

Available in

Entreprise Edition, Exakat Cloud