php - 如何在 PhpStorm 中折叠/展开文件中的所有注释 block ?

标签 php phpstorm comments docblocks

在 PhpStorm 中,有什么快速折叠或展开文件中所有注释 (doc) block 的方法?

在文档中 here它说:

Folding and expanding code blocks works for entire classes, inner and
anonymous classes, method bodies, import lists, comments, HTML and XML tags,
closures and language injections.

然后再往下说:

If you hold the Alt modifier and click a toggle button in the gutter, the code block
will be collapsed or expanded recursively, i.e. all sub-blocks within the parent 
block will also be collapsed or expanded.

但是我没有看到这个 Alt modifer 是如何工作的?我按住 Alt 然后单击切换按钮,只有那个 block 单独折叠。我在顶级文档 block 以及属性/方法文档 block 中尝试过这个。我错过了什么吗?

最佳答案

In PhpStorm, what is a quick way to collapse or expand all the comment (doc) blocks in a file?

代码 |折叠 |折叠/展开文档评论

enter image description here

默认情况下它没有快捷方式,但可以很容易地添加到设置(Mac 上的首选项)|外观与行为 |键盘映射——任何你想要的快捷方式。


But I'm not seeing how this Alt modifer works? I hold Alt then click the toggle button and only that block alone collapses. I tried this in the top class doc block, and also in the property/method doc blocks. Am I missing something?

是的。

What does it mean by recursively?

这意味着嵌套结构也可以折叠。

I mean, when I click the toggle, everything folds, no matter what it is. Pressing Alt does nothing differently.

真的吗?

示例代码:

<?php
class SomeClass
{
    public static function makeImageName($id, $sequence = 0, $sizeId = '')
    {
        $group = floor($id / 100);

        if ((int)$sequence > 0) {
            $suffix = '-' . $sequence . $sizeId;
        }
        else {
            $suffix = $sizeId;
        }

        return "/catalog/product/{$group}/{$id}/{$id}{$suffix}.jpg";
    }
}

在功能节点上 Alt + Click 之后:

enter image description here

现在通过“正常”单击将该函数扩展回来:

enter image description here

您可以清楚地看到 ifelse 嵌套 block 仍然折叠。

关于php - 如何在 PhpStorm 中折叠/展开文件中的所有注释 block ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28354775/

相关文章:

HTML 注释行为

PHP PDO (MSSQL) 无法获取输出参数

php - Mkdir() 设置权限 777

phpstorm - 为什么 PhpStorm 不建议字符串中的变量名?

phpstorm - 如何按模式从 PhpStorm 中的项目中排除文件?

version-control - 出于历史目的注释掉代码的替代方法

php - 在 2 个或更多表上使用 SELECT

php - 将数字和运算符添加到数组 PHP

PhpStorm 忽略重新格式化时生成的代码

ios - 通过 native iOS UI 在页面上发表评论