Page MenuHomeWickedGov Phorge

ElementContext.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

ElementContext.php

<?php
declare(strict_types=1);
namespace Phan\Language;
use Phan\CodeBase;
use Phan\Language\Element\AddressableElement;
use Phan\Language\Element\TypedElement;
/**
* A context referring to an element that hasn't been created yet.
* This is used when issues can be emitted before an object is added to the codebase.
*/
class ElementContext extends Context
{
/** @var ?AddressableElement $element */
private $element;
public function __construct(AddressableElement $element)
{
$this->copyPropertiesFrom($element->getContext());
$this->element = $element;
}
public function isInElementScope(): bool
{
return true;
}
/**
* Manually free the element reference to avoid the gc loop of
* Element -> Parameter -> ElementContext -> Element
*
* (Phan runs without garbage collection for performance reasons)
*/
public function freeElementReference(): void
{
$this->element = null;
}
public function getElementInScope(CodeBase $code_base): TypedElement
{
return $this->element ?? parent::getElementInScope($code_base);
}
public function isInGlobalScope(): bool
{
return false;
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, May 16, 21:33 (1 d, 8 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
be/68/afd8e1021a91ecdf5b747a8f2438
Default Alt Text
ElementContext.php (1 KB)

Event Timeline