php - 在 PHP-CS-Fixer 中使用制表符缩进

标签 php php-cs-fixer

如何配置 PHP-CS-Fixer 以使用制表符进行缩进?

我可以看到 indentation_type 修复器

* indentation_type [@PSR2, @Symfony]
  | Code MUST use configured indentation type.

但是如何配置缩进类型呢?如果我尝试设置 'indentation_type' => 'tab',,我会收到错误

[indentation_type] Is not configurable.

最佳答案

它在文档中,但我是如何错过它的(可能是因为我正在搜索术语“制表符”而不是“缩进”)

对于寻找相同内容的其他人,PhpCsFixer\Config 中有一个setIndent 方法。

return PhpCsFixer\Config::create()
    ->setRules([
        '@PSR2' => true,
        'indentation_type' => true,
    ])
    ->setIndent("\t")
    ->setLineEnding("\n")
    ->setFinder($finder)

关于php - 在 PHP-CS-Fixer 中使用制表符缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42849484/

相关文章:

php - sql查询不选择值

laravel - 如何将 php-cs-fixer 与 vim 一起用于 laravel?

php - 如何将 PhpCsFixer 限制为暂存文件?

php - 如何在 VS Code 中将 PHP 代码花括号自动格式化为新行

php-cs-修复程序 : keep brace on the same line of function declaration

php - 如何通过图片查看属性?

php - PHP高效的分页查询方式

php - 使用implode方法插入的值在mysql中有很多逗号

php - 如何让 PHP 将我的其他页面正确打印到 iframe 中?

php - Symfony Finder 使用 glob 排除