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

Issue:
[psr_autoloading] Configuration must be an array and may not be empty. 
## Bug report

updating from 2.18.2 to 2.18.3 we get the error when running `php-cs-fixer fix`

> [psr_autoloading] Configuration must be an array and may not be empty. 

this feels like a bug, because the docs mention this setting can be null or string

https://cs.symfony.com/doc/rules/basic/psr_autoloading.html



### Code snippet that reproduces the problem

config

```php
<?php

$finder = PhpCsFixer\Finder::create()
    ->in([
        __DIR__.'/app',
        __DIR__.'/config',
        __DIR__.'/lib',
        __DIR__.'/models',
        __DIR__.'/public',
        __DIR__.'/scripts',
    ])
;

return PhpCsFixer\Config::create()
    ->setUsingCache(true)
    ->setRules([
        '@Symfony' => true,
        '@Symfony:risky' => true,
        'array_syntax' => ['syntax' => 'short'],
        'fopen_flags' => false,
        'ordered_imports' => true,
        'protected_to_private' => false,
        'list_syntax' => ['syntax' => 'long'], // 'short' requires php 7.1+

        // custom rules for Motion
        // We need to disable psr_autoloading because it will change the classnames otherwise. PSR-0 autoloading is no solution!
        'psr_autoloading' => null,
    ])
    ->setRiskyAllowed(true)
    ->setFinder($finder)
;
```

Pull request description:
DX: RuleSet - convert null handling to soft-warning
closes #5537 

Patch:
diff --git a/src/RuleSet/RuleSet.php b/src/RuleSet/RuleSet.php
index 22f50287a..ea57d8512 100644
--- a/src/RuleSet/RuleSet.php
+++ b/src/RuleSet/RuleSet.php
@@ -39,13 +39,31 @@ class RuleSet implements RuleSetInterface
 
     public function __construct(array $set = [])
     {
-        foreach ($set as $key => $value) {
-            if (\is_int($key)) {
+        foreach ($set as $name => $value) {
+            if ('' === $name) {
+                throw new \InvalidArgumentException('Rule/set name must not be empty.');
+            }
+
+            if (\is_int($name)) {
                 throw new \InvalidArgumentException(sprintf('Missing value for "%s" rule/set.', $value));
             }
 
             if (true !== $value && false !== $value && !\is_array($value)) {
-                throw new InvalidFixerConfigurationException($key, 'Configuration must be an array and may not be empty.');
+                // @TODO drop me on 3.0
+                if (null === $value) {
+                    $messageForNullIssue = 'To disable the rule, use "FALSE" instead of "NULL".';
+                    if (getenv('PHP_CS_FIXER_FUTURE_MODE')) {
+                        throw new InvalidFixerConfigurationException($name, $messageForNullIssue);
+                    }
+
+                    @trigger_error($messageForNullIssue, E_USER_DEPRECATED);
+
+                    continue;
+                }
+
+                $message = '@' === $name[0] ? 'Set must be enabled (true) or disabled (false). Other values are not allowed.' : 'Rule must be enabled (true), disabled (false) or configured (non-empty, assoc array). Other values are not allowed.';
+
+                throw new InvalidFixerConfigurationException($name, $message);
             }
         }
 


Test patch:
diff --git a/tests/FixerFactoryTest.php b/tests/FixerFactoryTest.php
index abc0e8c8b..f4a932fcb 100644
--- a/tests/FixerFactoryTest.php
+++ b/tests/FixerFactoryTest.php
@@ -308,7 +308,7 @@ public function testConfigureFixerWithNonArray($value)
             \PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class
         );
         $this->expectExceptionMessage(
-            '[foo] Configuration must be an array and may not be empty.'
+            '[foo] Rule must be enabled (true), disabled (false) or configured (non-empty, assoc array). Other values are not allowed.'
         );
 
         $factory->useRuleSet(new RuleSet([