Is there a way in PHP the class definition to have a property set to a STD object with set properties?
I was thinking you can type cast but its not allowed for properties in the class definition.
//example.
class Foo{
private static $Obj = (object) ['bizz', 'bazz'];
}
which will trigger this error:
Parse error: syntax error, unexpected '(object)' (object) (T_OBJECT_CAST)
You cannot assign non-constant values to class properties during declaration. From http://php.net/language.oop5.properties
You will need to use a class method to initialise the property, eg