forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBroker.php
More file actions
143 lines (123 loc) · 3.57 KB
/
Copy pathBroker.php
File metadata and controls
143 lines (123 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php declare(strict_types = 1);
namespace PHPStan\Broker;
use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Reflection\GlobalConstantReflection;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\ShouldNotHappenException;
/** @api */
class Broker implements ReflectionProvider
{
private static ?Broker $instance = null;
/**
* @param string[] $universalObjectCratesClasses
*/
public function __construct(
private ReflectionProvider $reflectionProvider,
private array $universalObjectCratesClasses,
)
{
}
public static function registerInstance(Broker $broker): void
{
self::$instance = $broker;
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProviderStaticAccessor instead
*/
public static function getInstance(): Broker
{
if (self::$instance === null) {
throw new ShouldNotHappenException();
}
return self::$instance;
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function hasClass(string $className): bool
{
return $this->reflectionProvider->hasClass($className);
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function getClass(string $className): ClassReflection
{
return $this->reflectionProvider->getClass($className);
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function getClassName(string $className): string
{
return $this->reflectionProvider->getClassName($className);
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function supportsAnonymousClasses(): bool
{
return $this->reflectionProvider->supportsAnonymousClasses();
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function getAnonymousClassReflection(Node\Stmt\Class_ $classNode, Scope $scope): ClassReflection
{
return $this->reflectionProvider->getAnonymousClassReflection($classNode, $scope);
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function hasFunction(Node\Name $nameNode, ?Scope $scope): bool
{
return $this->reflectionProvider->hasFunction($nameNode, $scope);
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function getFunction(Node\Name $nameNode, ?Scope $scope): FunctionReflection
{
return $this->reflectionProvider->getFunction($nameNode, $scope);
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function resolveFunctionName(Node\Name $nameNode, ?Scope $scope): ?string
{
return $this->reflectionProvider->resolveFunctionName($nameNode, $scope);
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function hasConstant(Node\Name $nameNode, ?Scope $scope): bool
{
return $this->reflectionProvider->hasConstant($nameNode, $scope);
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function getConstant(Node\Name $nameNode, ?Scope $scope): GlobalConstantReflection
{
return $this->reflectionProvider->getConstant($nameNode, $scope);
}
/**
* @deprecated Use PHPStan\Reflection\ReflectionProvider instead
*/
public function resolveConstantName(Node\Name $nameNode, ?Scope $scope): ?string
{
return $this->reflectionProvider->resolveConstantName($nameNode, $scope);
}
/**
* @deprecated Inject %universalObjectCratesClasses% parameter instead.
*
* @return string[]
*/
public function getUniversalObjectCratesClasses(): array
{
return $this->universalObjectCratesClasses;
}
}