You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use DI\Annotations\Inject;
class Class1 {
/**
* @Inject
* @var Class2
*/
private $class2;
}
Private property $class2 will be injected when Class1 is instantiated, i.e. even if not used. This can impact the performances. Lazy loading could be an optimization.
One solution could be to inject proxy instances instead of the dependency. The proxy can catch method and property calls using __get, __set, __call... When used, the proxy can then load the dependency, and forward the call.
The text was updated successfully, but these errors were encountered:
Given the simple example:
Private property
$class2
will be injected whenClass1
is instantiated, i.e. even if not used. This can impact the performances. Lazy loading could be an optimization.One solution could be to inject proxy instances instead of the dependency. The proxy can catch method and property calls using
__get
,__set
,__call
... When used, the proxy can then load the dependency, and forward the call.The text was updated successfully, but these errors were encountered: