LazyArrayObject

同时可以作为数组和对象访问的类

  1. // $object = new \Imi\Util\LazyArrayObject;
  2. $object = new \Imi\Util\LazyArrayObject([
  3. 'id' => 123,
  4. 'name' => 'imi',
  5. ]);
  6. $object['id'] = 111;
  7. echo 'id:', $object->id, PHP_EOL;
  8. $object->id = 222;
  9. echo 'id:', $object['id'], PHP_EOL;
  10. $arrayData = $object->toArray();
  11. var_dump($arrayData);