在PhpStorm中进行IntelliJ结构搜索,以查找具有特定返回类型的方法 [英] IntelliJ Structural Search in PhpStorm to find methods with specific return types

查看:441
本文介绍了在PhpStorm中进行IntelliJ结构搜索,以查找具有特定返回类型的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的示例中使用 PhpStorm的结构搜索找到返回类型为 boolean foo 方法?

How can I find the method foo with return type boolean in my example using PhpStorm's Structural Search?

<?php

class test {

    public function hello() {
        return true;
    }

    /**
     * @return bool
     */
    public function foo(): boolean {
        return true;
    }

}

$t = new test();
$t->foo();

我尝试了以下搜索模板

class $a$ {
 public function $show$(): boolean {
  $content$
 }
}

我在哪里可以了解有关这些代码/搜索模板的更多信息?

Where can I learn more about these code/search templates?

推荐答案

我最近接触过JetBrains对PhpStorm结构搜索实现的支持。问题是它只是部分实施。返回类型,继承以及使结构搜索有用的更多内容目前无法使用(选项在那里,但是变灰并且它们不起作用)。

I have recently been in contact with JetBrains support about the structural search implementation in PhpStorm. The problem is that it is only partically implemented. Things like return types, inheritance, and more things that make structural search useful are currently not available (the options are there, but grayed out and they do not work).

这使得结构搜索的用例数量非常有限,通常最好使用不同类型的搜索。

This makes the number of use cases for structural search extremely limited, you are usually better off using different kinds of searches.

有一个关于此的开放票: https://youtrack.jetbrains.com/issue/IDEA-174921

There is an open ticket about this: https://youtrack.jetbrains.com/issue/IDEA-174921

对于您的用例(查找具有布尔返回类型的函数),我建议进行正则表达式搜索:

For your use case (finding functions with a boolean return type), I would recommend doing a regular expression search:


  • 转到编辑 - > 查找 - > 在路径中查找

  • 确保选中正则表达式且取消选中匹配cas e。

  • 输入以下正则表达式: function [^}] +:\ s * bool

  • Go to Edit -> Find -> Find in Path.
  • Make sure Regex is checked and Match case is unchecked.
  • Enter the following regex: function[^}]+:\s*bool

这篇关于在PhpStorm中进行IntelliJ结构搜索,以查找具有特定返回类型的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆