Hi, i have 2 classes A and B that extends A. A has a public property and i want that on the instances of B that property can't be accessible. I try to explain better:
class A
{
public $prop;
}
class B extends A
{
...
}
$instance=new B;
$instance->prop; //This must throw an error like "Undefined property prop"
I tried with the final
keyword but it's only available for methods not for properties. I tried also by setting the same property as private
on B but PHP does not allow to change the access level from public to private or protected.
Maybe there's a simple solution to this problem but i can't find it so do you know a way to do this?