Amazing facts about namespacing in PHP

alexander at zhigalin.tk alexander at zhigalin.tk
Wed Nov 25 02:53:24 UTC 2015


You wrote:
> 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,
Hi!

> 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".
I think KDev is the best IDE ever, it can compete(and win!) with QT creator, C 
Lion, Eclipse and NetBeans, but bad PHP(and langs other than c/cpp) support 
make it an another IDE no one knows about.
If we will have a complete PHP support, maybe only the last 5.x  version(there 
is too many new stuff in PHP7) but complete, we will surely attract many new 
developers from EclipsePHP and even from PHPStorm and Zend Studio!
Bugs like this reduces KDev functionality to Kate(no one want an IDE working 
only as a text editor)...

> 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".
Next year?
3 years with no bugfixes aren't enough, lets wait more so we have 4 years.
Is true that all us have no time, but fixing reported bugs(of a certain 
criticity) is less time-expensive than adding new stuff, isn't?

> 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?
I am a PHP guy, but also have some C++ knowledge, but KDev is... complex?
(I am not complaining, only stating a fact as this is an IDE so it's soures 
have to be complex to get the things working)
The codebase is big and somewhere looks kinda like magic...
However, if you can guide me I will be happy to try to fix something :)

> > 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?
Well, to me a namespace is similar to a class, and ClassesOftenAreLikeThis.
Anyway, even if the namespaces were case-insensitive, there was no sense of 
forcing lowercase.

> Anyhow, that can easily be fixed though: Just remove the
> custom NamespaceDeclaration used in PHP and instead use the one available
> in KDevplatform directly.
Remove? I can just delete the file duchain/NamespaceDeclaration{.h/.cpp} or I 
must do something different? Anyway I prefer tune the thing instead of getting 
rid of it.

> Maybe that fixes it already. Alternatively, just
> remove the to-lower step
I was searcing for the to-lower step but...
> for these declarations and remove the "prettyName"
> (which is the non-lowercased identifier).
Yeah, prettyName I had observed is first of all but find nothing...
Wait!
Oh shi..!
FOUND.
Why, oh why is inside duchain/helper.cpp ?
Is in QualifiedIdentifier identifierForNamespace(NamespacedIdentifierAst* node, 
EditorIntegrator* editor, bool lastIsConstIdentifier).
I will fix it soon.

> > 2: Sometimes in the completion the same namespace appears more times...
> 
> Sounds like another bug... Can you report it with a reproducible test case?
As soon as I'll have some more time.

> > 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.
There is 2 kinds of tasks: intresting ones and needed ones...

> 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!



More information about the KDevelop-devel mailing list