Skip to content

feat - add psr12 suppport#101

Open
driade wants to merge 5 commits intomasterfrom
feature/psr12
Open

feat - add psr12 suppport#101
driade wants to merge 5 commits intomasterfrom
feature/psr12

Conversation

@driade
Copy link
Owner

@driade driade commented Mar 6, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds PSR-12 support to the formatter and Sublime Text integration, along with new PSR-12-focused formatting passes and golden tests.

Changes:

  • Introduces a --psr12 CLI option and a PSR-12 decorator/profile enabling a set of new PSR-12 passes.
  • Updates the Sublime plugin/settings/commands to support toggling PSR-12 (mutually exclusive with PSR-2).
  • Adds PSR-12 golden tests covering imports/top-of-file layout, control structures, multiline calls/ternaries, traits, anonymous classes, and declare syntax.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
fmt.stub.php Adds PSR-12 profile wiring, CLI flag handling, and implements new PSR-12 formatting passes.
phpfmt.py Adds psr12 setting support and ensures PSR-12/PSR-2 are mutually exclusive in command construction and toggles.
phpfmt.sublime-settings Adds a default psr12 setting flag.
Default.sublime-commands Adds a command palette entry to toggle PSR-12.
README.md Documents PSR-12 support, configuration examples, and lists new passes.
tests/PSR/057-066-*.in/.out Adds PSR-12 regression/golden tests for the new behaviors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +6395 to +6408
case ST_CURLY_OPEN:
++$curlyDepth;
if ($awaitingClassCurly) {
$classCurlyDepthStack[] = $curlyDepth;
$awaitingClassCurly = false;
}
$this->appendCode($text);
break;
case ST_CURLY_CLOSE:
if (! empty($classCurlyDepthStack) && end($classCurlyDepthStack) === $curlyDepth) {
array_pop($classCurlyDepthStack);
}
$curlyDepth = max(0, $curlyDepth - 1);
$this->appendCode($text);
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PSR1ClassConstants, $curlyDepth is incremented only for ST_CURLY_OPEN, but decremented for every ST_CURLY_CLOSE. This can desync the depth when a class contains interpolated strings that emit T_CURLY_OPEN/T_DOLLAR_OPEN_CURLY_BRACES (their closing brace is still }), causing the class-scope stack to pop early and class constants to stop being uppercased. Consider incrementing $curlyDepth for T_CURLY_OPEN and T_DOLLAR_OPEN_CURLY_BRACES as well (and only pushing to $classCurlyDepthStack for the actual class-body {).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants