Skip to content

Commit ed7524a

Browse files
authoredJul 23, 2024
Merge branch refs/heads/1.11.x into 1.12.x
2 parents 00d29ea + 7c2d8b4 commit ed7524a

File tree

1 file changed

+22
-48
lines changed

1 file changed

+22
-48
lines changed
 

‎src/Reflection/SignatureMap/FunctionSignatureMapProvider.php

+22-48
Original file line numberDiff line numberDiff line change
@@ -184,80 +184,54 @@ public function getSignatureMap(): array
184184
$signatureMap = array_change_key_case($signatureMap, CASE_LOWER);
185185

186186
if ($this->stricterFunctionMap) {
187-
$stricterFunctionMap = require __DIR__ . '/../../../resources/functionMap_bleedingEdge.php';
188-
if (!is_array($stricterFunctionMap)) {
189-
throw new ShouldNotHappenException('Signature map could not be loaded.');
190-
}
191-
192-
$signatureMap = $this->computeSignatureMap($signatureMap, $stricterFunctionMap);
187+
$signatureMap = $this->computeSignatureMapFile($signatureMap, __DIR__ . '/../../../resources/functionMap_bleedingEdge.php');
193188
}
194189

195190
if ($this->phpVersion->getVersionId() >= 70400) {
196-
$php74MapDelta = require __DIR__ . '/../../../resources/functionMap_php74delta.php';
197-
if (!is_array($php74MapDelta)) {
198-
throw new ShouldNotHappenException('Signature map could not be loaded.');
199-
}
200-
201-
$signatureMap = $this->computeSignatureMap($signatureMap, $php74MapDelta);
191+
$signatureMap = $this->computeSignatureMapFile($signatureMap, __DIR__ . '/../../../resources/functionMap_php74delta.php');
202192
}
203193

204194
if ($this->phpVersion->getVersionId() >= 80000) {
205-
$php80MapDelta = require __DIR__ . '/../../../resources/functionMap_php80delta.php';
206-
if (!is_array($php80MapDelta)) {
207-
throw new ShouldNotHappenException('Signature map could not be loaded.');
208-
}
209-
210-
$signatureMap = $this->computeSignatureMap($signatureMap, $php80MapDelta);
195+
$signatureMap = $this->computeSignatureMapFile($signatureMap, __DIR__ . '/../../../resources/functionMap_php80delta.php');
211196

212197
if ($this->stricterFunctionMap) {
213-
$php80StricterFunctionMapDelta = require __DIR__ . '/../../../resources/functionMap_php80delta_bleedingEdge.php';
214-
if (!is_array($php80StricterFunctionMapDelta)) {
215-
throw new ShouldNotHappenException('Signature map could not be loaded.');
216-
}
217-
218-
$signatureMap = $this->computeSignatureMap($signatureMap, $php80StricterFunctionMapDelta);
198+
$signatureMap = $this->computeSignatureMapFile($signatureMap, __DIR__ . '/../../../resources/functionMap_php80delta_bleedingEdge.php');
219199
}
220200
}
221201

222202
if ($this->phpVersion->getVersionId() >= 80100) {
223-
$php81MapDelta = require __DIR__ . '/../../../resources/functionMap_php81delta.php';
224-
if (!is_array($php81MapDelta)) {
225-
throw new ShouldNotHappenException('Signature map could not be loaded.');
226-
}
227-
228-
$signatureMap = $this->computeSignatureMap($signatureMap, $php81MapDelta);
203+
$signatureMap = $this->computeSignatureMapFile($signatureMap, __DIR__ . '/../../../resources/functionMap_php81delta.php');
229204
}
230205

231206
if ($this->phpVersion->getVersionId() >= 80200) {
232-
$php82MapDelta = require __DIR__ . '/../../../resources/functionMap_php82delta.php';
233-
if (!is_array($php82MapDelta)) {
234-
throw new ShouldNotHappenException('Signature map could not be loaded.');
235-
}
236-
237-
$signatureMap = $this->computeSignatureMap($signatureMap, $php82MapDelta);
207+
$signatureMap = $this->computeSignatureMapFile($signatureMap, __DIR__ . '/../../../resources/functionMap_php82delta.php');
238208
}
239209

240210
if ($this->phpVersion->getVersionId() >= 80300) {
241-
$php83MapDelta = require __DIR__ . '/../../../resources/functionMap_php83delta.php';
242-
if (!is_array($php83MapDelta)) {
243-
throw new ShouldNotHappenException('Signature map could not be loaded.');
244-
}
245-
246-
$signatureMap = $this->computeSignatureMap($signatureMap, $php83MapDelta);
211+
$signatureMap = $this->computeSignatureMapFile($signatureMap, __DIR__ . '/../../../resources/functionMap_php83delta.php');
247212
}
248213

249214
if ($this->phpVersion->getVersionId() >= 80400) {
250-
$php84MapDelta = require __DIR__ . '/../../../resources/functionMap_php84delta.php';
251-
if (!is_array($php84MapDelta)) {
252-
throw new ShouldNotHappenException('Signature map could not be loaded.');
253-
}
254-
255-
$signatureMap = $this->computeSignatureMap($signatureMap, $php84MapDelta);
215+
$signatureMap = $this->computeSignatureMapFile($signatureMap, __DIR__ . '/../../../resources/functionMap_php84delta.php');
256216
}
257217

258218
return self::$signatureMaps[$cacheKey] = $signatureMap;
259219
}
260220

221+
/**
222+
* @param array<string, mixed> $signatureMap
223+
* @return array<string, mixed>
224+
*/
225+
private function computeSignatureMapFile(array $signatureMap, string $file): array
226+
{
227+
$signatureMapDelta = include $file;
228+
if (!is_array($signatureMapDelta)) {
229+
throw new ShouldNotHappenException(sprintf('Signature map file "%s" could not be loaded.', $file));
230+
}
231+
232+
return $this->computeSignatureMap($signatureMap, $signatureMapDelta);
233+
}
234+
261235
/**
262236
* @param array<string, mixed> $signatureMap
263237
* @param array<string, array<string, mixed>> $delta

0 commit comments

Comments
 (0)
Please sign in to comment.