Jim*_*mmy 10 visual-studio-code vscode-settings
我正在使用Visual Studio Code在PHP中进行开发,而我在使用Code提供正确的智能感知结果时遇到了一些麻烦.例如,这个新创建的Codeception单元测试:
<?php
class MyTest extends \Codeception\Test\Unit
{
/**
* @var \UnitTester
*/
protected $tester;
protected function _before()
{
}
protected function _after()
{
}
// tests
public function testSomeFeature()
{
$this->assertFalse(false);
}
}
Run Code Online (Sandbox Code Playgroud)
当我型$this->
我期望看到的assertFalse
,assertTrue
以及所提供的所有其他方法\Codeception\Test\Unit
.但我得到的基本上是当前文件中存在的任何项目,就是这样.
我该怎么做才能让Unit
课堂上的所有方法出现?我已经安装了PHP IntelliSense扩展,v2.3.4.
Álv*_*lez 18
Visual Studio Code核心不包括高级PHP功能,只需安装语法高亮,简单的代码完成和PHP二进制文件提供的代码linting.简而言之,您可以使用这些指令配置的功能:
// Controls whether the built-in PHP language suggestions are enabled. The support suggests PHP globals and variables.
"php.suggest.basic": true,
// Enable/disable built-in PHP validation.
"php.validate.enable": true,
// Points to the PHP executable.
"php.validate.executablePath": null,
// Whether the linter is run on save or on type.
"php.validate.run": "onSave"
Run Code Online (Sandbox Code Playgroud)
您还需要安装第三方扩展程序.
我个人的选择是PHP Intelephense.特别是,它支持docblock注释,包括魔术属性:
/**
* @property string $foo
*/
class Bar
{
}
Run Code Online (Sandbox Code Playgroud)
...和内联类型:
/** @var \Database $db */
$db->connect();
Run Code Online (Sandbox Code Playgroud)
不幸的是,这个扩展目前没有得到积极维护,但在撰写本文时,它仍然非常实用.
归档时间: |
|
查看次数: |
10563 次 |
最近记录: |