--- SOLVE --- Code: parent::__construct($path, Config::JSON); foreach ($this->getAll(true) as $key) { if (property_exists($this, $key)) { $this->$key = $this->get($key); } } property_exists instead isset($this->$key) --- END SOLVE --- I have made class ArenaData extending Config. After editing I save it, it works.. After restart I recreate it and it resets to zero. Code Code: $config = 'world.json' (exam) world.json were { "level": "world"} $ad = new ArenaData(BuildBattle::getInstance()->getDataFolder() . $config); after new ArenaData {"level": null} I know why it happened, how to fix?:/ --- need to fix --- array_filter((array)$this, function ($k) : bool { return strpos($k, Config::class) === false; }, ARRAY_FILTER_USE_KEY) --- end need to fix --- class ArenaData extends Config { public $level; public function __construct (string $path) { parent::__construct($path, Config::JSON, array_filter((array)$this, function ($k) : bool { return strpos($k, Config::class) === false; }, ARRAY_FILTER_USE_KEY)); foreach ($this->getAll(true) as $key) { if (isset($this->$key)) $this->$key = $this->get($key); } } public function __set ($k, $v) { $this->$k = $v; $this->set($k, $v); } public function __get ($k) { return $this->get($k); } public function save () : bool { $this->setAll( array_filter((array)$this, function ($k) : bool { return strpos($k, Config::class) === false; }, ARRAY_FILTER_USE_KEY) ); return parent::save(); } }
And also I remove lines marked as ---need to fix---. It started working, but $ad->level not working. Only this: $ad->get("level")