<?php
class A {
public function foo($str) {
$this->foobar($str);
}
private function foobar(string $str) {
print "A";
if ($str !== "A") {
$this->foobar("A"); // does never call B::foobar, as foobar is private
}
}
}
class B extends A {
public function foobar(string $str) {
print "B";
parent::foo("B");
}
}
(new A)->foo("A");
print PHP_EOL . "---" . PHP_EOL;
(new B)->foo("B");
Catchable fatal error: Argument 1 passed to A::foobar() must be an instance of string, string given, called in /in/KrOtJ on line 5 and defined in /in/KrOtJ on line 8
Process exited with code 255.