Skip to content
This repository was archived by the owner on Feb 16, 2019. It is now read-only.

Commit 96343b4

Browse files
committed
bug #338 Hotfix/335 (Tomasz Struczyński)
This PR was merged into the 4.0-dev branch. Discussion ---------- Hotfix/335 Fixes #335 Commits ------- 0b83d5b Fix #289
2 parents 2e24ce6 + 0b83d5b commit 96343b4

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

Sami/Parser/NodeVisitor.php

+18-10
Original file line numberDiff line numberDiff line change
@@ -331,19 +331,27 @@ protected function resolveAlias($alias)
331331

332332
$class = $this->context->getClass();
333333

334-
// special aliases
335-
if ('self' === $alias || 'static' === $alias || '\$this' === $alias) {
336-
return $class->getName();
337-
}
334+
// A class MIGHT or MIGHT NOT be present in context.
335+
// It is not present in cases, where eg. `@see` tag refers to non existing class/method.
336+
// We may want to run class related checks only, if class is actually present.
337+
if ($class) {
338+
// special aliases
339+
if ('self' === $alias || 'static' === $alias || '\$this' === $alias) {
340+
return $class->getName();
341+
}
342+
343+
// an alias defined by a use statement
344+
$aliases = $class->getAliases();
345+
346+
if (isset($aliases[$alias])) {
347+
return $aliases[$alias];
348+
}
338349

339-
// an alias defined by a use statement
340-
$aliases = $class->getAliases();
341-
if (isset($aliases[$alias])) {
342-
return $aliases[$alias];
350+
// a class in the current class namespace
351+
return $class->getNamespace().'\\'.$alias;
343352
}
344353

345-
// a class in the current class namespace
346-
return $class->getNamespace().'\\'.$alias;
354+
return $alias;
347355
}
348356

349357
protected function resolveSee(array $see)

0 commit comments

Comments
 (0)