我已经使用phpfmt
扩展名来缩进这样格式化代码的代码
'cms' => [
'class' => 'yii2mod\cms\Module',
'controllerNamespace' => 'backend\controllers',
'defaultRoute' => 'cms',
],
当我合并它时,返回代码意图错误。我需要像PhpStorm那样格式化的代码
'cms' => [
'class' => 'yii2mod\cms\Module',
'controllerNamespace' => 'backend\controllers',
'defaultRoute' => 'cms',
],
哪个扩展以及如何在Visual Studio Code中使用它来摆脱Visual Studio Code中的PHP预期错误?
答案 0 :(得分:1)
您可以使用以下用于我的开发环境的设置,这些设置将最接近您要寻找的设置。
在VSCode中将以下内容添加到您的settings.json
中。
//phpfmt
"phpfmt.php_bin": "php",
"phpfmt.passes": [
"AlignPHPCode",
"AlignTypeHint",
"AddMissingParentheses",
"ConvertOpenTagWithEcho",
"DocBlockToComment",
"IndentTernaryConditions",
"JoinToImplode",
"PSR2KeywordsLowerCase",
"PSR2LnAfterNamespace",
"PSR2CurlyOpenNextLine",
"PSR2ModifierVisibilityStaticOrder",
"PSR2SingleEmptyLineAndStripClosingTag",
"ReindentSwitchBlocks",
"RemoveUseLeadingSlash",
"StripExtraCommaInArray",
"SpaceBetweenMethods",
],
"phpfmt.exclude": [
"ReindentComments",
"StripNewlineWithinClassBody"
],
"phpfmt.psr2": false,
答案 1 :(得分:0)