Skip to content
Permalink
Browse files

Don’t make test reliant on knowing about Exception

  • Loading branch information...
muglug committed Aug 26, 2019
1 parent 781e711 commit d09a42721480e9e733c387ebad0e4eb4377c27da
Showing with 18 additions and 4 deletions.
  1. +17 −4 src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
  2. +1 −0 tests/ScopeTest.php
@@ -275,10 +275,23 @@ public function analyze(
if (isset($comments['specials']['psalm-scope-this'])) {
$trimmed = trim(\reset($comments['specials']['psalm-scope-this']));
$this_type = Type::parseString($trimmed);
$context->self = $trimmed;
$context->vars_in_scope['$this'] = $this_type;
$this->setFQCLN($trimmed);
if (!$codebase->classExists($trimmed)) {
if (IssueBuffer::accepts(
new \Psalm\Issue\UndefinedDocblockClass(
'Scope class ' . $trimmed . ' does not exist',
new CodeLocation($this->getSource(), $stmt, null, true),
$trimmed
)
)) {
// fall through
}
} else {
$this_type = Type::parseString($trimmed);
$context->self = $trimmed;
$context->vars_in_scope['$this'] = $this_type;
$this->setFQCLN($trimmed);
}
}
if (isset($comments['specials']['psalm-suppress'])) {
@@ -254,6 +254,7 @@ function a(): ?int {
],
'psalmScopeThisInTemplate' => [
'<?php
$e = new Exception(); // necessary to trick Psalm’s scanner for test
/** @psalm-scope-this Exception */
?>
<h1><?= $this->getMessage() ?></h1>',

0 comments on commit d09a427

Please sign in to comment.
You can’t perform that action at this time.