sublimelsp / LSP-intelephense

PHP support for Sublime's LSP plugin provided through intelephense.
MIT License
96 stars 3 forks source link

Core stubs not deep merged when also filled in user settings #73

Closed davidwebca closed 2 years ago

davidwebca commented 2 years ago

When filling settings.intelephense.stubs to add custom stubs like "wordpress", the setting is completely overriden instead of deep merged which makes intelephense complain about core PHP functions among others.

This is the extension settings

{
    "languages": [
        {
            "languageId": "php",
            // ST3 configuration
            "scopes": [
                "source.php"
            ],
            "syntaxes": [
                "Packages/PHP/PHP.sublime-syntax",
            ],
            // ST4 configuration
            "document_selector": "embedding.php",
            "feature_selector": "source.php",
        },
    ],
    "schemes": ["file", "buffer"],
    "auto_complete_selector": "punctuation.accessor | punctuation.definition.variable | punctuation.separator.namespace | punctuation.definition.tag.begin",
    "initializationOptions": {
        "clearCache": false,
        // "storagePath": "${temp_dir}/intelephense",
        // "globalStoragePath": "${home}/.intelephense",

        // if you want to use a premium license, you can either paste the key directly
        // or paste it into a file and provide its absolute path here
        // "licenceKey": "${packages}/User/intelephense-license.txt",
    },
    // @see configuration in https://github.com/bmewburn/vscode-intelephense/blob/master/package.json
    "settings": {
        // There are quite a lot of settings for intelephense...
        // For a full list, you can check the link above or just use LSP-json for autocompletion.
        "intelephense.environment.phpVersion": "8.1.0", // temporary fix for intelephense v1.8.0
    },
}

And here is the user settings

// Settings in here override those in "LSP-json/LSP-json.sublime-settings"
{
    "languages": [
        {
            "languageId": "php",
            // ST3 configuration
            "scopes": ["source.php","source.blade"],
            "syntaxes": [
                "Packages/PHP/PHP.sublime-syntax",
                "Packages/Laravel Blade Highlighter/blade.sublime-syntax"
            ],
            // ST4 configuration
            "document_selector": ["embedding.php", "embedding.blade"],
            "feature_selector": ["source.php", "source.blade"]
        },
    ],
    "auto_complete_selector": "punctuation.accessor | punctuation.definition.variable | punctuation.separator.namespace | punctuation.definition.tag.begin",
    "initializationOptions": {
        "clearCache": false,
    //     // "storagePath": "${temp_dir}/intelephense",
    //     // "globalStoragePath": "${home}/.intelephense",

    //     // if you want to use a premium license, you can either paste the key directly
    //     // or paste it into a file and provide its absolute path here
    //     // "licenceKey": "${packages}/User/intelephense-license.txt",
    },
    // @see configuration in https://github.com/bmewburn/vscode-intelephense/blob/master/package.json
    "settings": {
        // There are quite a lot of settings for intelephense...
        // For a full list, you can check the link above or just use LSP-json for autocompletion.
        "intelephense.stubs": [
            "wordpress"
        ]
    },
}

To fix it, I had to re-add the default stubs from the vscode definition

"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"

jfcherng commented 2 years ago

that's how it's designed in intelephense. https://github.com/bmewburn/vscode-intelephense/issues/1856