What that error is saying is that $labels
is an empty object, so it can’t assign to it.
$foo = NULL;
$foo->labels = false; // This causes the error
See this Stack Overflow post for technical details: https://stackoverflow.com/questions/8900701/creating-default-object-from-empty-value-in-php