1

I have configured my PhpStorm to use Zend for Code Style

PhpStorm | Preferences | Editor | Code Style | PHP | Set from Zend

The result for PhpStorm reformat looks like this:

    <?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',
]; 

For my existing codebase, with hundreds of files, I want to reformat the code to also follow Zend code style, so I am running

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

The result of running this command looks like this:

    <?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',
]; 

So the alignment after the equal sign is obviously different.

Now I know there are many options to configure phpcs using phpcs.xml, but the ones I have have tried, did not bring any improvements...

Here is my existing phpcs.xml file (in case it is needed):

<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>

My question is: How do I get the phpcs/phpcbf exactly to be like the default setting for Zend on PhpStorm?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Confidence
  • 2,283
  • 3
  • 33
  • 57
  • 1
    FYI (just in case): the alignment of array keys/values in PhpStorm is controlled by this option (2018.1 version): `Settings/Preferences | Editor | Code Style | PHP | Wrapping and Braces --> Array initializer | Align key-value pairs`. Maybe the name of such option will give you a hint of how it called in phpcs... – LazyOne Apr 25 '18 at 14:10
  • thanks @LazyOne yes I am aware of that :-) but googling that with phpcs brought nothing of importance. – Confidence Apr 25 '18 at 14:11

0 Answers0