【问题标题】:How can I make PHP CodeSniffer Fixer ignore the namespace declaration?如何让 PHP CodeSniffer Fixer 忽略命名空间声明?
【发布时间】:2012-10-07 13:03:47
【问题描述】:

我正在使用 PHP Coding Standards Fixer 的 sublime text 2 插件。它工作正常,除了它认为命名空间无效(它实际上是无效的,我可以接受)。此错误会阻止脚本更正文件的其余部分。我收到以下错误:

! The namespace Application\Controllers\Admin in <filepath> does not match the file path according to PSR-0 rules.

如何告诉脚本忽略命名空间约束。命令行参数和 Sublime text 2 用户设置都可以更改。

【问题讨论】:

    标签: php sublimetext2 codesniffer psr-0


    【解决方案1】:

    虽然丑陋,但一个简短的解决方案可能是添加如下内容:

    使用抑制注释标签:

    // @codingStandardsIgnoreStart
    
    /* your namespacing here */
    
    // @codingStandardsIgnoreEnd
    

    【讨论】:

      【解决方案2】:

      我正在使用以下命令排除 pso0 规则:

      php-cs-fixer fix --level="psr2" PATH --fixers=-psr0
      

      【讨论】:

      • 谢谢,对我帮助很大!
      猜你喜欢
      • 2011-05-01
      • 2015-05-01
      • 2011-12-05
      • 2015-02-18
      • 2018-02-11
      • 1970-01-01
      • 1970-01-01
      • 2011-02-06
      • 2012-10-29
      相关资源
      最近更新 更多