Is it possible to block the visibility of functions from a parent class in sub classes?
class DB {
function connect() {
// connects to db
}
}
class OtherClass extends DB {
function readData() {
// reads data
}
}
class AnotherOtherClass extends OtherClass {
function updateUser($username) {
// add username
}
}
If I were to write:
$cls1= new OtherClass();
$cls1->connect(); // want to allow this class to show
$cls2= new AnotherOtherClass();
$cls2->connect(); // do not want this class to show
$cls2->readData(); // want to allow this class to show
Is this possible?
Sounds like you don’t actually want
AnotherOtherClassto extendOtherClass. Perhaps you want to consume / wrap / decorateOtherClassinstead, egYou could also do this but it smells bad