1.2.691. Mismatch Parameter Name

Parameter name change in overwritten method. This may lead to errors when using PHP 8.0 named arguments.

PHP use the name of the parameter in the method whose code is executed. When the name change between the method and the overwritten method, the consistency is broken.

Here is another example, in early PHP 8.0 (courtesy of Carnage).

<?php

class x {
    function getValue($name) {}
}

class y extends x {
    // consistent with the method above
    function getValue($name) {}
}

class z extends x {
    // inconsistent with the method above
    function getValue($label) {}
}

?>

1.2.691.1. Suggestions

  • Make sure all the names are the same, between methods

1.2.691.2. Specs

Short name

Functions/MismatchParameterName

Rulesets

All, Analyze, CE, Changed Behavior, CompatibilityPHP80

Exakat since

2.1.8

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

named-parameter

Available in

Entreprise Edition, Community Edition, Exakat Cloud