Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting problems in class properties defaults declaration in PHP #7190

Closed
Eugene-Melbourne opened this issue Mar 25, 2024 · 1 comment · Fixed by #7423
Closed

Formatting problems in class properties defaults declaration in PHP #7190

Eugene-Melbourne opened this issue Mar 25, 2024 · 1 comment · Fixed by #7423
Assignees
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Milestone

Comments

@Eugene-Melbourne
Copy link

Apache NetBeans version

Apache NetBeans 21

What happened

class properties defaults declaration in PHP does not format correctly if types are provided

Language / Project Type / NetBeans Component

PHP project

How to reproduce

actual formatting

use Carbon\Carbon;
class Foo
{
    private ?string $a   = '';
    private ?Carbon $b   = null;
    private ?int $c   = null;
    private ?array $foo = [];
}

expected formatting

use Carbon\Carbon;
class Foo
{
    private ?string $a   = '';
    private ?Carbon $b   = null;
    private ?int $c      = null;
    private ?array $foo  = [];
}

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 10 version 10.0 running on amd64; UTF-8; en_AU (nb)

JDK

19.0.2; Java HotSpot(TM) 64-Bit Server VM 19.0.2+7-44

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

@Eugene-Melbourne Eugene-Melbourne added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Mar 25, 2024
@troizet troizet added the PHP [ci] enable extra PHP tests (php/php.editor) label Mar 26, 2024
@junichi11
Copy link
Member

Please also write your formatting option.

@junichi11 junichi11 removed the needs:triage Requires attention from one of the committers label May 30, 2024
@junichi11 junichi11 self-assigned this May 30, 2024
@junichi11 junichi11 added this to the NB23 milestone May 30, 2024
junichi11 added a commit to junichi11/netbeans that referenced this issue May 31, 2024
- apache#7190
- Add a field type name length
- Fix const name length
- Add unit tests

Example:

```php
class GH7190 {

       private const ?string C1   = '';
    public const ?string CCCC2 = '';
    const ?string CCCC3 = '';

       private ?Test $t2;
      private ?Test $t3       = null;
    private readonly Test1&Test2 $t4;
         private array|(Test2&Test3) $test5 = [];
}
```

Before:

```php
class GH7190 {

    private const ?string C1    = '';
    public const ?string CCCC2 = '';
    const ?string CCCC3 = '';

    private ?Test $t2;
    private ?Test $t3    = null;
    private readonly Test1&Test2 $t4;
    private array|(Test2&Test3) $test5 = [];
}
```

After:

```php
class GH7190 {

    private const ?string C1   = '';
    public const ?string CCCC2 = '';
    const ?string CCCC3        = '';

    private ?Test $t2;
    private ?Test $t3                  = null;
    private readonly Test1&Test2 $t4;
    private array|(Test2&Test3) $test5 = [];
}
```
@junichi11 junichi11 linked a pull request May 31, 2024 that will close this issue
junichi11 added a commit to junichi11/netbeans that referenced this issue Jun 5, 2024
- apache#7190
- Add a field type name length
- Fix const name length
- Add unit tests

Example:

```php
class GH7190 {

       private const ?string C1   = '';
    public const ?string CCCC2 = '';
    const ?string CCCC3 = '';

       private ?Test $t2;
      private ?Test $t3       = null;
    private readonly Test1&Test2 $t4;
         private array|(Test2&Test3) $test5 = [];
}
```

Before:

```php
class GH7190 {

    private const ?string C1    = '';
    public const ?string CCCC2 = '';
    const ?string CCCC3 = '';

    private ?Test $t2;
    private ?Test $t3    = null;
    private readonly Test1&Test2 $t4;
    private array|(Test2&Test3) $test5 = [];
}
```

After:

```php
class GH7190 {

    private const ?string C1   = '';
    public const ?string CCCC2 = '';
    const ?string CCCC3        = '';

    private ?Test $t2;
    private ?Test $t3                  = null;
    private readonly Test1&Test2 $t4;
    private array|(Test2&Test3) $test5 = [];
}
```
junichi11 added a commit that referenced this issue Jun 5, 2024
…ped-fields-alignment

Fix formatting for typed field and const alignment #7190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants