-
Notifications
You must be signed in to change notification settings - Fork 4
Code Diagnostics
Magento Toolbox ships a diagnostics engine that surfaces common Magento XML mistakes inline. Each rule can be toggled independently under Settings -> Extensions -> Magento Toolbox -> Diagnostics.
All diagnostics are re-evaluated on file open, file save, and in-editor changes.
In layout/*.xml and page_layout/*.xml files:
- Unknown
<referenceBlock name="...">or<referenceContainer name="...">— the referenced block or container does not exist in the current area or base. - Unknown
<move element="...">— no block or container matches. - Unknown
<move destination="...">— no block or container matches. - Unknown
<update handle="...">— no layout file with that handle exists in the current area.
Both <referenceBlock> and <referenceContainer> are permissive: either kind is accepted as a target because Magento's runtime does not enforce the distinction.
Setting: magento-toolbox.provideLayoutDefinitions (covers layout-specific rules via the diagnostics framework).
-
Invalid DI type — classes referenced in
di.xml(type,preference for,preference type, arguments withxsi:type="object") that don't resolve via PSR-4. -
Invalid virtual type source — virtual types whose
typeattribute points at a non-existent class. -
Preference declaration — duplicate or malformed
<preference>entries. -
Plugin declaration — duplicate or disabled plugins inside
<type>. -
Plugin attribute type — incorrect attribute values on
<plugin>nodes (e.g. non-booleandisabled, non-numericsortOrder).
Settings: magento-toolbox.diagnostics.invalidDiType, .invalidVirtualTypeSource, .preferenceDeclaration, .pluginDeclaration, .pluginAttrType.
-
Observer declaration — duplicate or disabled observers inside
events.xml.
Setting: magento-toolbox.diagnostics.observerDeclaration.
-
Module declaration —
etc/module.xmldeclares a name that doesn't match its folder structure (app/code/Vendor/Module). -
Module scope — a config file sits under
etc/<area>/where<area>is not a recognized Magento area.
Settings: magento-toolbox.diagnostics.moduleDeclaration, .moduleScope.
- Missing or invalid
id/titleattributes on<resource>nodes inacl.xml.
Setting: magento-toolbox.diagnostics.aclResource.
- Broken service class or method references inside
webapi.xml.
Setting: magento-toolbox.diagnostics.webApiService.
- Warns when a block in a
default.xmllayout setscacheable="false", which disables full-page cache for every page. Usually a bug.
Setting: magento-toolbox.diagnostics.cacheableFalseInDefaultLayout.
Some diagnostics offer a Quick Fix (lightbulb / Ctrl+.):
-
Fix module name — update
etc/module.xmlso the name matches its folder path. -
Make plugin method public — bumps the targeted method's visibility to
public(interceptors cannot wrap non-public methods). -
Remove
cacheable="false"— strips the attribute from the offending block indefault.xml.
Developed and maintained by Magebit
