Is there a way to modify property visibility in a child class from protected
to public
? Consider the following code snippet:
class BaseFoo {
protected foo;
}
class Foo extends BaseFoo {
foo = 1;
}
new Foo().foo;
It seems that this change is possible from protected
to public
, but not in any other direction. In fact, changing the visibility accidentally to public
by omitting the modifier can be more harmful than attempting to change from protected
to private
(which is not allowed). What could explain this behavior? Is it a known issue?