fix(diagnostics): handle null case
parent
9b1fafae58
commit
09477b747e
|
@ -99,7 +99,7 @@ class TreeAnalyzer
|
||||||
// Find the first ancestor that's a class method. Return an error
|
// Find the first ancestor that's a class method. Return an error
|
||||||
// if there is none, or if the method is static.
|
// if there is none, or if the method is static.
|
||||||
$method = $node->getFirstAncestor(Node\MethodDeclaration::class);
|
$method = $node->getFirstAncestor(Node\MethodDeclaration::class);
|
||||||
if ($method->isStatic()) {
|
if ($method && $method->isStatic()) {
|
||||||
$this->diagnostics[] = new Diagnostic(
|
$this->diagnostics[] = new Diagnostic(
|
||||||
"\$this can not be used in static methods.",
|
"\$this can not be used in static methods.",
|
||||||
Range::fromNode($node),
|
Range::fromNode($node),
|
||||||
|
|
Loading…
Reference in New Issue