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 Converting Enum or Enum case #210

Open the-liquid-metal opened 1 year ago

the-liquid-metal commented 1 year ago

Bug Description Missing error on Converting Enum or Enum case.

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 Test34: string {
    case Hearts = 'H';
    case Diamonds = 'D';
    case Clubs = 'C';
    case Spades = 'S';
}

echo Test34::Hearts . "\n";        // this statement must trigger error
echo Test34::Hearts->value . "\n"; // OK (not a conversion)

$test34 = Test34::Diamonds;
echo $test34 . "\n";        // this statement must trigger error
echo $test34->value . "\n"; // OK (not a conversion)

// -----------------------------------------------

enum Test34b: int {
    case Hearts = 10;
    case Diamonds = 20;
    case Clubs = 20;
    case Spades = 40;
}

echo (Test34b::Hearts + Test34b::Diamonds) . "\n";               // this statement must trigger error
echo (Test34b::Hearts->value + Test34b::Diamonds->value) . "\n"; // OK (not a conversion)

$test34bX = Test34b::Hearts;
$test34bY = Test34b::Diamonds;
echo ($test34bX + $test34bY) . "\n";               // this statement must trigger error
echo ($test34bX->value + $test34bY->value) . "\n"; // OK (not a conversion)