To Reproduce
Steps to reproduce the behavior: copy-paste this script to the IDE
<?php
declare(strict_types=1);
namespace ns1\ns2;
class Test55 {
public const PUBLIC_CONST = "foo";
protected const PROTECTED_CONST = "bar";
private const PRIVATE_CONST = "baz";
public static function fnStatic() {
echo static::PUBLIC_CONST; // OK
echo static::PROTECTED_CONST; // OK
echo static::PRIVATE_CONST; // OK
echo static::UNDEFINED_CONST; // this statement must trigger error
echo self::PUBLIC_CONST; // OK
echo self::PROTECTED_CONST; // OK
echo self::PRIVATE_CONST; // OK
echo self::UNDEFINED_CONST; // this statement must trigger error
}
public function fnInstance() {
echo static::PUBLIC_CONST; // OK
echo static::PROTECTED_CONST; // OK
echo static::PRIVATE_CONST; // OK
echo static::UNDEFINED_CONST; // this statement must trigger error
echo self::PUBLIC_CONST; // OK
echo self::PROTECTED_CONST; // OK
echo self::PRIVATE_CONST; // OK
echo self::UNDEFINED_CONST; // this statement must trigger error
echo $this::PUBLIC_CONST; // OK
echo $this::PROTECTED_CONST; // OK
echo $this::PRIVATE_CONST; // OK
echo $this::UNDEFINED_CONST; // this statement must trigger error
}
}
class Test55b extends Test55 {
public static function fnStatic() {
echo static::PUBLIC_CONST; // OK
echo static::PROTECTED_CONST; // OK
echo static::PRIVATE_CONST; // this statement must trigger error
echo static::UNDEFINED_CONST; // this statement must trigger error
echo self::PUBLIC_CONST; // OK
echo self::PROTECTED_CONST; // OK
echo self::PRIVATE_CONST; // this statement must trigger error
echo self::UNDEFINED_CONST; // this statement must trigger error
}
public function fnInstance() {
echo static::PUBLIC_CONST; // OK
echo static::PROTECTED_CONST; // OK
echo static::PRIVATE_CONST; // this statement must trigger error
echo static::UNDEFINED_CONST; // this statement must trigger error
echo self::PUBLIC_CONST; // OK
echo self::PROTECTED_CONST; // OK
echo self::PRIVATE_CONST; // this statement must trigger error
echo self::UNDEFINED_CONST; // this statement must trigger error
echo $this::PUBLIC_CONST; // OK
echo $this::PROTECTED_CONST; // OK
echo $this::PRIVATE_CONST; // this statement must trigger error
echo $this::UNDEFINED_CONST; // this statement must trigger error
}
}
echo Test55::PUBLIC_CONST; // OK
echo Test55::PROTECTED_CONST; // this statement must trigger error
echo Test55::PRIVATE_CONST; // this statement must trigger error
echo Test55::UNDEFINED_CONST; // this statement must trigger error
$ins1 = new Test55;
echo $ins1::PUBLIC_CONST; // OK
echo $ins1::PROTECTED_CONST; // this statement must trigger error
echo $ins1::PRIVATE_CONST; // this statement must trigger error
echo $ins1::UNDEFINED_CONST; // this statement must trigger error
function myFunc(Test55 $ins) {
echo $ins::PUBLIC_CONST; // OK
echo $ins::PROTECTED_CONST; // this statement must trigger error
echo $ins::PRIVATE_CONST; // this statement must trigger error
echo $ins::UNDEFINED_CONST; // this statement must trigger error
}
$ins1::fnStatic();
$ins1->fnInstance();
myFunc($ins1);
$ins2 = new Test55b;
$ins2::fnStatic();
$ins2->fnInstance();
Bug Description Missing error on accessing undeclared/inaccessible class constant.
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