I've noticed that in PHP the following code works with no complaints:
class A {
public static function echoes($b) {
echo $b->protectedFunction();
}
}
class B extends A {
protected function protectedFunction() {
return "this is protected";
}
}
$b = new B();
A::echoes($b);
Example https://3v4l.org/JTpuQ
However I've tried this in C# and it does not work as the parent cannot access the child protected members.
My question is who's got the OOP principles right here? I've read through the LSP but it doesn't seem concerned with parent classes, so is it correct for a parent to access child protected members (like PHP assumes it is) or should it be restricted (like C# assumes it should be)?