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

Issue:
nullable_type_declaration_for_default_null_value adds ? to mixed
## Bug report

php 8.0.1
php-cs-fixer 2.18.2

```diff
-function a(mixed $val = null): void
+function a(?mixed $val = null): void
{
}
```

https://3v4l.org/Ei4aY

Pull request description:
NullableTypeDeclarationForDefaultNullValueFixer - handle mixed pseudotype
closes #5483

Patch:
diff --git a/src/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixer.php b/src/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixer.php
index 3ed4e0ba7..8325cd759 100644
--- a/src/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixer.php
+++ b/src/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixer.php
@@ -140,7 +140,7 @@ private function fixFunctionParameters(Tokens $tokens, array $arguments)
 
             $argumentTypeInfo = $argumentInfo->getTypeAnalysis();
             if (true === $this->configuration['use_nullable_type_declaration']) {
-                if (!$argumentTypeInfo->isNullable()) {
+                if (!$argumentTypeInfo->isNullable() && 'mixed' !== $argumentTypeInfo->getName()) {
                     $tokens->insertAt($argumentTypeInfo->getStartIndex(), new Token([CT::T_NULLABLE_TYPE, '?']));
                 }
             } else {


Test patch:
diff --git a/tests/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixerTest.php b/tests/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixerTest.php
index d12833a06..7ff546cc4 100644
--- a/tests/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixerTest.php
+++ b/tests/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixerTest.php
@@ -88,6 +88,8 @@ public function provideDoNotFixCases()
         yield ['<?php function foo(...$param) {}'];
         yield ['<?php function foo(array ...$param) {}'];
         yield ['<?php function foo(?array ...$param) {}'];
+
+        yield ['<?php function foo(mixed $param = null) {}'];
     }
 
     /**