PhpStorm常用的一些配置
一. 数据键值对齐
Settings (Preferences on Mac) | Editor | Code Style | PHP | Other | Array declaration style -> Align key-value pairs (勾选)
效果:
原数组:
$array = [
'foo'=>'123',
'barrrrr'=>'234',
'abcdefghijklmn'=>'456'
];
格式化代码后(Code -> Reformat code):
$array = [
'foo' => '123',
'barrrrr' => '234',
'abcdefghijklmn' => '456'
];
二. 变量赋值对齐
Settings (Preferences on Mac) | Editor | Code Style | PHP | Wrapping and Braces -> Assignment Statement -> Align consecutive assignments (勾选)
$sExample = 'Example !';
$sAnotherOneHere = 'Again ?';
$sAndTheLast = 'ENOUGH !';
$sExample = 'Example !';
$sAnotherOneHere = 'Again ?';
$sAndTheLast = 'ENOUGH !';
三. 类和方法的花括号跟在方法名后面
Settings -> Editor -> Code style -> PHP -> Wrapping and Braces -> Braces placement -> In function declaratio (Or In class declaratio) -> end of line (勾选)
<?php
class Foo
{
}
<?php
class Foo{
}