<?php
class My {
private $fields = [
'hello' => 'world'
];
public function f() {
return $this;
}
public function __get($name) {
if($name == 'f') {
return (object) $this->fields;
}
}
public function __set($name, $value) {
$this->fields[$name] = $value;
}
public function printFields() {
print_r($this->fields);
}
}
$my = new My();
$my->f()->jetpack = 'azaza';
$my->printFields();