Skip to content

Commit

Permalink
Result cache - notice change in class constant PHPDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 27, 2021
1 parent 111bda6 commit d88b568
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
24 changes: 21 additions & 3 deletions src/Dependency/ExportedNode/ExportedClassConstantNode.php
Expand Up @@ -16,12 +16,15 @@ class ExportedClassConstantNode implements ExportedNode, JsonSerializable

private bool $private;

public function __construct(string $name, string $value, bool $public, bool $private)
private ?ExportedPhpDocNode $phpDoc;

public function __construct(string $name, string $value, bool $public, bool $private, ?ExportedPhpDocNode $phpDoc)
{
$this->name = $name;
$this->value = $value;
$this->public = $public;
$this->private = $private;
$this->phpDoc = $phpDoc;
}

public function equals(ExportedNode $node): bool
Expand All @@ -30,6 +33,18 @@ public function equals(ExportedNode $node): bool
return false;
}

if ($this->phpDoc === null) {
if ($node->phpDoc !== null) {
return false;
}
} elseif ($node->phpDoc !== null) {
if (!$this->phpDoc->equals($node->phpDoc)) {
return false;
}
} else {
return false;
}

return $this->name === $node->name
&& $this->value === $node->value
&& $this->public === $node->public
Expand All @@ -46,7 +61,8 @@ public static function __set_state(array $properties): ExportedNode
$properties['name'],
$properties['value'],
$properties['public'],
$properties['private']
$properties['private'],
$properties['phpDoc']
);
}

Expand All @@ -60,7 +76,8 @@ public static function decode(array $data): ExportedNode
$data['name'],
$data['value'],
$data['public'],
$data['private']
$data['private'],
$data['phpDoc'],
);
}

Expand All @@ -76,6 +93,7 @@ public function jsonSerialize()
'value' => $this->value,
'public' => $this->public,
'private' => $this->private,
'phpDoc' => $this->phpDoc,
],
];
}
Expand Down
15 changes: 14 additions & 1 deletion src/Dependency/ExportedNodeResolver.php
Expand Up @@ -194,11 +194,24 @@ public function resolve(string $fileName, \PhpParser\Node $node): ?ExportedNode
return null;
}

$classNode = $parentNode->getAttribute('parent');
if (!$classNode instanceof Class_ || !isset($classNode->namespacedName)) {
return null;
}

$docComment = $parentNode->getDocComment();

return new ExportedClassConstantNode(
$node->name->toString(),
$this->printer->prettyPrintExpr($node->value),
$parentNode->isPublic(),
$parentNode->isPrivate()
$parentNode->isPrivate(),
$this->exportPhpDocNode(
$fileName,
$classNode->namespacedName->toString(),
null,
$docComment !== null ? $docComment->getText() : null
),
);
}

Expand Down

0 comments on commit d88b568

Please sign in to comment.