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
Expand Up @@ -93,6 +93,11 @@ public function refactor(Node $node): ?Node
return null;
}

$returns = $this->betterNodeFinder->findReturnsScoped($node);
if (! $this->returnAnalyzer->hasOnlyReturnWithExpr($node, $returns)) {
return null;
}

$scope = ScopeFetcher::fetch($node);
if ($this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node, $scope)) {
return null;
Expand All @@ -101,11 +106,6 @@ public function refactor(Node $node): ?Node
$tryReturnType = null;
$catchReturnTypes = [];

$returns = $this->betterNodeFinder->findReturnsScoped($node);
if (! $this->returnAnalyzer->hasOnlyReturnWithExpr($node, $returns)) {
return null;
}

foreach ((array) $node->stmts as $classMethodStmt) {
if (! $classMethodStmt instanceof TryCatch) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public function refactor(Node $node): ?Node
return null;
}

if (! $this->hasReturnArray($node)) {
return null;
}

$scope = ScopeFetcher::fetch($node);
if ($node instanceof ClassMethod && $this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod(
$node,
Expand All @@ -84,10 +88,6 @@ public function refactor(Node $node): ?Node
return null;
}

if (! $this->hasReturnArray($node)) {
return null;
}

$type = $this->returnTypeInferer->inferFunctionLike($node);
if (! $type->isArray()->yes()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ public function refactor(Node $node): ?Node
return null;
}

$scope = ScopeFetcher::fetch($node);
if ($this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node, $scope)) {
return null;
}

if (count($node->stmts) !== 1) {
return null;
}
Expand All @@ -111,6 +106,11 @@ public function refactor(Node $node): ?Node
return null;
}

$scope = ScopeFetcher::fetch($node);
if ($this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node, $scope)) {
return null;
}

if (! $this->isObjectType($returnExpr->var, new ObjectType('Symfony\Component\Serializer\Serializer'))) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ public function refactor(Node $node): ?Node
return null;
}

$scope = ScopeFetcher::fetch($node);
if ($this->shouldSkip($node, $scope)) {
return null;
}

if ($node->stmts === null) {
return null;
}
Expand All @@ -109,6 +104,11 @@ public function refactor(Node $node): ?Node
return null;
}

$scope = ScopeFetcher::fetch($node);
if ($this->shouldSkip($node, $scope)) {
return null;
}

$ternary = $return->expr;

$returnScope = $return->expr->getAttribute(AttributeKey::SCOPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ public function refactor(Node $node): ?Node
return null;
}

$scope = ScopeFetcher::fetch($node);
if (! $this->isInsideTestCaseClass($scope)) {
// only handle closures narrowed by assertInstanceOf(); plain returns are handled by ClosureReturnTypeRector
if (! $this->hasAssertInstanceOf($node)) {
return null;
}

// only handle closures narrowed by assertInstanceOf(); plain returns are handled by ClosureReturnTypeRector
if (! $this->hasAssertInstanceOf($node)) {
$scope = ScopeFetcher::fetch($node);
if (! $this->isInsideTestCaseClass($scope)) {
return null;
}

Expand Down
Loading