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 @@ -104,12 +104,12 @@ private function refactorBooleanOr(BooleanOr $booleanOr): ?Expr
return null;
}

// the docblock type can be wider than the real value
if ($this->exprAnalyzer->isNonTypedFromParam($nullComparedExpr)) {
if (! $booleanOr->right instanceof BooleanNot) {
return null;
}

if (! $booleanOr->right instanceof BooleanNot) {
// the docblock type can be wider than the real value
if ($this->exprAnalyzer->isNonTypedFromParam($nullComparedExpr)) {
return null;
}

Expand Down Expand Up @@ -144,6 +144,10 @@ private function refactorBooleanAnd(BooleanAnd $booleanAnd): ?Expr
return null;
}

if (! $booleanAnd->right instanceof FuncCall) {
return null;
}

// the docblock type can be wider than the real value
if ($this->exprAnalyzer->isNonTypedFromParam($booleanAnd->left)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function refactor(Node $node): ?Node
}

$hasChanged = false;
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($constructClassMethod);
$phpDocInfo = null;

foreach ($constructClassMethod->params as $key => $param) {
// only private local scope; removing public property might be dangerous
Expand Down Expand Up @@ -140,6 +140,7 @@ public function refactor(Node $node): ?Node
continue;
}

$phpDocInfo ??= $this->phpDocInfoFactory->createFromNode($constructClassMethod);
if ($phpDocInfo instanceof PhpDocInfo) {
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName);
if ($paramTagValueNode instanceof ParamTagValueNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,8 @@ public function refactor(Node $node): ?Node
return null;
}

// early return can skip the assign, so the default value is still needed
if ($this->hasEarlyReturn($node, $constructClassMethod)) {
return null;
}

$hasChanged = false;
$hasEarlyReturn = null;
$isFinal = $node->isFinal() || FeatureFlags::treatClassesAsFinal($node);

foreach ($node->getProperties() as $property) {
Expand Down Expand Up @@ -128,6 +124,12 @@ public function refactor(Node $node): ?Node
continue;
}

// early return can skip the assign, so the default value is still needed
$hasEarlyReturn ??= $this->hasEarlyReturn($node, $constructClassMethod);
if ($hasEarlyReturn) {
return null;
}

$propertyProperty->default = null;
$hasChanged = true;
}
Expand Down
Loading