Skip to content

Commit 91111d6

Browse files
committed
Updated Rector to commit 014b976b1989d40af977ba95bddf8bd63bd6eb94
rectorphp/rector-src@014b976 [CodeQuality] Skip used by other property hooks on InlineConstructorDefaultToPropertyRector (#7920)
1 parent bd8f2e3 commit 91111d6

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

rules/CodeQuality/Rector/Class_/InlineConstructorDefaultToPropertyRector.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use PhpParser\Node\Stmt\Property;
1515
use Rector\NodeAnalyzer\ExprAnalyzer;
1616
use Rector\NodeTypeResolver\Node\AttributeKey;
17+
use Rector\PhpParser\Node\BetterNodeFinder;
18+
use Rector\PhpParser\NodeFinder\PropertyFetchFinder;
1719
use Rector\Rector\AbstractRector;
1820
use Rector\ValueObject\MethodName;
1921
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@@ -27,9 +29,19 @@ final class InlineConstructorDefaultToPropertyRector extends AbstractRector
2729
* @readonly
2830
*/
2931
private ExprAnalyzer $exprAnalyzer;
30-
public function __construct(ExprAnalyzer $exprAnalyzer)
32+
/**
33+
* @readonly
34+
*/
35+
private BetterNodeFinder $betterNodeFinder;
36+
/**
37+
* @readonly
38+
*/
39+
private PropertyFetchFinder $propertyFetchFinder;
40+
public function __construct(ExprAnalyzer $exprAnalyzer, BetterNodeFinder $betterNodeFinder, PropertyFetchFinder $propertyFetchFinder)
3141
{
3242
$this->exprAnalyzer = $exprAnalyzer;
43+
$this->betterNodeFinder = $betterNodeFinder;
44+
$this->propertyFetchFinder = $propertyFetchFinder;
3345
}
3446
public function getRuleDefinition(): RuleDefinition
3547
{
@@ -121,11 +133,24 @@ private function matchAssignedLocalPropertyName(Assign $assign): ?string
121133
}
122134
return $propertyName;
123135
}
136+
private function isFoundInAnyPropertyHooks(Class_ $class, string $propertyName): bool
137+
{
138+
$propertyHooks = array_reduce($class->getProperties(), static fn(array $hooks, Property $property): array => array_merge($hooks, $property->hooks), []);
139+
return (bool) $this->betterNodeFinder->findFirst($propertyHooks, function (Node $subNode) use ($class, $propertyName): bool {
140+
if (!$subNode instanceof PropertyFetch) {
141+
return \false;
142+
}
143+
return $this->propertyFetchFinder->isLocalPropertyFetchByName($subNode, $class, $propertyName);
144+
});
145+
}
124146
private function refactorProperty(Class_ $class, string $propertyName, Expr $defaultExpr, ClassMethod $constructClassMethod, int $key): bool
125147
{
126148
if ($class->isReadonly()) {
127149
return \false;
128150
}
151+
if ($this->isFoundInAnyPropertyHooks($class, $propertyName)) {
152+
return \false;
153+
}
129154
foreach ($class->stmts as $classStmt) {
130155
if (!$classStmt instanceof Property) {
131156
continue;

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = 'a22afd1549cd9ab88fab1e47cfcb5b0d1cd50b49';
22+
public const PACKAGE_VERSION = '014b976b1989d40af977ba95bddf8bd63bd6eb94';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-03-01 15:56:12';
27+
public const RELEASE_DATE = '2026-03-04 09:05:30';
2828
/**
2929
* @var int
3030
*/

0 commit comments

Comments
 (0)