简体   繁体   English

数组中的数组的PHPStorm代码完成失败

[英]PHPStorm code completion fails for array within array

I have this basic code: 我有以下基本代码:

    $test = array(
    'nested' => array('test' => 'nada');
);

    function doit()
    {
        global $test;
        $test['nested'][''];
    }

PHPStorm correctly suggests me 'nested' when I press Ctrl+Space 当我按Ctrl + Space时,PHPStorm正确建议我“嵌套”
However, I found no way to make it suggest 'test' as member of the 'nested' array. 但是,我没有办法建议它作为“嵌套”数组的成员来建议“测试”。
PHPStorm does not seem to be aware that nested is an array and also has members. PHPStorm似乎不知道nested是一个数组,也有成员。

Is that a bug, did I do something wrong ? 那是一个错误,我做错了吗?

According to comment I tried another solution to get completion support: 根据评论,我尝试了另一种解决方案以获得完成支持:
With no luck either 也没有运气

    class test
    {
      public static $nested = array('test' => 'nada');
}

    function doit()
    {
        $completeme = test::$nested;
        $completeme['']; // no completion working

        /** @var test::nested $completeme */
        $completeme = test::$nested;
        $completeme['']; // no completion working
    }

Same issue for me at the IDE, this time it is an array inside a class. 在IDE中,对我来说同样的问题,这一次它是一个类中的数组。
test::nested[''] << this works, I get completion. test :: nested [''] <<这样有效,我可以完成。 But as soon as I make a copy of it I found no way to get completion again or to specify the type using phpdoc. 但是,一旦我复制了它,我就找不到重新获得完成或使用phpdoc指定类型的方法。

This feature is not implemented ( original array keys support ticket ). 未实现此功能( 原始阵列键支持ticket )。

AFAIK even remembering keys for first level array adds some noticeable overhead (memory + CPU -- depends on actual project and how heavily arrays/variables are used). AFAIK甚至记住一级数组的键都会增加一些明显的开销(内存+ CPU-取决于实际项目以及数组/变量的使用量)。 Considering this + the fact that in majority of cases first level is enough, the implementation for other levels was simply put on hold. 考虑到+在大多数情况下第一层就足够了这一事实,其他层的实现就被搁置了。

https://youtrack.jetbrains.com/issue/WI-6845 -- star/vote/comment to get notified on progress. https://youtrack.jetbrains.com/issue/WI-6845-星号/投票/评论以获取进度通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM