22
33namespace PHPStan \Analyser ;
44
5- use PhpParser \Token ;
65use PHPStan \Reflection \ClassReflection ;
76use PHPStan \ShouldNotHappenException ;
87
98final class ScopeContext
109{
1110
12- /**
13- * @param string $file
14- * @param \PHPStan\Reflection\ClassReflection|null $classReflection
15- * @param \PHPStan\Reflection\ClassReflection|null $traitReflection
16- * @param Token[] $tokens
17- */
1811 private function __construct (
1912 private string $ file ,
2013 private ?ClassReflection $ classReflection ,
2114 private ?ClassReflection $ traitReflection ,
22- private array $ tokens ,
2315 )
2416 {
2517 }
2618
27- /**
28- * @param string $file
29- * @param Token[] $tokens
30- *
31- * @return self
32- *
33- * @api
34- */
35- public static function create (string $ file , array $ tokens = []): self
19+ /** @api */
20+ public static function create (string $ file ): self
3621 {
37- return new self ($ file , classReflection: null , traitReflection: null , tokens: $ tokens );
22+ return new self ($ file , classReflection: null , traitReflection: null );
3823 }
3924
4025 public function beginFile (): self
4126 {
42- return new self ($ this ->file , classReflection: null , traitReflection: null , tokens: $ this -> tokens );
27+ return new self ($ this ->file , classReflection: null , traitReflection: null );
4328 }
4429
4530 public function enterClass (ClassReflection $ classReflection ): self
@@ -50,7 +35,7 @@ public function enterClass(ClassReflection $classReflection): self
5035 if ($ classReflection ->isTrait ()) {
5136 throw new ShouldNotHappenException ();
5237 }
53- return new self ($ this ->file , $ classReflection , traitReflection: null , tokens: $ this -> tokens );
38+ return new self ($ this ->file , $ classReflection , traitReflection: null );
5439 }
5540
5641 public function enterTrait (ClassReflection $ traitReflection ): self
@@ -62,7 +47,7 @@ public function enterTrait(ClassReflection $traitReflection): self
6247 throw new ShouldNotHappenException ();
6348 }
6449
65- return new self ($ this ->file , $ this ->classReflection , $ traitReflection, $ this -> tokens );
50+ return new self ($ this ->file , $ this ->classReflection , $ traitReflection );
6651 }
6752
6853 public function equals (self $ otherContext ): bool
@@ -105,12 +90,4 @@ public function getTraitReflection(): ?ClassReflection
10590 return $ this ->traitReflection ;
10691 }
10792
108- /**
109- * @return Token[]
110- */
111- public function getTokens (): array
112- {
113- return $ this ->tokens ;
114- }
115-
11693}
0 commit comments