Have a look at the following code:
class A
{
private $var = 17;
public function accessOtherPrivate(A $a)
{
echo $a->var;
}
}
$a = new A();
$b = new A();
$b->accessOtherPrivate($a);
The code above works just fine, you can access private properties of different object – as long as you’re the same class. PHP manual confirms the behaviour:
Members declared as private may only be accessed by the class that defines the member.
Java has the same behaviour.