Рассмотрим этот код здесь:
final class TinkerWithMe {
protected $key1 = 19;
private $key2 = 88;
}
$class = new TinkerWithMe();
$getKeys = function() {
return array($this->key1, $this->key2);
};
$oldKeys = $getKeys->call($class);
$newKey1 = 96;
$newKey2 = 42;
$setKeys = function() use ($newKey1, $newKey2) {
$this->key1 = $newKey1;
$this->key2 = $newKey2;
};
$setKeys->call($class);
Зачем беспокоиться о видимости ООП, когда вы можете так легко обойти его с помощью Closures или Reflections?
Есть ли способ блокировать такие вещи, которые мне не хватает?