Skip to content

Files

Latest commit

 

History

History
41 lines (30 loc) · 905 Bytes

Generic.CodeAnalysis.UselessOverridingMethod.md

File metadata and controls

41 lines (30 loc) · 905 Bytes

Pattern: Unnecessary overriding method

Issue: -

Description

Detects unnecessary overridden methods that simply call their parent. These methods are not required.

Example

Example of incorrect code:

class SomeClass extends SomeParentClass {
  public function __construct($a, $b) {
    parent::__construct($a, $b);
  }
  
  public function init() {
    $this->connect_to_DB();
    $this->set_emulate_state();
    $this->start_profiler();
  }  
}

Example of correct code:

class SomeClass extends SomeParentClass {
  public function init() {
    $this->connect_to_DB();
    $this->set_emulate_state();
    $this->start_profiler();
  }
}

Further Reading