Skip to content

Commit 614f681

Browse files
committed
Revert arginfo generation behaviour change
1 parent 1ccc8d3 commit 614f681

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

build/gen_stub.php

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ function processStubFile(string $stubFile, Context $context): ?FileInfo {
5555
initPhpParser();
5656
$fileInfo = parseStubFile($stubCode);
5757
$arginfoCode = generateArgInfoCode($fileInfo, $stubHash);
58-
if ($context->forceRegeneration || $stubHash !== $oldStubHash) {
59-
$context->generatedArginfoFiles[$arginfoFile] = $arginfoCode;
58+
if (($context->forceRegeneration || $stubHash !== $oldStubHash) && file_put_contents($arginfoFile, $arginfoCode)) {
59+
echo "Saved $arginfoFile\n";
6060
}
6161

6262
if ($fileInfo->generateLegacyArginfo) {
6363
foreach ($fileInfo->getAllFuncInfos() as $funcInfo) {
6464
$funcInfo->discardInfoForOldPhpVersions();
6565
}
6666
$arginfoCode = generateArgInfoCode($fileInfo, $stubHash);
67-
if ($context->forceRegeneration || $stubHash !== $oldStubHash) {
68-
$context->generatedArginfoFiles[$legacyFile] = $arginfoCode;
67+
if (($context->forceRegeneration || $stubHash !== $oldStubHash) && file_put_contents($legacyFile, $arginfoCode)) {
68+
echo "Saved $legacyFile\n";
6969
}
7070
}
7171

@@ -98,8 +98,6 @@ class Context {
9898
public $forceParse = false;
9999
/** @var bool */
100100
public $forceRegeneration = false;
101-
/** @var array */
102-
public $generatedArginfoFiles = [];
103101
}
104102

105103
class SimpleType {
@@ -532,12 +530,12 @@ public function isMethod(): bool
532530

533531
public function isFinalMethod(): bool
534532
{
535-
return $this->flags & Class_::MODIFIER_FINAL || $this->classFlags & Class_::MODIFIER_FINAL;
533+
return ($this->flags & Class_::MODIFIER_FINAL) || ($this->classFlags & Class_::MODIFIER_FINAL);
536534
}
537535

538536
public function isInstanceMethod(): bool
539537
{
540-
return !($this->flags & Class_::MODIFIER_STATIC) && $this->isMethod() && $this->name->isConstructor() === false;
538+
return !($this->flags & Class_::MODIFIER_STATIC) && $this->isMethod() && !$this->name->isConstructor();
541539
}
542540

543541
public function equalsApartFromName(FuncInfo $other): bool {
@@ -1347,6 +1345,24 @@ function initPhpParser() {
13471345
exit(1);
13481346
}
13491347

1348+
if ($printParameterStats) {
1349+
$parameterStats = [];
1350+
1351+
foreach ($fileInfos as $fileInfo) {
1352+
foreach ($fileInfo->getAllFuncInfos() as $funcInfo) {
1353+
foreach ($funcInfo->args as $argInfo) {
1354+
if (!isset($context->parameterStats[$argInfo->name])) {
1355+
$parameterStats[$argInfo->name] = 0;
1356+
}
1357+
$parameterStats[$argInfo->name]++;
1358+
}
1359+
}
1360+
}
1361+
1362+
arsort($parameterStats);
1363+
echo json_encode($parameterStats, JSON_PRETTY_PRINT), "\n";
1364+
}
1365+
13501366
if ($verify) {
13511367
$errors = [];
13521368
$funcMap = [];
@@ -1431,29 +1447,3 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
14311447
exit(1);
14321448
}
14331449
}
1434-
1435-
foreach ($context->generatedArginfoFiles as $arginfoFile => $arginfoCode) {
1436-
if (file_put_contents($arginfoFile, $arginfoCode)) {
1437-
echo "Saved $arginfoFile\n";
1438-
} else {
1439-
echo "Saving $arginfoFile was unsuccessful\n";
1440-
}
1441-
}
1442-
1443-
if ($printParameterStats) {
1444-
$parameterStats = [];
1445-
1446-
foreach ($fileInfos as $fileInfo) {
1447-
foreach ($fileInfo->getAllFuncInfos() as $funcInfo) {
1448-
foreach ($funcInfo->args as $argInfo) {
1449-
if (!isset($context->parameterStats[$argInfo->name])) {
1450-
$parameterStats[$argInfo->name] = 0;
1451-
}
1452-
$parameterStats[$argInfo->name]++;
1453-
}
1454-
}
1455-
}
1456-
1457-
arsort($parameterStats);
1458-
echo json_encode($parameterStats, JSON_PRETTY_PRINT), "\n";
1459-
}

0 commit comments

Comments
 (0)