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

Closed
leofeyer opened this issue Jul 10, 2019 · 1 comment
Closed

SenselessMethodDuplicationInspector false positive #1363

leofeyer opened this issue Jul 10, 2019 · 1 comment

Comments

@leofeyer
Copy link

leofeyer 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.

@kalessil kalessil self-assigned this Aug 5, 2019
@kalessil kalessil added this to the C-3.0.15 milestone Aug 5, 2019
kalessil added a commit that referenced this issue Aug 5, 2019
@kalessil kalessil added the fixed label Aug 5, 2019
@kalessil
Copy link
Owner

kalessil commented Aug 5, 2019

Fixed!

@kalessil kalessil closed this as completed Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants