1

我已将我的 PhpStorm 配置为使用 Zend for Code Style

风暴 | 偏好 | 编辑 | 代码风格 | PHP | 从 Zend 设置

PhpStorm 重新格式化的结果如下所示:

    <?php

return [
    'url_images'                 => '/img',
    'url_images_email'           => 'http://website.mine.amazonaws.com/img/mail',
    'url_images_profile'         => '//test.http://website.mine',
    'url_images_editorial_team'  => '//http://website.mine/images/tips1',
    'url_images_profile_product' => '//http://website.mine/images/tips1',
    'url_images_cms'             => 'https://http://website.mine/wp-content/uploads',
]; 

对于我现有的代码库,有数百个文件,我想重新格式化代码以也遵循 Zend 代码风格,所以我正在运行

./vendor/bin/phpcbf --standard=Zend config/autoload/image.development.php 

运行此命令的结果如下所示:

    <?php

return [
    'url_images' => '/img',
    'url_images_email'  => 'http://website.mine.amazonaws.com/img/mail',
    'url_images_profile' => '//test.http://website.mine',
    'url_images_editorial_team' => '//http://website.mine/images/tips1',
    'url_images_profile_product' => '//http://website.mine/images/tips1',
    'url_images_cms'   => 'https://http://website.mine/wp-content/uploads',
]; 

所以等号后的对齐方式明显不同。

现在我知道使用 phpcs.xml 配置 phpcs 有很多选项,但是我尝试过的选项并没有带来任何改进......

这是我现有的phpcs.xml文件(以防万一):

<ruleset name="Zend Framework Coding Standard">
  <description>Zend Framework Coding Standard</description>

  <!-- display progress -->
  <arg value="p"/>
  <arg name="colors"/>

  <!-- inherit rules from: -->
  <rule ref="PSR2"/>
  <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
  <rule ref="Generic.Formatting.SpaceAfterNot"/>
  <rule ref="Squiz.WhiteSpace.OperatorSpacing">
    <properties>
      <property name="ignoreNewlines" value="true"/>
    </properties>
  </rule>
  <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
    <properties>
      <property name="ignoreBlankLines" value="false"/>
    </properties>
  </rule>

  <file>config</file>

</ruleset>

我的问题是:如何让 phpcs/phpcbf 与 PhpStorm 上 Zend 的默认设置完全一样?

4

0 回答 0