PHP-Parser icon indicating copy to clipboard operation
PHP-Parser copied to clipboard

Improve printer compatibility with PSR-2/12

Open SerafimArts opened this issue 6 years ago • 2 comments

Fixed whitespace before Closure "use" statement.

Before:

function ($arg) use($var) { ... }

After:

function ($arg) use ($var) { ... }
//                 ^ whitespace added

Reason: PSR-2 https://www.php-fig.org/psr/psr-2/#6-closures

Removed whitespace prefix before typehint colon.

Before:

function example() : void { ... }

After:

function example(): void { ... }
//                ^ whitespace removed

Reason: PSR-12 https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md#45-method-and-function-arguments

SerafimArts avatar Jul 24 '19 14:07 SerafimArts

Generally this looks reasonable, but I don't think I can merge this into 4.x due to the backwards compatibility break this causes.

nikic avatar Jul 24 '19 15:07 nikic

I propose to merge this PR into the future 4.3 version.

Test fails associated with incorrect work on PHP 7.4

SerafimArts avatar Jul 24 '19 16:07 SerafimArts

Variants of these changes have been implemented for the next major in the meantime.

nikic avatar Aug 28 '22 16:08 nikic