Skip to content

MethodChainingNewlineFixer turns code unreadable #49

Description

@staabm

we get changes like:

33) packages/phpstan-rules/src/ScriptSimulation.php

    ---------- begin diff ----------
@@ -24,9 +24,12 @@
         }

         if (
-            $paramType->isInteger()->yes()
-            || $paramType->isBoolean()->yes()
-            || $paramType->isNumericString()->yes()
+            $paramType->isInteger()
+                ->yes()
+            || $paramType->isBoolean()
+                ->yes()
+            || $paramType->isNumericString()
+                ->yes()
         ) {
             return ['1'];
         }
    ----------- end diff -----------


Applied checkers:

* PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer
* Symplify\CodingStandard\Fixer\Spacing\MethodChainingNewlineFixer

for my source file

Minimal reproducer code snippet

<?php

declare(strict_types=1);

namespace clxSymplify\PHPStan;

use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;

/**
 * @internal
 */
final class ScriptSimulation
{
    /**
     * @return array<string>
     */
    public static function simulateParamValueType(Type $paramType): array
    {
        $constantStringTypes = $paramType->getConstantStrings();
        if ($constantStringTypes !== []) {
            return array_map(static fn (ConstantStringType $s) => $s->getValue(), $constantStringTypes);
        }

        if (
            $paramType->isInteger()->yes()
            || $paramType->isBoolean()->yes()
            || $paramType->isNumericString()->yes()
        ) {
            return ['1'];
        }

        if ($paramType->isFloat()->yes()) {
            return ['1.0'];
        }

        if ($paramType->isString()->yes()) {
            return ['string'];
        }

        if ($paramType instanceof UnionType) {
            $values = [];
            foreach ($paramType->getTypes() as $unionedType) {
                $values = array_merge($values, self::simulateParamValueType($unionedType));
            }

            return $values;
        }

        return [];
    }
}

on ECS 13.2.7.

this seem to have started recently because ECS 13.1.* did not uglify our sources =)
in my opinion make the code less readable.

were these changes intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions