Open schmunk42 opened 11 years ago
We can run it through http://cs.sensiolabs.org
I just tried it on the outputted files, but it doesn't support re-indentation atm. So I think we'll have to fix the generator manually.
Tried with:
php-cs-fixer.phar fix . --fixers=linefeed,short_tag,indentation
php-cs-fixer.phar fix . --level=psr2
Fair enough, we'll do it manually.
A question regarding formatting that is not covered under PSR2:
The current code has a lot of this style of formatting: array('foo'=>'bar')
PhpStorm's default setting for Assignment Operators is to leave spaces around them: array('foo' => 'bar')
I'd like to use this default style in the generated code. What do you think about that?
A similar default style setting is to have a space after commas so that this: $foo = bar($a,$b); $arr = array(0 => "zero",1 => "one");
..becomes: $foo = bar($a, $b); $arr = array(0 => "zero", 1 => "one");
Should we also here use PhpStorm's default setting (the latter)?
I however vote for changing these default PhpStorm settings:
Function call arguments - From "Chop down if long" to "Do not wrap" New line after '(' - From checked to unchecked Place ')' on new line - From checked to unchecked
And the same for Array initializer
This is fine:
$foo = bar($a, $b);
$arr = array(0 => "zero", 1 => "one");
array('foo' => 'bar')
Could you give me some examples for the other cases?
Check out 39913128239f14a02473ef2ecfbda4a958a70d6b, 7f5a389a3d2c9e14909602e6cdf7e64be08f8a6b and 8ea9727d79536a9cacabda24bfcb173c2186f075
Could you give me some examples for the other cases?
Do you mean the code not formatted as per above, or are you referring to the "Do not wrap" settings?
Found this script: http://stackoverflow.com/a/494295/291573 (32 upvotes) and this one: http://pear.php.net/package/PHP_Beautifier (inactive)
Indentation fixer change tabs into spaces, it does not change level of indent. There are no fixer that change indentation inside array https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/770
Have you tried phpfmt/fmt ?
@ccirello No, not yet - but looks promising, thank you. I tried https://github.com/cmrcx/phptidy for https://github.com/schmunk42/yii2-giiant
Code indent, formatting, etc....