When a function has a class as an argument you can use this class without initiating it. Can someone explain how this class is initiated as a function argument? See code below for clarification.
/**
*
* @param PseudoClass $class
* @return void
*/
public function pseudoFunction(PseudoClass $class)
{
// access PseudoClass instance from function argument
$class->exampleFunction();
// instead of manually creating a new instance of the PseudoClass
new PseudoClass();
$class->exampleFunction();
}
The code shows only the methods logic. In real life, you still need to instantiate the class you use before using it as the function's parameter.
Some frameworks use automatic injections, but they are still instantiated, however, under the hood.