75142913在线留言
macOS上VScode 扩展的PHP Intellisense不支持php8.x+的处理办法_PHP技术_网络人

macOS上VScode 扩展的PHP Intellisense不支持php8.x+的处理办法

Kwok 发表于:2022-03-28 09:28:34 点击:28 评论: 0

我使用的brew install php 命令直接安装的macOS版的PHP,默认为最新版本8.1+,导致了我的PHP Intellisense一直报错:

ErrorException: Method ReflectionParameter::getClass() is deprecated in /Users/honghuguo/.vscode/extensions/felixfbecker.php-intellisense-2.3.14/vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php:241
Stack trace:
#0 /Users/honghuguo/.vscode/extensions/felixfbecker.php-intellisense-2.3.14/vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php(241): {closure}(8192, 'Method Reflecti...', '/Users/Kwok...', 241)

brew 又叫Homebrew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件, 只需要一个命令, 非常方便 brew类似ubuntu系统下的apt-get的功能。

在PHP8.0+里getClass已经deprecated。要解决这个问题目前只能切换到支持getClass的版本,为了体验php的新特性,所以我还是决定降级到php7.4版本。

使用下面的命令先卸载现在的php版本:

brew uninstall php

然后重新安装PHP 7.4:

brew install php@7.4

然后更新PHP Intellisense扩展的配置:

"php.executablePath": "/opt/homebrew/Cellar/php@7.4/7.4.27/bin/php",
"php.validate.executablePath": "/opt/homebrew/Cellar/php@7.4/7.4.27/bin/php",

上面的路径请根据自己电脑实际路径配置即可。

除非注明,网络人的文章均为原创,转载请以链接形式标明本文地址:https://www.55mx.com/post/200
0
感谢打赏!

《macOS上VScode 扩展的PHP Intellisense不支持php8.x+的处理办法》的网友评论(0)

本站推荐阅读

热门点击文章