eclipse-pdt / pdt

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

Missing error on using enum as array key #217

Open the-liquid-metal opened 1 year ago

the-liquid-metal commented 1 year ago

Bug Description Missing error on using enum as array key.

Eclipse environment Version: 2023-06 (4.28.0) Build id: 20230608-1333 PDT: 8.0.0.202306050832

System

To Reproduce Steps to reproduce the behavior: copy-paste this script to the IDE

<?php
declare(strict_types=1);

namespace ns1\ns2;

enum Test42: string {
    case Hearts = 'H';
    case Diamonds = 'D';
    case Clubs = 'C';
    case Spades = 'S';
}

$test42 = Test42::Hearts;

$var1 = [
    Test42::Hearts => 10,        // this statement must trigger error
    Test42::Hearts->value => 10, // OK
    Test42::Hearts->name => 10,  // OK
    Test42::Hearts->other => 10, // this statement must trigger error
    $test42 => 10,               // this statement must trigger error
    $test42->value => 10,        // OK
    $test42->name => 10,         // OK
    $test42->other => 10,        // this statement must trigger error
];

echo $var1[Test42::Hearts];        // this statement must trigger error
echo $var1[Test42::Hearts->value]; // OK
echo $var1[Test42::Hearts->name];  // OK
echo $var1[Test42::Hearts->other]; // this statement must trigger error
echo $var1[$test42];               // this statement must trigger error
echo $var1[$test42->value];        // OK
echo $var1[$test42->name];         // OK
echo $var1[$test42->other];        // this statement must trigger error