Can someone please explain what it means to have a class instance within the argument of another class instance:
$controller = new controllerObject(new dependenciesObject());
I understand the basics of classes and class instances but have never seen code like the above before. What does it mean? The controllerObect is a class so what does it mean to pass it an object instance in the argument?
All this means is that the
controllerObjectconstructor accepts an object of typedependenciesObject.You instantiate a
dependenciesObjectand use it as an argument to instantiate acontrollerObject, which is assigned to$controller. If it helps you understand, this is equivalent to: