Amazing facts about namespacing in PHP

Heinz Wiesinger HMWiesinger at liwjatan.at
Wed Nov 25 11:56:58 UTC 2015


On Wednesday 25 November 2015 03:53:24 alexander at zhigalin.tk wrote:
> 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)...

While I agree that kdev-php is lacking in features, I think it's a bit harsh 
to say it's reduced to the feature set of kate. We have quite nice support for 
many things that go way beyond what kate offers. 

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

That's a rather unfair statement. kdev-php 1.7 was released in September 2014, 
so just a bit more than 1 year ago, and contained quite some fixes and features 
for PHP support.

I agree that conceptually fixing bugs costs less time than new features, but it 
depends on the bug. You're talking about "fixing" namespaces, which is by far 
not easy and in terms of work that needs to be done may even be classified as a 
feature. Back at the sprint in Barcelona in 2014 I spent some time making it 
work generally fine. It's by far not correct and probably doesn't cover all 
corner cases, but it's usable enough for me to rely on it for my work.

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

I don't know which php you are using, but namespaces are most definitely case-
insensitive here. See testcase attached to this mail.

My guess is that forcing it lowercase makes it easier to compare all the 
possible casing options one could come up with, while showing the defined name 
as pretty name.

> As soon as I'll have some more time.

;)

Grs,
Heinz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: namespace.php
Type: application/x-php
Size: 157 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20151125/2e405f47/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20151125/2e405f47/attachment-0001.sig>


More information about the KDevelop-devel mailing list