How can the return value of the "similar" method impact the functionality of the overdriven method in PHP?

When overloading a method in PHP, the return value of the "similar" method can impact the functionality if the return type of the overloaded method does not match the return type of the "similar" method. To solve this issue, ensure that the return type of the overloaded method matches the return type of the "similar" method.

class ParentClass {
    public function similar(): string {
        return "Similar method in ParentClass";
    }
}

class ChildClass extends ParentClass {
    public function similar(): string {
        return "Similar method in ChildClass";
    }
}

$child = new ChildClass();
echo $child->similar(); // Output: Similar method in ChildClass