PHP would let calls to private methods as long as they come from instances of the same class.
This is how the PHP docs explains it:
Objects of the same type will have access to each others private and protected members even though they are not the same instances. This is because the implementation specific details are already known when inside those objects.
Doesn't this break encapsulation? How does the fact that implementation specific details are known
justify it?
p.s. Are there other (object oriented) languages that do this?
This is true for most languages, in java
you can do it too,
this is because the object is from the same instance, it "knows" all the properties same instances have
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With