Ignoring / suppressing Intelephense errors in VSCode

Quick tip for the VSCode PHP people out there.

Ever had an unsightly red line appear under your code telling you there’s an error that you know is a false positive?

Screenshot of an Intelephense error in the VSCode IDE

Happily VSCode’s Intelephense extension has an undocumented feature called @disregard that can be used to supress these “errors”. Taking the form of an annotation, the template is /** @disregard [OPTIONAL_CODE] [OPTIONAL_DESCRIPTION] */.

The annotation must go before the full block that contains the issue. So if you have an array (as pictured), it goes above the array, if you have an if block it goes above that and so on.

Here’s our suppressed error:

While the code and description part of the annotation are optional, including them makes our code easier to understand and our error suppression more precise (we don’t want to accidentally suppress a legit error in a code block).

Get in Touch

Get in touch with us today 01202 790300

monday 09:00 - 17:00
tuesday 09:00 - 17:00
wednesday 09:00 - 17:00
thursday 09:00 - 17:00
friday 09:00 - 16:00
saturday Closed
sunday Closed