Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 777 Bytes

ImplementedParamTypeMismatch.md

File metadata and controls

35 lines (26 loc) · 777 Bytes

ImplementedParamTypeMismatch

Emitted when a class that inherits another, or implements an interface, has a docblock param type that's entirely different to the parent.

<?php

class D {
    /** @param string $a */
    public function foo($a): void {}
}

class E extends D {
    /** @param int $a */
    public function foo($a): void {}
}

How to fix

Make sure to respect the Liskov substitution principle – any method that overrides a parent method must accept all the same arguments as its parent method.

<?php

class D {
    /** @param string $a */
    public function foo($a): void {}
}

class E extends D {
    /** @param string|int $a */
    public function foo($a): void {}
}