Override Inspections? (change how Undefined Methods inspection works)

Hi, I want to avoid the inspection "Undefined Method" in Phpstorm marking some methods as undefined (they are magic methods in PHP and I cannot add the PHPDocs to the original files).

Is there any easy or correct way to do this?


Could you please provide an example? Is this from a known framework? Probably there's a solution out there already.

Anyway, you can:

1) enable "Downgrade severity if __magic ..." checkbox in File | Settings | Editor | Inspections > PHP | Undefined | Undefined method

2) disable inspection completely there


Hi Dmitry, Framework is Magento (and I'm the creator of Magicento), it depends a lot on magic methods from __call, the method names are mainly extracted from the database.

I don't want to disable the inspection, is useful, I just wan to make it work correctly with Magento.

I'm not sure what does the checkbox "Downgrade severity if __magic" but I'm pretty sure won't be able to guess if it's a correct method or not in Magento.

Magicento can already help with the autocomplete for all these magic methods, it reads them from the database, but PhpStorm stills showing that as an undefined method, I just need a way to avoid that for the methods which are actually correct.

I was thinking in creating a new inspection, extending the original from PhpStorm, and overriding it properly, but it's a bit difficult because it just return the buildVisitor and the code is not open source, so I'm not sure how to proceed, any ideas?


As far as I can see there's no workaround for this, see https://youtrack.jetbrains.com/issue/WI-22884. As for "I'm not sure how to proceed, any ideas?" - I'll check this with a team



Inspections are not designed to be extended. The way to go is to implement an external resolve for a method reference thus the inspection won't consider it undefined. At the moment there's no proper way to do it. I've filed a corresponding issue (https://youtrack.jetbrains.com/v2/issue/WI-38698) so feel free to share your thought there. We'll discuss it internally and then document how it can be done.


Please sign in to leave a comment.