[PHP] Auto formatting does not handle use ordering
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### Apache NetBeans version
Apache NetBeans 20 release candidate
### What happened
https://www.php-fig.org/per/coding-style/#3-declare-statements-namespace-and-import-statements
>The header of a PHP file may consist of a number of different blocks. If present, each of the blocks below MUST be separated by a single blank line, and MUST NOT contain a blank line. Each block MUST be in the order listed below, although blocks that are not relevant may be omitted.
>
>- Opening - File-level docblock.
>- One or more declare statements.
>- The namespace declaration of the file.
>- One or more class-based use import statements.
>- One or more function-based use import statements.
>- One or more constant-based use import statements.
>- The remainder of the code in the file.
When using Source > Format (`alt+shift+F`) NetBeans correctly detect the blocks and separates them, but the order is not enforced. Only Source > Fix Imports (`ctrl+shift+I`) fixes the order.
```php
Contributor guide
Research direction
Reproduce the issue in Apache NetBeans 20 with the provided PHP examples using Source > Format and Source > Fix Imports. Compare the ordering of declare, namespace, class-based, function-based, and constant-based imports, including imports after a class; done means formatting enforces the PHP-FIG order and preserves a single newline at end of file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100