1
0
Fork 0

Check null before creating $range

I'm not sure this will have much of an effect, but every little helps...
pull/305/head
Matthew Brown 2017-02-17 12:50:17 -05:00 committed by GitHub
parent 5d2ab8f369
commit 5f1bc35195
1 changed files with 6 additions and 4 deletions

View File

@ -15,7 +15,7 @@ class NodeAtPositionFinder extends NodeVisitorAbstract
/**
* The node at the position, if found
*
* @var Node
* @var Node|null
*/
public $node;
@ -34,9 +34,11 @@ class NodeAtPositionFinder extends NodeVisitorAbstract
public function leaveNode(Node $node)
{
$range = Range::fromNode($node);
if (!isset($this->node) && $range->includes($this->position)) {
$this->node = $node;
if ($this->node === null) {
$range = Range::fromNode($node);
if ($range->includes($this->position)) {
$this->node = $node;
}
}
}
}