Mantis - Quercus
Viewing Issue Advanced Details
3233 minor always 01-09-09 07:50 01-12-09 09:53
haplo  
nam  
normal  
closed  
fixed  
none    
none 4.0.0  
0003233: constant does not resovle ClassName::ConstantName
The method Evn.getConstantImpl does not resovle ClassName::ConstantName

Replacing Evn.getConstantImpl with the following method fixes the bug

    private Value getConstantImpl(String name) {
        Value value = _constMap.get(name);

        if (value != null)
            return value;

        value = _quercus.getConstant(name);
        if (value != null)
            return value;
        if (name.contains("::")){
            String[] splitName = name.split("::");
            if(splitName.length == 2 && _classMap.containsKey(splitName[0])){
                QuercusClass constantClass = _classMap.get(splitName[0]);
                value = constantClass.getConstant(this, splitName[1]);
            }
        }
        if(value != null){
            return value;
        }
        if (_lowerConstMap != null) {
            value = _lowerConstMap.get(name.toLowerCase());

            if (value != null)
                return value;
        }

        return null;
    }

Notes
(0003716)
nam   
01-09-09 18:19   
php/09d0
php/39d0

Test case needed. This issue does not appear to exist on the trunk:

class A
{
  const FOO = "bar";
}

var_dump(A::FOO);

Quercus results:
string(3) "bar"

(0003720)
haplo   
01-12-09 02:54   
Hi,

but this should fail:

class A
{
  const FOO = "bar";
}

var_dump(constant("A::FOO"));
(0003721)
nam   
01-12-09 09:53   
php/0508