You could have a trait for read-only object like this:
  trait ReadOnly{  
      protected $readonly = false;
      public function setReadonly($value){ $this->readonly = (bool)$value; }
      public function getReadonly($value){ return $this->readonly; }
  }
You could detect if that trait is used and determine wheter or not you should write that object in a database, file, etc.