简体   繁体   English

Go 到 VSCode 中 PHP 扩展的定义

[英]Go To Definition for PHP extensions in VSCode

When I use Composer 'Go To Definition' works well.当我使用 Composer 时,“转到定义”效果很好。 But it doesn't work for PHP core extensions like MySQLi. Ubuntu is my OS and I have searched for PHP files for those libraries and only find their.so files, maybe that's why I can't 'Go To Definition'.但它不适用于 PHP 核心扩展,如 MySQLi。Ubuntu 是我的操作系统,我已经为这些库搜索了 PHP 文件,但只找到了它们的 .so 文件,也许这就是我无法“转到定义”的原因。

Above are my vscode PHP definitions.以上是我的 vscode PHP 定义。 Don't know if that 'Sync: Ignored' is a problem, I didn't have path for PHP binary setted in settings.json but I tried to add it and it didn't make difference.不知道“同步:忽略”是否有问题,我没有在 settings.json 中设置 PHP 二进制文件的路径,但我尝试添加它但没有任何区别。

How solve this?这个怎么解决

我的 vscode PHP 定义

{
"editor.detectIndentation": false,
"C_Cpp.updateChannel": "Insiders",
"riot.base": "/home/fe/RIOT",
"riot.board": "esp8266-esp-12x",
"[lisp]": {
    "editor.tabSize": 2
},
"[html]": {
    "editor.tabSize": 2
},
"phpserver.browser": "firefox",
"typescript.disableAutomaticTypeAcquisition": true,
"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",
    "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",
    "mysqli"
],
"php.validate.executablePath": "/usr/bin/php"
}

You can't go to the definition of standard functions.你不能 go 来定义标准函数。 PHP doesn't offer such functionality. PHP 不提供此类功能。

Intelephense uses stubs from PHPStorm to specify the syntax and PHPDoc comments, but going to the definition of these files would be pointless. Intelephense 使用来自 PHPStorm 的存根来指定语法和 PHPDoc 注释,但是去定义这些文件是没有意义的。 Everything you need is shown to you in the popover.您需要的一切都会在弹出窗口中显示给您。 For this reason, going to the definition in the stub files is blocked.由于这个原因,进入存根文件中的定义被阻止。

PHP core extensions are compiled. PHP 内核扩展被编译。 PHP is an interpreted language but the executable is compiled C source code. PHP 是一种解释语言,但可执行文件是编译 C 源代码。 PHP core extensions are written in C, not in PHP. PHP 核心扩展是在 C 中编写的,而不是在 PHP 中。 There's no reason to go to the definition in C source code even if such functionality would be available in VS Code.没有理由将 go 定义为 C 源代码中的定义,即使此类功能在 VS Code 中可用。

Steps to Reproduce:重现步骤:

Install PHP Intellisense extension Open a folder with a php project in VS Code Ctrl + click on a method/function reference, then right click on it and select "Go to definition"安装 PHP Intellisense 扩展 在 VS Code 中打开包含 php 项目的文件夹 Ctrl + 单击方法/函数引用,然后右键单击它和 select “转到定义”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM