Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make PhpStorm suggest / autocomplete array keys

Tags:

php

phpstorm

<?php


function test(){
    return array(
        'one' => 1,
        'two' => 2
    );
}

$test = test();

echo $test[''];

I would like to put my cursor in the last line in between the single quotes, and have it suggest one or two. How can I do this?

The below works fine, so why doesn't it work inside of a function:

    $test = array(
        'one' => 1,
        'two' => 2
    );



    echo $test[''];
// Suggests 'one' and 'two'
like image 765
Zevi Sternlicht Avatar asked Dec 13 '22 16:12

Zevi Sternlicht


1 Answers

The below works fine, so why doesn't it work inside of a function:

Because it's implemented only for variables/class properties.

How can I do this?

Just install deep-assoc-completion plugin. It can do even more than that (e.g. help with completion of array parameter -- what keys are possible (if you bother to describe those keys, of course) etc).

like image 85
LazyOne Avatar answered Dec 17 '22 22:12

LazyOne