noverify icon indicating copy to clipboard operation
noverify copied to clipboard

False alarm undefinedConstant Class constant ::XX does not exist

Open EdmondDantes opened this issue 3 years ago • 0 comments

PHP Version: 8.1

OS: Windows 11

Run command:

noverify.exe check --ignore-vendor --allow-disable="./*" --exclude-checks="discardExpr" --index-only-files="./tests/KC,./vendor,./api3.php" --output="reports.txt" ./KC

The minimal code in which the bug appears:


class Students                      extends LMSEntityAbstract
{
    
    const TIME_ZONE                 = 'time_zone';

    protected function _propertyTimeZone(): VirtualProperty
    {
        // @todo propertyTimeZone
        return new VirtualProperty(static::TIME_ZONE);
    }
    
    
    protected function propertyFullName(): VirtualProperty
    {
        // CONCAT_WS(' ', first_name, last_name)
        return new VirtualPropertyAsExpression(self::FULL_NAME, new ConcatenateWithSeparator(
            ' ',
            new FieldRef(self::FIRST_NAME),
            new FieldRef(self::LAST_NAME)
        ));
    }

Actual Behavior:

ERROR undefinedConstant: Class constant ::TIME_ZONE does not exist at Entities/Students.php:180 return new VirtualProperty(static::TIME_ZONE); ^^^^^^^^^ ERROR undefinedConstant: Class constant ::FULL_NAME does not exist at Entities/Students.php:187 return new VirtualPropertyAsExpression(self::FULL_NAME, new ConcatenateWithSeparator( ^^^^^^^^^ ERROR undefinedConstant: Class constant ::FIRST_NAME does not exist at Entities/Students.php:189 new FieldRef(self::FIRST_NAME), ^^^^^^^^^^ ERROR undefinedConstant: Class constant ::LAST_NAME does not exist at Entities/Students.php:190 new FieldRef(self::LAST_NAME) ^^^^^^^^^

Expected Behavior:

No alert Students.zip s

EdmondDantes avatar Feb 19 '22 09:02 EdmondDantes