-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK: Update rector to version 0.15.2
- Loading branch information
1 parent
0b70082
commit abc5258
Showing
6 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ssch\TYPO3Rector\NodeAnalyzer; | ||
|
||
use PhpParser\Node\Expr\MethodCall; | ||
use PHPStan\Reflection\MethodReflection; | ||
use Rector\Core\Reflection\ReflectionResolver; | ||
|
||
final class SameClassMethodCallAnalyzer | ||
{ | ||
/** | ||
* @readonly | ||
*/ | ||
private ReflectionResolver $reflectionResolver; | ||
|
||
public function __construct(ReflectionResolver $reflectionResolver) | ||
{ | ||
$this->reflectionResolver = $reflectionResolver; | ||
} | ||
|
||
/** | ||
* @param MethodCall[] $chainMethodCalls | ||
*/ | ||
public function haveSingleClass(array $chainMethodCalls): bool | ||
{ | ||
// are method calls located in the same class? | ||
$classOfClassMethod = []; | ||
foreach ($chainMethodCalls as $chainMethodCall) { | ||
$methodReflection = $this->reflectionResolver->resolveMethodReflectionFromMethodCall($chainMethodCall); | ||
if ($methodReflection instanceof MethodReflection) { | ||
$declaringClass = $methodReflection->getDeclaringClass(); | ||
$classOfClassMethod[] = $declaringClass->getName(); | ||
} else { | ||
$classOfClassMethod[] = null; | ||
} | ||
} | ||
$uniqueClasses = \array_unique($classOfClassMethod); | ||
return \count($uniqueClasses) < 2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters