phpStorm reformat differs from phpcs (Zend CodeStyle)
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?
Please sign in to leave a comment.
According to https://framework.zend.com/manual/1.11/en/coding-standard.coding-style.html#coding-standard.coding-style.arrays PhpStorm formats the code right: each successive line must be padded with white space such that both the keys and the values are aligned.
The result of ./vendor/bin/phpcbf --standard=Zend looks wrong.