Skip to content
Closed
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,19 @@
<?php

namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\Fixture;

class SkipDifferentTypePropertyAndParamType
{
private ?\stdClass $customerInput;

public function __construct(
\stdClass $customerInput,
) {
$this->customerInput = $customerInput;
}

public function markResolved(): void
{
$this->customerInput = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rector\Php80\NodeAnalyzer;

use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable;
Expand Down Expand Up @@ -131,6 +132,13 @@ private function matchPropertyPromotionCandidate(
continue;
}

if ($property->type instanceof Node
&& $matchedParam->type instanceof Node
&& ! $matchedParam->default instanceof Expr
&& ! $this->nodeComparator->areNodesEqual($matchedParam->type, $property->type)) {
continue;
}

if ($this->shouldSkipParam($matchedParam, $assignedExpr, $firstParamAsVariable)) {
continue;
}
Expand Down