Consider this code here:
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);
Why bother with OOP visibility when you can get around it so easily with Closures or Reflections?
Is there a way of blocking this kind of thing that I am missing?
Aucun commentaire:
Enregistrer un commentaire