From 6a3cb055779c0a9347d334c9589d00361b454dd4 Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <ben@bnf.dev>
Date: Tue, 24 Oct 2023 10:15:18 +0200
Subject: [PATCH] [TASK] Pin to PER Coding Style v1.0

PER-CS2.0 was added as clone of PER-CS1.0 in php-cs-fixer v3.27
in order to implement the new rules that are defined in
PER Coding Style 2.0 [1]. The alias PER already points to PER-CS2.0
although the current set of rules are not implemented yet. [2]
There is only one rule (single_line_empty_body) that is done by now
and more will follow, so we rather pin to PER-CS1.0 for now (and
enable single_line_empty_body which we already migrated to) in
order to prevent having coding style changes with every
php-cs-fixer raise. We rather wait until the 2.0 preset has been
finished and is on par with the upstream php-fig definitions and
then switch with one change.

[1] https://www.php-fig.org/per/coding-style/
[2] https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247

Resolves: #102240
Related: #102236
Releases: main, 12.4, 11.5
Change-Id: I33377e4e5016f1e5cc8ab08a9e71a933dcd41d93
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81539
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
---
 Build/php-cs-fixer/config.php | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Build/php-cs-fixer/config.php b/Build/php-cs-fixer/config.php
index 20b171c3a783..a64a5e44ea18 100644
--- a/Build/php-cs-fixer/config.php
+++ b/Build/php-cs-fixer/config.php
@@ -49,7 +49,8 @@ return (new \PhpCsFixer\Config())
     ->setRiskyAllowed(true)
     ->setRules([
         '@DoctrineAnnotation' => true,
-        '@PER' => true,
+        // @todo: Switch to @PER-CS2.0 once php-cs-fixer's todo list is done: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247
+        '@PER-CS1.0' => true,
         'array_syntax' => ['syntax' => 'short'],
         'blank_line_after_opening_tag' => true,
         'braces' => ['allow_single_line_closure' => true],
@@ -95,6 +96,8 @@ return (new \PhpCsFixer\Config())
         'return_type_declaration' => ['space_before' => 'none'],
         'single_quote' => true,
         'single_line_comment_style' => ['comment_types' => ['hash']],
+        // @todo: Can be dropped once we enable @PER-CS2.0
+        'single_line_empty_body' => true,
         'single_trait_insert_per_statement' => true,
         'trailing_comma_in_multiline' => ['elements' => ['arrays']],
         'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
-- 
GitLab