Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I edit the intelephense.stubs preference? #10

Closed
devnix opened this issue Jan 9, 2020 · 13 comments
Closed

How can I edit the intelephense.stubs preference? #10

devnix opened this issue Jan 9, 2020 · 13 comments

Comments

@devnix
Copy link

devnix commented Jan 9, 2020

I see in bmewburn/vscode-intelephense#827 that I can modify a intelephense.stubs attribute to add gettext and avoid wrong errors, but I can't find a way of doing it on LSP.

@jfcherng
Copy link
Collaborator

jfcherng commented Jan 9, 2020

Use settings.

{
    "client" : {
        // ...
        // @see https://github.com/bmewburn/vscode-intelephense/blob/master/package.json
        "settings": {
            "stubs": [ /* ... */ ],
        },
    },
}

@devnix
Copy link
Author

devnix commented Jan 10, 2020

This doesn't seem to work. Same configuration works on VSCode:

{
	"client" : {
		"initializationOptions": {
			"storagePath": "${temp_dir}/intelephense",
			"globalStoragePath": "${temp_dir}/intelephense",
			"licenceKey": "...",
		}, 
		"settings": {
			"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",
				"gettext"
			]
		}
	}
}

@jfcherng
Copy link
Collaborator

jfcherng commented Jan 10, 2020

image

My test config (but it should work like yours 🤔 ) is as the following.

{
    "client" : {
        "enabled": true,
        "languages": [
            {
                "languageId": "php",
                "scopes": ["source.php", "embedding.php"],
            },
        ],
        "initializationOptions": {
            "clearCache": false,
            "storagePath": "E:/_Data/intelephense",
            "globalStoragePath": "E:/_Data/intelephense",
            // To use the licenceKey,
            // you can also write it to "YOUR_HOME_DIR/intelephense/licence.txt"
            // and comment out the following property
            "licenceKey": "${packages}/User/intelephense.sublime-license",
        },
        // @see https://github.com/bmewburn/vscode-intelephense/blob/master/package.json
        "settings": {
            "diagnostics": {
                "undefinedSymbols": true,
            },
            "debug": {
                "enable": false,
            },
            "files": {
                "exclude": [
                    "**/branch-*/**",
                ],
            },
            "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",
                "gettext",
            ],
        },
    },
}

Some possible reasons:

  • Restart ST to let LSP use the new config in case you didn't.
  • Outdated intelephense (Bump intelephense from 1.3.4 to 1.3.7 #9). (I always manually update to the latest version.)
  • intelephense just seems to not loading cache/stubs. (This sometimes happens on my side. I don't know why.)

@devnix
Copy link
Author

devnix commented Jan 10, 2020

Your configuration is in LSP.sublime-settings or in LSP-intelephense.sublime-settings? I've restarted Sublime and upgraded Intelephense too.

Right now I've got this, it's pretty hilarious 😄
image

@jfcherng
Copy link
Collaborator

jfcherng commented Jan 10, 2020

Your configuration is in LSP.sublime-settings or in LSP-intelephense.sublime-settings?

LSP-intelephense.sublime-settings but it shouldn't matter since they share the same structure.

@devnix
Copy link
Author

devnix commented Jan 10, 2020

That's where it is configured. Wow, seems like I had configured too php-ls but it wans't triggering until now (I have no idea why).

Anyway, glad you helped me where to find where to configure the stubs section. Thank you so much!

@devnix
Copy link
Author

devnix commented Jun 16, 2020

Did stubs stopped working? A few months ago, the gettext issue came again, and I just can't resolve it. I've even deleted all the stubs and, for example, the mysqli functions/constants are not marked as undefined, which is pretty strange...

@jfcherng
Copy link
Collaborator

jfcherng commented Jun 16, 2020

Did stubs stopped working? A few months ago, the gettext issue came again, and I just can't resolve it. I've even deleted all the stubs and, for example, the mysqli functions/constants are not marked as undefined, which is pretty strange...

{
    // @see configuration in https://github.com/bmewburn/vscode-intelephense/blob/master/package.json
    "settings": {
        "intelephense": {
            "stubs": [
                // ...
            ],
        },
    },
}

@devnix
Copy link
Author

devnix commented Jun 16, 2020

Ok, now it seems like it requires a new key called intelephense inside the settings object, but this was different before, right?

Old example
{
    "client" : {
        "initializationOptions": {
            "storagePath": "${temp_dir}/intelephense",
            "globalStoragePath": "${temp_dir}/intelephense",
            "licenceKey": "...",
        }, 
        "settings": {
            "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",
                "gettext"
            ]
        }
    }
}
New example
{
    "client" : {
        "initializationOptions": {
            "storagePath": "${temp_dir}/intelephense",
            "globalStoragePath": "${temp_dir}/intelephense",
            "licenceKey": "...",
        }, 
        "settings": {
            "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",
                    "gettext"
                ]
            }
        }
    }
}

@devnix devnix closed this as completed Jun 16, 2020
@jfcherng
Copy link
Collaborator

There is no client anymore.

@devnix
Copy link
Author

devnix commented Jun 16, 2020

Where does initializationOptions go then? It's frustrating not having any documentation available

@jfcherng
Copy link
Collaborator

jfcherng commented Jun 16, 2020

Are you using LSP-intelephense? If yes, I am pretty sure you should be able to deduce it yourself when you see default settings, which is opened automatically on the left-hand side...

image

@rchl
Copy link
Member

rchl commented Jun 16, 2020

(btw. no need for enabled: true there)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants