Skip to content

Code Diagnostics

raideer edited this page Apr 19, 2026 · 1 revision

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.

Layout diagnostics

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).

DI diagnostics

  • Invalid DI type — classes referenced in di.xml (type, preference for, preference type, arguments with xsi:type="object") that don't resolve via PSR-4.
  • Invalid virtual type source — virtual types whose type attribute 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-boolean disabled, non-numeric sortOrder).

Settings: magento-toolbox.diagnostics.invalidDiType, .invalidVirtualTypeSource, .preferenceDeclaration, .pluginDeclaration, .pluginAttrType.

Event & observer diagnostics

  • Observer declaration — duplicate or disabled observers inside events.xml.

Setting: magento-toolbox.diagnostics.observerDeclaration.

Module diagnostics

  • Module declarationetc/module.xml declares 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.

ACL diagnostics

  • Missing or invalid id / title attributes on <resource> nodes in acl.xml.

Setting: magento-toolbox.diagnostics.aclResource.

Web API diagnostics

  • Broken service class or method references inside webapi.xml.

Setting: magento-toolbox.diagnostics.webApiService.

Cacheable-false-in-default-layout

  • Warns when a block in a default.xml layout sets cacheable="false", which disables full-page cache for every page. Usually a bug.

Setting: magento-toolbox.diagnostics.cacheableFalseInDefaultLayout.

Quick fixes

Some diagnostics offer a Quick Fix (lightbulb / Ctrl+.):

  • Fix module name — update etc/module.xml so 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 in default.xml.

Clone this wiki locally