eclipse-pdt / pdt

PHP Development Tools project (PDT)
https://eclipse.org/pdt
Eclipse Public License 2.0
188 stars 46 forks source link

Bad suggested array key name in compile time constants #251

Open litdevel opened 11 months ago

litdevel commented 11 months ago

Describe the bug Bad suggested array key name in compile time constants

Describe the eclipse environment Eclipse PDT 8.1.0.202307051059

To Reproduce Steps to reproduce the behavior:

  1. Copy this code
    
    <?php

const TEST_CONSTANT = [ 'HT_aa_very_long_long_long_key' => 1, 'HT_ab_very_long_long_long_key' => 2, 'HT_ac_very_long_long_long_key' => 3 ];

TEST_CONSTANT['H'];

$_SERVER['HTTP_ACCEPT'];

$runtime_test_array = [ 'HT_runtime_key1_verylong' => 'value1', 'HT_runtime_key2_verylong' => 'value2', 'HT_runtime_key3_verylong' => 'value3', ];

$runtime_test_array['HT'];


3. Move cursor to "['H']" after H on line 9,  press Ctrl + Tab
4. Read suggestions

**Expected behavior**
Constant "TEST_CONSTANT" array keys 'HT_aa_very_long_long_long_key', 'HT_ab_very_long_long_long_key' and 'HT_ac_very_long_long_long_key' must be suggested. Other array keys from $runtime_test_array or $_SERVER must not be suggested.

**Screenshots**

![screen_1](https://github.com/eclipse-pdt/pdt/assets/139230522/8c829bf8-3fce-444b-b5dd-0a290fa0ad1e)
![screen_2](https://github.com/eclipse-pdt/pdt/assets/139230522/1d3d6c39-1286-4042-b6fa-6f9d40d4e697)