Monday, 2 November 2020

Intelephense stub won't load in CakePHP 2

I have some helper functions that I use everywhere in a CakePHP 2 application. They are underlined with red and reported as 'undefined functions' in the console. I know I can just ignore the errors, but I would like to have it working properly going forward, especially if I can manage to get alt-click working with it for models.

In my VS Code settings.json, I have the following:

"intelephense.stubs": [
        "apache", "bcmath", "bz2", "calendar", "com_dotnet", "Core", "ctype", "curl", "date", "dba", "dom", "enchant", "exif", "FFI", "fileinfo", "filter", "fpm", "ftp", "gd", "gettext", "gmp", "hash", "iconv", "imap", "intl", "json", "ldap", "libxml", "mbstring", "meta", "mysqli", "oci8", "odbc", "openssl", "pcntl", "pcre", "PDO", "pdo_ibm", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "pgsql", "Phar", "posix", "pspell", "readline", "Reflection", "session", "shmop", "SimpleXML", "snmp", "soap", "sockets", "sodium", "SPL", "sqlite3", "standard", "superglobals", "sysvmsg", "sysvsem", "sysvshm", "tidy", "tokenizer", "xml", "xmlreader", "xmlrpc", "xmlwriter", "xsl", "Zend OPcache", "zip", "zlib", "wordpress",
        "./Config/core.php"
    ],

It's my understanding that it is allowed to import custom .php files as stubs so that Intelephense recognizes them. However, no path that I enter will work. I have tried everything I can think of:

  1. C:/wamp64/www/MY_APP/app/
  2. ../App/Config
  3. simply not adding .php, simply not adding the file at all
  4. So many more!

How can I get Intelephense to recognize core.php, which essentially just holds a bunch of settings and some helper functions defined as, for example:

// just an alias for json decode
function jdec($json) {
    return json_decode($json, 1, 512, JSON_INVALID_UTF8_IGNORE);
}

Note: I am sure my difficulty with Intelephense is not strictly related to the CakePHP 2 framework.



from Intelephense stub won't load in CakePHP 2

No comments:

Post a Comment