1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Analyser;
4:
5: use PHPStan\AnalysedCodeException;
6: use function sprintf;
7:
8: /**
9: * @api
10: *
11: * Unchecked exception thrown from `PHPStan\Analyser\Scope::getVariableType()`
12: * in case the user doesn't check `hasVariableType()` is not `no()`.
13: */
14: final class UndefinedVariableException extends AnalysedCodeException
15: {
16:
17: public function __construct(private Scope $scope, private string $variableName)
18: {
19: parent::__construct(sprintf('Undefined variable: $%s', $variableName));
20: }
21:
22: public function getScope(): Scope
23: {
24: return $this->scope;
25: }
26:
27: public function getVariableName(): string
28: {
29: return $this->variableName;
30: }
31:
32: public function getTip(): ?string
33: {
34: return null;
35: }
36:
37: }
38: