Skip to content

Conversation

alexchexes
Copy link

@alexchexes alexchexes commented Jul 19, 2025

PSR‑12 and Laminas CS v2/v3 specify no space before the : in return‑type declarations (function foo(): bool).
But MethodGenerator::generate() still outputs ) : bool, a legacy Zend CS formatting.
This patch drops the extra space, bringing generated code in line with current standards.
Behaviour is unchanged; all affected tests are updated and passing.

Q A
QA yes
  • What changed?
    Replaced ' : ' with ': ' in MethodGenerator::generate().

  • Why?
    To comply with PSR‑12 / Laminas CS v2 return‑type spacing.

  • Impact
    Cosmetic only; no functional changes. Test suite green.

Signed-off-by: alexchexes <alexchexes@gmail.com>
@alexchexes alexchexes force-pushed the fix/return-type-colon-space branch from d91b53c to e747a96 Compare July 19, 2025 08:20
@gsteel gsteel added this to the 4.17.0 milestone Jul 21, 2025
Copy link
Member

@gsteel gsteel left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @alexchexes

That said, I'll defer to @Ocramius for the final word - cosmetics like this should probably be handled by PHP_CodeSniffer or CS Fixer

@alexchexes
Copy link
Author

alexchexes commented Jul 21, 2025

Thanks!

cosmetics like this should probably be handled by PHP_CodeSniffer or CS Fixer

Having the generator emit PSR‑12‑compliant code up front means even projects that don't run CS fixers get the right style for free, so it would be great if we eventually merge this.

Unlike some other codestyle preferences, which may even vary from project to project, an extra space in the fn() : bool is a rare style choice today and catches the eye too easily, IMO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants