Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SenselessMethodDuplicationInspector false positive #1363

Open
leofeyer opened this issue Jul 10, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@leofeyer
Copy link

commented Jul 10, 2019

Subject Details
Plugin Php Inspections (EA Extended) v3.0.14
Language level PHP 7.1
class A
{
    private $foo = 'foo';

    public function get(): string
    {
        return $this->foo;
    }
}

class B extends A
{
    private $foo = 'bar';

    public function get(): string
    {
        return $this->foo;
    }
}

$b = new B();
echo $b->get(); // bar

In this example, the SenselessMethodDuplicationInspector tells me that the B::get() method can be dropped as it is identical to the parent one. However, if I drop the method, it will return A::$foo instead of B::$foo:

class A
{
    private $foo = 'foo';

    public function get(): string
    {
        return $this->foo;
    }
}

class B extends A
{
    private $foo = 'bar';
}

$b = new B();
echo $b->get(); // foo

So the method should not be dropped, even if it is identical to the parent one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.