symplify / coding-standard

Coding Standard rules for PHP projects with focus on Clean Architecture
MIT License
347 stars 20 forks source link

[BUG] MethodChainingNewLineFixer: incorrectly aligns parameter of chained method result #47

Closed elkhasa closed 3 months ago

elkhasa commented 4 months ago

Example code:

<?php

declare(strict_types=1);

class A
{
    public function art(): mixed
    {
        $a = $aq->withRow($q)->name;

        $b = $aq->withRow($q)->getName($s);

        $c = $aq->withRow($q)->withOtherRow($s)->name;

        return $a + $b - $c;
    }
}

Expected result after running MethodChainingNewLineFixer:

<?php

declare(strict_types=1);

class A
{
    public function art(): mixed
    {
        $a = $aq->withRow($q)
            ->name;

        $b = $aq->withRow($q)
            ->getName($s);

        $c = $aq->withRow($q)
            ->withOtherRow($s)
            ->name;

        return $a + $b - $c;
    }
}

Reality:

<?php

declare(strict_types=1);

class A
{
    public function art(): mixed
    {
        $a = $aq->withRow($q)
->name;

        $b = $aq->withRow($q)
            ->getName($s);

        $c = $aq->withRow($q)
            ->withOtherRow($s)
->name;

        return $a + $b - $c;
    }
}