/**
* Magic getter for the user object. Returns the injected
* one if any, or the current one if none.
*
* Using a magic getter to preserve B/C when we stopped storing the user object upon construction of the menu object.
* As the user property is not initialized anymore, this getter ensures any class extending
* this one can still use $instance->user and get a proper value.
*
* @param string $propName Name of the missing or protected property.
*
* @return User|null
*
* @since 3.9.26
*/
public function __get($propName)
{
if ($propName === 'user') {
return empty($this->storedUser) ? Factory::getUser() : $this->storedUser;
}
return null;
}