Bug 411588

Summary: PHP 7.0: Group Use Declarations
Product: [Applications] kdevelop Reporter: Marcus Harrison <marcus>
Component: Language Support: PHPAssignee: kdevelop-bugs-null
Status: CONFIRMED ---    
Severity: normal CC: pprkut
Priority: NOR    
Version First Reported In: 5.4.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Marcus Harrison 2019-09-04 12:32:03 UTC
As of PHP 7, a single "use" statement can refer to multiple aliases through the use of curly braces:

    // pre PHP7
    use Foo\Bar\Baz;
    use Foo\Bar\Barry;

    // post PHP7
    use Foo\Bar\{Baz, Barry};

Documentation: https://www.php.net/manual/en/language.namespaces.importing.php

This currently is considered a syntax error by the parser.
Comment 1 Heinz Wiesinger 2023-07-16 12:24:55 UTC
Git commit dca4ff7b506eec03b67f8207b447dd1291150371 by Heinz Wiesinger, on behalf of Hugues Mitonneau.
Committed on 16/07/2023 at 12:16.
Pushed by wiesinger into branch 'master'.

Syntax support for grouped namespaces

This is a first step to implement Grouped namespaces.

The syntax has been updated to parse Grouped namespaces without generating errors,
but declarations into grouped namespaces are not processed.

"Normal" use statements are still processed.
Related: bug 459654
CHANGELOG: Add partial support for PHP 7.0's grouped namespace syntax

Reviewers: pprkut

Reviewed By: pprkut

Subscribers: pprkut, kdevelop-devel

Tags: #kdevelop

Differential Revision: https://phabricator.kde.org/D29444

M  +10   -1    duchain/builders/declarationbuilder.cpp
M  +2    -1    duchain/builders/declarationbuilder.h
M  +1    -0    duchain/builders/typebuilder.cpp
M  +67   -23   duchain/builders/usebuilder.cpp
M  +15   -5    duchain/builders/usebuilder.h
M  +45   -0    duchain/helper.cpp
M  +10   -9    duchain/helper.h
M  +61   -3    parser/php.g

https://invent.kde.org/kdevelop/kdev-php/-/commit/dca4ff7b506eec03b67f8207b447dd1291150371
Comment 2 Heinz Wiesinger 2023-07-16 12:25:11 UTC
Git commit 566881bc9b0a138f4d0846e54cf2b4bedde8ff37 by Heinz Wiesinger.
Committed on 16/07/2023 at 12:16.
Pushed by wiesinger into branch 'master'.

Add unit tests for grouped namespaces
Related: bug 459654
FIXED-IN: 5.12.230800
CHANGELOG: Add support for PHP 7.2's trailing commas in grouped namespaces

M  +127  -0    duchain/tests/duchain.cpp
M  +4    -0    duchain/tests/duchain.h
M  +69   -0    duchain/tests/uses.cpp
M  +2    -0    duchain/tests/uses.h

https://invent.kde.org/kdevelop/kdev-php/-/commit/566881bc9b0a138f4d0846e54cf2b4bedde8ff37
Comment 3 Heinz Wiesinger 2023-07-16 12:29:08 UTC
Remaining work (taken from phabricator):

Declaration with alias into grouped namespace are not processed: use Foo\ { const C as FooC };
The mix between UseImportType, ParserUseImportType, DeclarationType is not clean