mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 03:40:50 +00:00
a9b1bbba88
Co-authored-by: GitHub Action <action@github.com>
31 lines
670 B
PHP
31 lines
670 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\NodeTypeResolver\PHPStan\Collector;
|
|
|
|
use PHPStan\Analyser\Scope;
|
|
|
|
final class TraitNodeScopeCollector
|
|
{
|
|
/**
|
|
* @var array<string, Scope>
|
|
*/
|
|
private array $scopeByTraitNodeHash = [];
|
|
|
|
public function addForTrait(string $traitName, Scope $scope): void
|
|
{
|
|
// probably set from another class
|
|
if (isset($this->scopeByTraitNodeHash[$traitName])) {
|
|
return;
|
|
}
|
|
|
|
$this->scopeByTraitNodeHash[$traitName] = $scope;
|
|
}
|
|
|
|
public function getScopeForTrait(string $traitName): ?Scope
|
|
{
|
|
return $this->scopeByTraitNodeHash[$traitName] ?? null;
|
|
}
|
|
}
|