Search code examples
phpvisual-studio-codeintelephense

Hide specific "undefined function XXX" in intelephense


Is there any way to prevent specific functions to show the "undefined function XXX" message? I have an old PHP project in docker and it's confusing seeing all the error messages refering to the same 2-3 functions: enter image description here

I have tried adding the specific php version ({"intelephense.environment.phpVersion": "5.6"}) to the settings.json file but it has no effect.

I also tried adding {"intelephense.diagnostics.undefinedFunctions": true} but that hides all the messages but that is not what I want.


Solution

  • The recommended approach is to create a stub file (e.g. phpstubs/mysql.php)

    <?php
    function mysql_escape_string($str){}
    

    Then add this folder (phpstubs) to this setting: Intelephense> Environment: Include Paths


    Another option is using the @disregard annotation.

    /** @disregard */
    $str2 = mysql_escape_string($str1);