Mantis - Quercus
Viewing Issue Advanced Details
3972 crash always 03-29-10 09:37 01-05-11 08:57
rodchyn  
 
normal  
new 4.0.5  
open  
none    
none  
0003972: Namespace error
There are no way to write code with namespaces.
Code that throw error.

namespace identifier is not allowed at '\DomElement' in

static public function convertDomElementToArray(\DomElement $element)
{

}

Notes
(0004494)
rodchyn   
03-29-10 09:56   
I mean that I can't add global classes when passing type hint to function arguments.

In other places global classes work fine.
(0004888)
Craige   
01-05-11 06:42   
Considering nobody has looked at this in 9 months, I took a look into the source.

quercus/com/caucho/quercus/parser/QuercusParser.java line 4468 - 4475

    if (_lexeme.indexOf('\\') >= 0) {
      throw error(L.l("namespace identifier is not allowed at '{0}'",
                      _lexeme));
    }
    else if (_peek == '\\') {
        throw error(L.l("namespace identifier is not allowed at '{0}\\'",
                        _lexeme));
    }

It seems Quercus is explicitly disallowing referencing the global namespace, but I could be wrong. This was just a 5 min dig into the source. I'm going to dig further into it and see if I can dig up/patch the problem, but I'm not really a Quercus developer.
(0004889)
Craige   
01-05-11 08:57   
Upon further digging, it appears that `parseFunctionArgDefinition()` is calling `parseIdentifier()`, which does allow namespaced identifiers. In this particular context, a namespaced identifier is perfectly valid, and thus `parseNamespacedIdentifier()` is the method that should be called.

I have a feeling this is a legacy problem from when PHP 5.3 introduced namespaces. I'm going to see if I can set up a proper dev environment ant patch this is the next few days.