Repository: FriendsOfPHP/PHP-CS-Fixer (php)

Issue:
PHP 8.1 Support
Do we have an issue tracking PHP 8.1 support? If not, could we use this issue to track this. My feeling here is that there isn't too much to do to support PHP 8.1 compared to what was required to support 8.0. :)

Changes to support:

* Support for `readonly` properties (both in class property definitions and also constructor property promotion).
* Support for `final` class constants.
* Support for intersection types (⚠️ lexing changes to `&` in PHP 8.1... maybe a transformer required. EDIT: https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/5861 looks to be exactly adding a transformer).
* Support for enums (definition sytnax only - i don't think there are any changes to parsing enum access - the same as class constant access).

---

Related: https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/5863.

Pull request description:
PHP 8.1: add new_in_initializers to PHP 8.1 integration test
closes #5891

Patch:
diff --git a/composer.json b/composer.json
index 48ed1f2ad..4ac1cc25f 100644
--- a/composer.json
+++ b/composer.json
@@ -1,8 +1,8 @@
 {
     "name": "friendsofphp/php-cs-fixer",
+    "type": "application",
     "description": "A tool to automatically fix PHP code style",
     "license": "MIT",
-    "type": "application",
     "authors": [
         {
             "name": "Fabien Potencier",
@@ -52,6 +52,9 @@
         "ext-dom": "For handling output formats in XML",
         "ext-mbstring": "For handling non-UTF8 characters."
     },
+    "config": {
+        "sort-packages": true
+    },
     "autoload": {
         "psr-4": {
             "PhpCsFixer\\": "src/"
@@ -64,8 +67,5 @@
     },
     "bin": [
         "php-cs-fixer"
-    ],
-    "config": {
-        "sort-packages": true
-    }
+    ]
 }
diff --git a/dev-tools/composer.json b/dev-tools/composer.json
index c3b703edc..ff133c06b 100644
--- a/dev-tools/composer.json
+++ b/dev-tools/composer.json
@@ -3,7 +3,7 @@
         "php": "^7.4 || ^8.0"
     },
     "require-dev": {
-        "ergebnis/composer-normalize": "^2.17.0",
+        "ergebnis/composer-normalize": "^2.15.0",
         "humbug/box": "^3.8",
         "humbug/php-scoper": "dev-master#0a4e329 as 0.14.2",
         "jangregor/phpstan-prophecy": "^0.8.1",


Test patch:
diff --git a/tests/Fixtures/Integration/misc/PHP8_1.test b/tests/Fixtures/Integration/misc/PHP8_1.test
index 627d78629..e6c8f2f34 100644
--- a/tests/Fixtures/Integration/misc/PHP8_1.test
+++ b/tests/Fixtures/Integration/misc/PHP8_1.test
@@ -47,6 +47,15 @@ fsync($fp);
 // https://wiki.php.net/rfc/explicit_octal_notation
 0o16 === 14;
 
+// https://wiki.php.net/rfc/new_in_initializers
+class TestNewWithInitialiers
+{
+    public function __construct(
+        private Logger $logger = new NullLogger(),
+    ) {
+    }
+}
+
 --INPUT--
 <?php
 
@@ -85,3 +94,12 @@ FSYNC($fp);
 
 // https://wiki.php.net/rfc/explicit_octal_notation
 0O16 === 14;
+
+// https://wiki.php.net/rfc/new_in_initializers
+class TestNewWithInitialiers
+{
+    public function __construct(
+        private Logger $logger = new NullLogger,
+    ) {
+    }
+}