On Thu, Sep 3, 2020 at 10:40 AM David Rodrigues <david.pro...@gmail.com> wrote:
> Now I rethinked about what I said. Really, maybe clone is not the best > option. So maybe we can just use a method that will clone and will have > access to both informations. But I don't know if it solves the original > message. > > public function getUserCopy() { > $userCopy = clone $this; > $this->copies[] = $userCopy; > > return $userCopy; > } > > If your goal is to track copies, then a static makes much more sense. class AllKnowing { private static $copies = []; public function __construct(...) { self::$copies[] = $this; .... } public function __clone() { self::$copies[] = $this; } } -Sara