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 @@ -94,16 +94,16 @@ public function refactor(Node $node): ?int
return null;
}

if ($this->hasRefiningDocblock($node)) {
if (! $this->isParentCallDelegatingParams($node, $node->stmts[0])) {
return null;
}

$parentMethodReflection = $this->matchParentMethodReflection($node);
if (! $parentMethodReflection instanceof ExtendedMethodReflection) {
if ($this->hasRefiningDocblock($node)) {
return null;
}

if (! $this->isParentCallDelegatingParams($node, $node->stmts[0])) {
$parentMethodReflection = $this->matchParentMethodReflection($node);
if (! $parentMethodReflection instanceof ExtendedMethodReflection) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,24 @@ public function refactor(Node $node): ?int
return null;
}

$parentMethodReflection = $this->matchParentConstructorReflection($node);
if (! $parentMethodReflection instanceof ExtendedMethodReflection) {
$soleStmt = $node->stmts[0];
$parentCallArgs = $this->matchParentConstructorCallArgs($soleStmt);
if ($parentCallArgs === null) {
return null;
}

// removing public constructor would expose the narrower parent one
if (! $parentMethodReflection->isPublic()) {
// match count and order
if (! $this->isParameterAndArgCountAndOrderIdentical($node)) {
return null;
}

$soleStmt = $node->stmts[0];
$parentCallArgs = $this->matchParentConstructorCallArgs($soleStmt);
if ($parentCallArgs === null) {
$parentMethodReflection = $this->matchParentConstructorReflection($node);
if (! $parentMethodReflection instanceof ExtendedMethodReflection) {
return null;
}

// match count and order
if (! $this->isParameterAndArgCountAndOrderIdentical($node)) {
// removing public constructor would expose the narrower parent one
if (! $parentMethodReflection->isPublic()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public function refactor(Node $node): ?Node
return null;
}

// early return if no @return tag is present
if (! str_contains((string) $node->getDocComment(), '@return')) {
return null;
}

$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);

$returnTagValueNode = $phpDocInfo->getReturnTagValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public function refactor(Node $node): ?Node
$stmt->keyVar = null;
$hasChanged = true;

// no @var tag to clean up
if (! str_contains((string) $stmt->getDocComment(), '@var')) {
continue;
}

$phpDocInfo = $this->phpDocInfoFactory->createFromNode($stmt);
if (! $phpDocInfo instanceof PhpDocInfo) {
continue;
Expand Down
Loading