dss087358 2019-02-14 17:54
浏览 78

警告消息:“找不到方法getText”,仅编辑器警告*,在运行时工作

I am trying to get rid of an editor warning:

"Method 'getText' not found."

This is only an editor issue because the code works at run-time, so my assumption is that the editor is just not 'aware' of where this method is from. Therefore, I am looking for help on how to set-up the Editor to work with my PHP 7.3 interpreter and all of its libraries.

I've tried two things:

  1. Under the Language & Frameworks setting for PHP, I tried syncing "Extensions with Interpreter"
  2. Looking through some what I 'think' are similar problems on here and elsewhere, I was pointed to one, which was to enable the extension: extension=intl in my php.ini file.
$this->foo("foooooooo");
$foos = $this->getElements('//XPATH"]//a[starts-with(text(), "TEXT")]');
$selectedFoo = false;

//Choose XXX foo if it exists
foreach ($foos as $foo)
{
    $fooText = $foo->getText(); //I get the warning here

    if (substr($fooText, -3) === 'XXX')
    {
        $selectedFoo = $foo;
    }
}

I expect that the editor is able to get the reference to this method and not show a warning.

*If you believe I have not put in the adequate effort into researching this issue, please tell me so but I would appreciate being pointed into the right direction, so that I may make another attempt to solve it on my own.

  • 写回答

1条回答 默认 最新

  • dtgr3392 2019-02-18 15:22
    关注

    I guess you can help PhpStorm by adding @var doc block:

    $this->foo("foooooooo");
    
    /** @var Behat\Mink\Element\Element[] $foos */
    $foos = $this->getElements('//XPATH"]//a[starts-with(text(), "TEXT")]');
    
    $selectedFoo = false;
    
    //Choose XXX foo if it exists
    foreach ($foos as $foo)
    {
        $fooText = $foo->getText(); //I get the warning here
    
        if (substr($fooText, -3) === 'XXX')
        {
            $selectedFoo = $foo;
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路