False positive: PHP S1185 Overriding methods should do more than

Inspection S1185 for PHP (Overriding methods should do more than simply call the same method in super class) generates false positive when the derived child only adds default values to parameters in the signature.

Example:

class A
{
    public function __construct(int $value, string $period)
    {
        // init..
    }
}

class DefaultA extends A
{
    public function __construct(int $value = 0, string $period = '')
    {
        parent::__construct($value, $period);
    }
}

PHPStorm SonarLint plugin version: 4.0.2.3009

Indeed, that’s a false positive.
I created SONARPHP-930 to track this issue.
Thanks a lot for the feedback and the concise example!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.