Amazing facts about namespacing in PHP

Milian Wolff mail at milianw.de
Tue Nov 24 16:49:34 UTC 2015


On Dienstag, 24. November 2015 15:56:03 CET Alexander Zhigalin wrote:
> BUGHUNT MODE ON;
> 
> {0-noname.png}
> There is a lazy class load system, so no includes, \Application\DB is used 3
> times.
> \Application\DB is not recognized(as every other classes in other
> namespaces, as was stated here: https://bugs.kde.org/show_bug.cgi?id=280985
> (btw, 3 year with no fix...)), Application\DB is recognized but wrong.
> I have made a supposion that the parser doesn't recognize the leading
> backslash, but...
> 
> {1-require.png}
> If we directly include the file /Application/DB.php the thing work.
> Obliviously, including tons of files just to get duchain working is not an
> option.
> 
> we_need_to_go_deeper.jpg :)
> 
> {2-nobackslash.png}
> WTF? What kind of logic make it working then we leave just 1 backslash of 3?


Hey Alexander,

I'm aware that the PHP namespace support for KDevelop is a mess. I introduced 
it back then a few years ago but b/c I don't use PHP myself anymore, and b/c 
the PHP language is so stupid in many cases, I simply opted to spend my time 
elsewhere. I can completely understand that you and other people that rely on 
PHP are frustrated. What we need is someone with C++ _and_ PHP language skills 
_and_ time. Heinz picked up my role back than but currently also has no time 
to fix PHP support for KDevelop. Afaik he said something like "maybe early 
next year".

Alexander, do you happen to have C++ skills? You said you dove into the code 
already. I could guide you a bit, maybe you can then fix it for real?

> Another two things:
> 
> 1: Somewhere in duchain all the namespace names are being lowercased, while
> is PHP namespaces aren't always lowercase, moreover they're case-sensitive
> and "\Application" != "\application". I lurked inside the sources but I had
> no success. Maybe someone will be able to suggest where is that mysteriuos
> place?

All other declarations in PHP are case-insensitive. Why oh why are namespaces 
not? Anyhow, that can easily be fixed though: Just remove the custom 
NamespaceDeclaration used in PHP and instead use the one available in 
KDevplatform directly. Maybe that fixes it already. Alternatively, just remove 
the to-lower step for these declarations and remove the "prettyName" (which is 
the non-lowercased identifier).

> 2: Sometimes in the completion the same namespace appears more times...

Sounds like another bug... Can you report it with a reproducible test case?

> P.S. Using Kubuntu 14.04, Kdev 4.6 from repos and then 4.7.2 from sources,
> but still the same bugs :(

In 5.0 most of these bugs will also still be there, I'm afraid. Not much 
happened in kdev-php due to the above mentioned lack of interest from capable 
C++ developers.

Cheers

PS: To make one thing clear: I'd _love_ to see the PHP support in KDevelop 
improved! Please step up if you feel like it!
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20151124/733d896e/attachment.sig>


More information about the KDevelop-devel mailing list