Fix using reserved type names in identifiers.
ClosedPublic

Authored by pprkut on Jun 3 2018, 7:41 PM.

Details

Summary

Remove special tokens for base type names (PHP itself doesn't
have them either in their AST). Unfortunately, keeping them,
while cleaner, is also a lot more complicated and would leave
us with double the amount of FIRST/FIRST conflicts in the grammar.
(Mostly when NamespacedIdentifiers would conflict with base types
in typehints. Think 'String\Stringhandler $foo' vs 'string $bar'.

Removing the tokens essentially immediately resolves the bug,
with the remaining work just being error handling and a bit of
cleanup.

BUG: 392759

Diff Detail

Repository
R52 KDevelop: PHP Support
Branch
types2
Lint
No Linters Available
Unit
No Unit Test Coverage
pprkut created this revision.Jun 3 2018, 7:41 PM
Restricted Application added a project: KDevelop. · View Herald TranscriptJun 3 2018, 7:41 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald Transcript
pprkut requested review of this revision.Jun 3 2018, 7:41 PM
pprkut added inline comments.Jun 3 2018, 7:49 PM
duchain/builders/declarationbuilder.cpp
205 ↗(On Diff #35479)

This is the error message that PHP gives, and yes, it says "class" in all cases, also for interfaces or traits. So not a copy-paste mistake ;)

I tend to prefer keeping this like in PHP, but if other people's preference sways a different way I'm also fine with it.

pprkut updated this revision to Diff 35797.Jun 7 2018, 7:39 PM

Renamed isObjectTypehint => isClassTypehint to avoid confusion when
'object' typehint support is implemented.

Added helper function to determine if a class name is reserved.

mwolff accepted this revision.Jun 12 2018, 8:48 PM
mwolff added a subscriber: mwolff.

lgtm, thanks!

This revision is now accepted and ready to land.Jun 12 2018, 8:48 PM
This revision was automatically updated to reflect the committed changes.