| 1: | <?php declare(strict_types = 1); |
| 2: | |
| 3: | namespace PHPStan\Analyser; |
| 4: | |
| 5: | use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode; |
| 6: | |
| 7: | final class IntermediaryNameScope |
| 8: | { |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | public function __construct( |
| 20: | private ?string $namespace, |
| 21: | private array $uses, |
| 22: | private ?string $className = null, |
| 23: | private ?string $functionName = null, |
| 24: | private array $templatePhpDocNodes = [], |
| 25: | private ?self $parent = null, |
| 26: | private array $typeAliasesMap = [], |
| 27: | private bool $bypassTypeAliases = false, |
| 28: | private array $constUses = [], |
| 29: | private ?string $typeAliasClassName = null, |
| 30: | private ?array $traitData = null, |
| 31: | ) |
| 32: | { |
| 33: | } |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | public function getNamespace(): ?string |
| 39: | { |
| 40: | return $this->namespace; |
| 41: | } |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | public function getUses(): array |
| 47: | { |
| 48: | return $this->uses; |
| 49: | } |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | public function getConstUses(): array |
| 55: | { |
| 56: | return $this->constUses; |
| 57: | } |
| 58: | |
| 59: | public function getClassName(): ?string |
| 60: | { |
| 61: | return $this->className; |
| 62: | } |
| 63: | |
| 64: | public function getFunctionName(): ?string |
| 65: | { |
| 66: | return $this->functionName; |
| 67: | } |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | public function getTemplatePhpDocNodes(): array |
| 73: | { |
| 74: | return $this->templatePhpDocNodes; |
| 75: | } |
| 76: | |
| 77: | public function withTraitData(string $fileName, string $className, string $traitName, ?string $lookForTraitName, ?string $docComment): self |
| 78: | { |
| 79: | return new self( |
| 80: | $this->namespace, |
| 81: | $this->uses, |
| 82: | $this->className, |
| 83: | $this->functionName, |
| 84: | $this->templatePhpDocNodes, |
| 85: | $this->parent, |
| 86: | $this->typeAliasesMap, |
| 87: | $this->bypassTypeAliases, |
| 88: | $this->constUses, |
| 89: | $this->typeAliasClassName, |
| 90: | [$fileName, $className, $traitName, $lookForTraitName, $docComment], |
| 91: | ); |
| 92: | } |
| 93: | |
| 94: | |
| 95: | |
| 96: | |
| 97: | public function unsetTemplatePhpDocNodes(array $namesToUnset): self |
| 98: | { |
| 99: | $templatePhpDocNodes = $this->templatePhpDocNodes; |
| 100: | foreach ($namesToUnset as $name) { |
| 101: | unset($templatePhpDocNodes[$name]); |
| 102: | } |
| 103: | return new self( |
| 104: | $this->namespace, |
| 105: | $this->uses, |
| 106: | $this->className, |
| 107: | $this->functionName, |
| 108: | $templatePhpDocNodes, |
| 109: | $this->parent, |
| 110: | $this->typeAliasesMap, |
| 111: | $this->bypassTypeAliases, |
| 112: | $this->constUses, |
| 113: | $this->typeAliasClassName, |
| 114: | $this->traitData, |
| 115: | ); |
| 116: | } |
| 117: | |
| 118: | |
| 119: | |
| 120: | |
| 121: | public function getTraitData(): ?array |
| 122: | { |
| 123: | return $this->traitData; |
| 124: | } |
| 125: | |
| 126: | public function getParent(): ?self |
| 127: | { |
| 128: | return $this->parent; |
| 129: | } |
| 130: | |
| 131: | |
| 132: | |
| 133: | |
| 134: | public function getTypeAliasesMap(): array |
| 135: | { |
| 136: | return $this->typeAliasesMap; |
| 137: | } |
| 138: | |
| 139: | public function shouldBypassTypeAliases(): bool |
| 140: | { |
| 141: | return $this->bypassTypeAliases; |
| 142: | } |
| 143: | |
| 144: | public function getClassNameForTypeAlias(): ?string |
| 145: | { |
| 146: | return $this->typeAliasClassName; |
| 147: | } |
| 148: | |
| 149: | |
| 150: | |
| 151: | |
| 152: | public static function __set_state(array $properties): self |
| 153: | { |
| 154: | return new self( |
| 155: | $properties['namespace'], |
| 156: | $properties['uses'], |
| 157: | $properties['className'], |
| 158: | $properties['functionName'], |
| 159: | $properties['templatePhpDocNodes'], |
| 160: | $properties['parent'], |
| 161: | $properties['typeAliasesMap'], |
| 162: | $properties['bypassTypeAliases'], |
| 163: | $properties['constUses'], |
| 164: | $properties['typeAliasClassName'], |
| 165: | $properties['traitData'], |
| 166: | ); |
| 167: | } |
| 168: | |
| 169: | } |
| 170: | |