Description
When reporting an issue (bug) please provide the following information:
The PHP version you are using ($ php -v
):
PHP 7.2.21-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 7 2019 09:53:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.21-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
PHP CS Fixer version you are using ($ php-cs-fixer -V
):
PHP CS Fixer 2.16.0 Yellow Bird by Fabien Potencier and Dariusz Ruminski
The command you use to run PHP CS Fixer:
php-cs-fixer fix --diff --dry-run --rules=class_definition .
The configuration file you are using, if any:
none
If applicable, please provide minimum samples of PHP code (as plain text, not screenshots):
- before running PHP CS Fixer (no changes):
$class = new class(
$foo,
$bar,
$baz
) extends \Psr\Log\AbstractLogger implements \Psr\Log\LoggerInterface {
public function __construct($foo, $bar, $baz)
{
}
public function log($level, $message, array $context = array())
{
echo $message;
}
};
- with unexpected changes applied when running PHP CS Fixer:
$class = new class($foo, $bar, $baz) extends \Psr\Log\AbstractLogger implements \Psr\Log\LoggerInterface {
The multiline constructor parameters are forced onto one line. This example uses short var names, using longer var names and outer class properties (like injecting mock objects in tests) makes this more obvious that creating a very long single line is not a good idea.
- with the changes you expected instead:
PSR12 states in section 8: Anonymous Classes MUST follow the same guidelines and principles as closures in the above section.
Section 7 has this example
$longArgs_longVars = function (
$longArgument,
$longerArgument,
$muchLongerArgument
) use (
$longVar1,
$longerVar2,
$muchLongerVar3
) {
// body
};
I'd expect that using multiline argument lists like in the example code is completely correct, no changes should take place at all.