<?php class P { private int $someProp = 0; public function setProp(int $value): void { $this->someProp = $value; } } class C extends P { private array $cache = []; private int $someOtherProp; public function __construct(int $value) { $this->someOtherProp = $value; } public function fillCache(): void { $this->cache[] = 'value'; } public function __serialize(): array { return [ 'someOtherProp' => $this->someOtherProp ]; } public function __unserialize(array $data): void { $this->someOtherProp = $data['someOtherProp']; $this->cache = []; } } $c = new C(7); $c->setProp(5); $c->fillCache(); var_dump($c); var_dump($s = serialize($c)); var_dump(unserialize($s));
You have javascript disabled. You will not be able to edit any code.