PHPStorm php代码缩进
我需要像这样正确缩进这些代码块:
$this->render('rights', array(
'admin' => $admin,
'editor' => $editor,
'author' => $author,
));
和小部件片段:
<?php $this->widget('zii.widgets.CMenu', array(
'items' => array(
array('label' => 'label', 'url' => 'url')
)
)); ?>
使用默认的 PHPStorm 设置,它会像这样缩进此代码:
$this->render('rights', array(
'admin' => $admin,
'editor' => $editor,
'author' => $author,
));
我转到“设置”->“代码样式”->“包装和大括号”并更改了以下选项:
- 数组初始值设定项->多个(取消选中)
- 方法调用参数时对齐 ->多个时对齐(取消选中)
结果是:
$this->render('rights', array(
'admin' => $admin,
'editor' => $editor,
'author' => $author,
));
仍然不是我想要的样式,但这就是我设法完成的全部。您能指出我需要更改的选项吗?
I need these chunks of code to be indented properly like this:
$this->render('rights', array(
'admin' => $admin,
'editor' => $editor,
'author' => $author,
));
and widget snippet:
<?php $this->widget('zii.widgets.CMenu', array(
'items' => array(
array('label' => 'label', 'url' => 'url')
)
)); ?>
With default PHPStorm settings it indents this code like this:
$this->render('rights', array(
'admin' => $admin,
'editor' => $editor,
'author' => $author,
));
I went to Settings->Code Style->Wrapping and Braces and changed following options:
- Array initializer -> Align when multiple (uncheck)
- Method call arguments -> Align when multiple (uncheck)
The result is:
$this->render('rights', array(
'admin' => $admin,
'editor' => $editor,
'author' => $author,
));
Still not the style I want, but that's all I managed to accomplish. Can you please point me to the option I need to change?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试选择所有代码并单击:
Ctrl + Alt + I
这是自动缩进快捷方式...
Try selecting all the code and clicking :
Ctrl + Alt + I
It's auto indentation shortcut ...
这似乎是一个已知问题。请观看/投票或添加您的评论。
It seems a to be a known issue. Please watch/vote or add your comments there.
我认为这会帮助你格式化
你的代码
https://laracasts.com/series/how-to -be-awesome-in-phpstorm/episodes/8
I think this will help you in formatting
Your code
https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/8
我发现取消选中以下选项可以解决我的问题:
这会更改以下代码:
格式如下:
I've found that unchecking the following option solves the issue for me:
This changes the following code:
To be formatted like: