kokororin / vscode-phpfmt

Integrates phpfmt into VS Code
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
BSD 3-Clause "New" or "Revised" License
130 stars 30 forks source link

Issue with StripSpaceWithinControlStructures Pass in PHP Formatting #127

Closed ferhado closed 10 months ago

ferhado commented 10 months ago

Hi,

I've encountered an issue with the StripSpaceWithinControlStructures pass in PHP formatting. The pass seems to incorrectly format the enum structure, especially with the method signature.

Before Formatting:

namespace App\Enums;

enum InvoiceStatus: string {
  case DRAFT = 'draft';
  case UNPAID = 'unpaid';
  case PAID = 'paid';
  case PARTIAL = 'partial';

  public static function isValid(string $status): bool {
    return in_array($status, self::cases(), true);

  }
}

After Formatting:

namespace App\Enums;

enum InvoiceStatus: string {
  case DRAFT = 'draft';
  case UNPAID = 'unpaid';
  case PAID = 'paid';
  case PARTIAL = 'partial';

  public static function isValid(string $status):  
  bool {
    return in_array($status, self::cases(), true);
  }
}

As you can see, after formatting, the return type bool of the isValid method is incorrectly moved to the next line. This change doesn't align with standard PHP formatting practices and could potentially lead to readability issues.

Could you please look into this issue?

Thanks, ferhado

driade commented 10 months ago

Thank you, this should be fixed, may you confirm?

ferhado commented 10 months ago

Confirmed, thank you for fastest support