Excuse the double-entendre-filled subject for this post
I read an interesting tidbit on the PHP site:
“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.”
<?php
class Foo {
private $bar;
public function __construct($value) {
$this->bar = $value;
}
public function getOtherBar($otherObject) {
return $otherObject->bar;
}
}
$a = new Foo('baz');
$b = new Foo('ban');
echo $a->getOtherBar($b);
?>
Am I wrong in thinking that the above code should (in theory/ a perfect world) cause an error? Or am I missing something fundemental with relation to OO?