pdt
pdt copied to clipboard
Missing error on Converting Enum or Enum case
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
- PHP Version: 8.2.7, 8.1.20, 8.0.29, 7.4.33 (via https://onlinephp.io/)
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)