Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Rector\Tests\CodingStyle\Rector\ClassMethod\BinaryOpStandaloneAssignsToDirectRector\Fixture;

use CodingStyle\Rector\ClassMethod\BinaryOpStandaloneAssignsToDirectRector\Source\SomeGetter;

final class TwoBareGetters
{
public function run(SomeGetter $firstSomeGetter, SomeGetter $secondSomeGetter)
{
$first = $firstSomeGetter->getSome();
$second = $secondSomeGetter->getSome();

return $first <=> $second;
}
}

?>
-----
<?php

namespace Rector\Tests\CodingStyle\Rector\ClassMethod\BinaryOpStandaloneAssignsToDirectRector\Fixture;

use CodingStyle\Rector\ClassMethod\BinaryOpStandaloneAssignsToDirectRector\Source\SomeGetter;

final class TwoBareGetters
{
public function run(SomeGetter $firstSomeGetter, SomeGetter $secondSomeGetter)
{
return $firstSomeGetter->getSome() <=> $secondSomeGetter->getSome();
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace CodingStyle\Rector\ClassMethod\BinaryOpStandaloneAssignsToDirectRector\Source;

class SomeGetter
{
public function getSome()
{
return 100;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private function matchToVariableAssignExpr(Stmt $stmt): ?VariableAndExprAssign
}

// skip complex cases
if ($assign->expr instanceof MethodCall) {
if ($assign->expr instanceof MethodCall && $assign->expr->args !== []) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think general CallLike instance can be used, so it can be long static call:

        $first =  Some::cal(a, b, c, d, e, f, g, h, i, j, k, l, m, n):
        $second =  Some::call(a, b, c);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return null;
}

Expand Down