Just playing around and I found this.
Why the call by reference to $this->newAxis() does not throw an undefined property notice (xAxis property), while the var_dump() does?
public function newXAxis()
{
// var_dump(isset($this->xAxis)); // false
// var_dump($this->xAxis); // Throws the notice
return $this->newAxis($this->xAxis); // Should throw the notice?!
}
protected function newAxis(&$current)
{
// ...
}
Does it have something to do with the passing by reference, thus not accessing the property directly?
Yes, it happens because you pass it by reference. When you pass by value, an attempt is made to actually read the value of the variable – so a notice appears. When you pass by reference, the value does not need to be read.
When you do that, the variable/property is created if it does not exist yet.
From the manual: