rector/packages/NodeTypeResolver/PHPStan/Collector/TraitNodeScopeCollector.php
Tomas Votruba a9b1bbba88
[PHP 8.0] Make Downgrade widening union depend on ClassMethod, the narrow scope (#375)
Co-authored-by: GitHub Action <action@github.com>
2021-07-04 18:11:13 +00:00

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;
}
}