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 mismatch between default value and property type #231

Open the-liquid-metal opened 1 year ago

the-liquid-metal commented 1 year ago

Bug Description Missing error on mismatch between default value and property type.

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 Test57 {
    public int $propInt1 = 10;                 // OK
    public int $propInt2 = 10.1;               // this statement must display error
    public int $propInt3 = "foo";              // this statement must display error
    public int $propInt4 = false;              // this statement must display error
    public int $propInt5 = null;               // this statement must display error
    public int $propInt6 = [10, "foo", false]; // this statement must display error

    public float $propFloat1 = 10;                 // OK
    public float $propFloat2 = 10.1;               // OK
    public float $propFloat3 = "foo";              // this statement must display error
    public float $propFloat4 = false;              // this statement must display error
    public float $propFloat5 = null;               // this statement must display error
    public float $propFloat6 = [10, "foo", false]; // this statement must display error

    public string $propString1 = 10;                 // this statement must display error
    public string $propString2 = 10.1;               // this statement must display error
    public string $propString3 = "foo";              // OK
    public string $propString4 = false;              // this statement must display error
    public string $propString5 = null;               // this statement must display error
    public string $propString6 = [10, "foo", false]; // this statement must display error

    public bool $propBool1 = 10;                  // this statement must display error
    public bool $propBool2 = 10.1;                // this statement must display error
    public bool $propBool3 = "foo";               // this statement must display error
    public bool $propBool4 = false;               // OK
    public bool $propBool5 = null;                // this statement must display error
    public bool $propBool6 = [10, "foo", false];  // this statement must display error

    public array $propArray1 = 10;                 // this statement must display error
    public array $propArray2 = 10.1;               // this statement must display error
    public array $propArray3 = "foo";              // this statement must display error
    public array $propArray4 = false;              // this statement must display error
    public array $propArray5 = null;               // this statement must display error
    public array $propArray6 = [10, "foo", false]; // OK

    public object $propObject1 = 10;                 // this statement must display error
    public object $propObject2 = 10.1;               // this statement must display error
    public object $propObject3 = "foo";              // this statement must display error
    public object $propObject4 = false;              // this statement must display error
    public object $propObject5 = null;               // this statement must display error
    public object $propObject6 = [10, "foo", false]; // this statement must display error
}