Symplify: [CS] Do not call parent, if it's empty - PHPStan rule

Created on 18 Sep 2020  路  7Comments  路  Source: symplify/symplify

final class SomeTest exteds TestCase
{
     protected function setUp()
     { 
          parent::setUp();
     }
}

:no_entry:

All 7 comments

I made the original issue with intent to create check for case, when parent call is empty method.

Something like this:

class SomeClass
{
    public function emptyMethod()
    {
    }
}

class ChildSomeClass extends SomeClass
{
    public function emptyMethod()
    {
         // this has no added value, since parent method is empty 
-        parent::emptyMethod(); // this method must be checked, it's empty

         // some code, whatever
         $value = 5;
    }
}

Ok, I will try.

Thank you

I'm just going to :bed: in my timezone :)

Feel free to create multiple phpstan rules in separated PRs, I'll check it tomorrow and merge them.

Thank you for your work :+1:

Could you give me hint how to get class->extends statements ?

The is a $scope with class/function reflections in it

Thank you, btw, I sent you an email ;)

Was this page helpful?
0 / 5 - 0 ratings