eclipse-pdt / pdt

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

Missing error on instantiation in class constant declaration #221

Open the-liquid-metal opened 1 year ago

the-liquid-metal commented 1 year ago

Bug Description Missing error on instantiation in class constant declaration.

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;

class Test46 {
    public function __construct(public $par1 = "bar", public $par2 = "baz") {}
}
$myVar = "bar";

class Test1 {
    const CONST_F1 = ["foo", new Test46];               // this statement must trigger error
    const CONST_F2 = ["foo", new Test46()];             // this statement must trigger error
    const CONST_F3 = ["foo", new Test46("bar")];        // this statement must trigger error
    const CONST_F4 = ["foo", new Test46($myVar)];       // misleading error
    const CONST_F5 = ["foo", new Test46(par2: $myVar)]; // misleading error
    const CONST_F6 = ["foo", new Test46(...$myVar)];    // misleading error

    const CONST_C1 = new Test46;               // this statement must trigger error
    const CONST_C2 = new Test46();             // this statement must trigger error
    const CONST_C3 = new Test46("bar");        // this statement must trigger error
    const CONST_C4 = new Test46($myVar);       // misleading error
    const CONST_C5 = new Test46(par2: $myVar); // misleading error
    const CONST_C6 = new Test46(...$myVar);    // misleading error
}