Closed
Description
Rule
Proxies and interceptors MUST never be explicitly requested in constructors.
Source - Magento Technical Guidelines
Description
Proxies are used for lazy-loading. Details on DevDocs.
Proxies should be configured via di.xml
file.
<type name="FastLoading">
<arguments>
<argument name="slowLoading" xsi:type="object">SlowLoading\Proxy</argument>
</arguments>
</type>
Plugins (interceptors) modify the behavior of public class functions by intercepting a function call and running code before, after, or around that function call. Details on DevDocs.
Plugins should be declared via di.xml
file.
<config>
<type name="{ObservedType}">
<plugin name="{pluginName}" type="{PluginClassName}" sortOrder="1" disabled="false" />
</type>
</config>
Implementation
Subscribe to the T_CLASS
token and analyse __constructor
arguments.
<severity>8</severity>
<type>warning</type>