Created
April 27, 2016 22:19
-
-
Save morria/620b3847a353c60c3f962e8b3c5243ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index b8b44ce..943e87c 100644 | |
--- a/src/Phan/Language/Context.php | |
+++ b/src/Phan/Language/Context.php | |
@@ -289,7 +289,7 @@ class Context extends FileRef implements \Serializable | |
public function getClassInScope(CodeBase $code_base) : Clazz | |
{ | |
assert($this->isInClassScope(), | |
- "Must be in class scope to get class"); | |
+ "Must be in class scope to get class from $this"); | |
if (!$code_base->hasClassWithFQSEN($this->getClassFQSEN())) { | |
throw new CodeBaseException( | |
diff --git a/src/Phan/Language/UnionType.php b/src/Phan/Language/UnionType.php | |
index 4c47618..e6e9142 100644 | |
--- a/src/Phan/Language/UnionType.php | |
+++ b/src/Phan/Language/UnionType.php | |
@@ -6,6 +6,7 @@ use Phan\CodeBase; | |
use Phan\Config; | |
use Phan\Exception\CodeBaseException; | |
use Phan\Exception\IssueException; | |
+use Phan\Issue; | |
use Phan\Language\Element\Clazz; | |
use Phan\Language\FQSEN\FullyQualifiedFunctionName; | |
use Phan\Language\FQSEN\FullyQualifiedMethodName; | |
@@ -530,6 +531,18 @@ class UnionType implements \Serializable | |
$class_fqsen = $class_type->asFQSEN(); | |
if ($class_type->isStaticType()) { | |
+ if (!$context->isInClassScope()) { | |
+ throw new IssueException( | |
+ Issue::fromType(Issue::ContextNotObject)( | |
+ $context->getFile(), | |
+ $context->getLineNumberStart(), | |
+ [ | |
+ (string)$class_type | |
+ ] | |
+ ) | |
+ ); | |
+ | |
+ } | |
yield $context->getClassInScope($code_base); | |
} else { | |
// See if the class exists |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment