Skip to content

Commit d88b568

Browse files
committed
Result cache - notice change in class constant PHPDoc
1 parent 111bda6 commit d88b568

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/Dependency/ExportedNode/ExportedClassConstantNode.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ class ExportedClassConstantNode implements ExportedNode, JsonSerializable
1616

1717
private bool $private;
1818

19-
public function __construct(string $name, string $value, bool $public, bool $private)
19+
private ?ExportedPhpDocNode $phpDoc;
20+
21+
public function __construct(string $name, string $value, bool $public, bool $private, ?ExportedPhpDocNode $phpDoc)
2022
{
2123
$this->name = $name;
2224
$this->value = $value;
2325
$this->public = $public;
2426
$this->private = $private;
27+
$this->phpDoc = $phpDoc;
2528
}
2629

2730
public function equals(ExportedNode $node): bool
@@ -30,6 +33,18 @@ public function equals(ExportedNode $node): bool
3033
return false;
3134
}
3235

36+
if ($this->phpDoc === null) {
37+
if ($node->phpDoc !== null) {
38+
return false;
39+
}
40+
} elseif ($node->phpDoc !== null) {
41+
if (!$this->phpDoc->equals($node->phpDoc)) {
42+
return false;
43+
}
44+
} else {
45+
return false;
46+
}
47+
3348
return $this->name === $node->name
3449
&& $this->value === $node->value
3550
&& $this->public === $node->public
@@ -46,7 +61,8 @@ public static function __set_state(array $properties): ExportedNode
4661
$properties['name'],
4762
$properties['value'],
4863
$properties['public'],
49-
$properties['private']
64+
$properties['private'],
65+
$properties['phpDoc']
5066
);
5167
}
5268

@@ -60,7 +76,8 @@ public static function decode(array $data): ExportedNode
6076
$data['name'],
6177
$data['value'],
6278
$data['public'],
63-
$data['private']
79+
$data['private'],
80+
$data['phpDoc'],
6481
);
6582
}
6683

@@ -76,6 +93,7 @@ public function jsonSerialize()
7693
'value' => $this->value,
7794
'public' => $this->public,
7895
'private' => $this->private,
96+
'phpDoc' => $this->phpDoc,
7997
],
8098
];
8199
}

src/Dependency/ExportedNodeResolver.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,24 @@ public function resolve(string $fileName, \PhpParser\Node $node): ?ExportedNode
194194
return null;
195195
}
196196

197+
$classNode = $parentNode->getAttribute('parent');
198+
if (!$classNode instanceof Class_ || !isset($classNode->namespacedName)) {
199+
return null;
200+
}
201+
202+
$docComment = $parentNode->getDocComment();
203+
197204
return new ExportedClassConstantNode(
198205
$node->name->toString(),
199206
$this->printer->prettyPrintExpr($node->value),
200207
$parentNode->isPublic(),
201-
$parentNode->isPrivate()
208+
$parentNode->isPrivate(),
209+
$this->exportPhpDocNode(
210+
$fileName,
211+
$classNode->namespacedName->toString(),
212+
null,
213+
$docComment !== null ? $docComment->getText() : null
214+
),
202215
);
203216
}
204217

0 commit comments

Comments
 (0)