Skip to content

Commit

Permalink
add getStringValue() to value resolver (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Nov 2, 2021
1 parent f6afff9 commit 29b7978
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/PhpParser/Node/Value/ValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public function isValue(Expr $expr, $value): bool
return $this->getValue($expr) === $value;
}

public function getStringValue(Expr $expr): string
{
$resolvedValue = $this->getValue($expr);
if (! is_string($resolvedValue)) {
throw new ShouldNotHappenException();
}

return $resolvedValue;
}

/**
* @return mixed|null
*/
Expand Down

0 comments on commit 29b7978

Please sign in to comment.