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 accessing/invoking all trait member using trait name #230

Open the-liquid-metal opened 1 year ago

the-liquid-metal commented 1 year ago

Bug Description Missing error on accessing/invoking all trait member using trait name.

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;

trait Test56 {
    public static string $publicProp = "foo";

    public static function publicFunc(): string {
        return "bar";
    }

    public static function fnStatic() {
        echo Test56::$publicProp;  // this statement must trigger error
        echo static::$publicProp;  // OK
        echo self::$publicProp;    // OK

        echo Test56::publicFunc(); // this statement must trigger error
        echo static::publicFunc(); // OK
        echo self::publicFunc();   // OK

        $func1A = Test56::publicFunc(...); // this statement must trigger error
        $func1B = static::publicFunc(...); // OK
        $func1C = self::publicFunc(...);   // OK

        var_dump($func1A, $func1B, $func1C);
    }

    public function fnInstance() {
        echo Test56::$publicProp;  // this statement must trigger error
        echo static::$publicProp;  // OK
        echo self::$publicProp;    // OK
        echo $this::$publicProp;   // OK

        echo Test56::publicFunc(); // this statement must trigger error
        echo static::publicFunc(); // OK
        echo self::publicFunc();   // OK
        echo $this::publicFunc();  // OK

        $func1A = Test56::publicFunc(...); // this statement must trigger error
        $func1B = static::publicFunc(...); // OK
        $func1C = self::publicFunc(...);   // OK
        $func1D = $this::publicFunc(...);  // OK

        var_dump($func1A, $func1B, $func1C, $func1D);
    }
}

class Test56b {
    use Test56;
}

$ins = new Test56b;
$ins::fnStatic();
$ins->fnInstance();

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

trait Test56c {
    public    const CONST_1 = "foo";
    protected const CONST_2 = "bar";
    private   const CONST_3 = "baz";

    public    static string $propA = "foo";
    protected static string $propB = "bar";
    private   static string $propC = "baz";

    public    string $propX = "foo";
    protected string $propY = "bar";
    private   string $propZ = "baz";

    public static function funcA(string $par1): string {
        return $par1."foo";
    }

    protected static function funcB(string $par1): string {
        return $par1."bar";
    }

    private static function funcC(string $par1): string {
        return $par1."baz";
    }

    public function funcX(string $par1): string {
        return $par1."foo";
    }

    protected function funcY(string $par1): string {
        return $par1."bar";
    }

    private function funcZ(string $par1): string {
        return $par1."baz";
    }
}

echo Test56c::CONST_1;         // this statement must trigger error
echo Test56c::CONST_2;         // this statement must trigger error
echo Test56c::CONST_3;         // this statement must trigger error

echo Test56c::$propA;          // this statement must trigger error
echo Test56c::$propB;          // this statement must trigger error
echo Test56c::$propC;          // this statement must trigger error

echo Test56c::funcA("foo");    // this statement must trigger error
echo Test56c::funcB("bar");    // this statement must trigger error
echo Test56c::funcC("baz");    // this statement must trigger error

$func1A = Test56c::funcA(...); // this statement must trigger error
$func1B = Test56c::funcB(...); // this statement must trigger error
$func1C = Test56c::funcC(...); // this statement must trigger error

var_dump($func1A, $func1B, $func1C);