gen_stub: clean up some variable declarations

Inline single-use variables, remove unneeded forward declarations
This commit is contained in:
Daniel Scherzer 2025-02-04 11:20:04 -08:00 committed by Máté Kocsis
parent 4af64fdbfa
commit c2f81073fd

View file

@ -4599,14 +4599,12 @@ function parseClass(
?int $minimumPhpVersionIdCompatibility, ?int $minimumPhpVersionIdCompatibility,
bool $isUndocumentable bool $isUndocumentable
): ClassInfo { ): ClassInfo {
$flags = $class instanceof Class_ ? $class->flags : 0;
$comments = $class->getComments(); $comments = $class->getComments();
$alias = null; $alias = null;
$isDeprecated = false; $isDeprecated = false;
$isStrictProperties = false; $isStrictProperties = false;
$isNotSerializable = false; $isNotSerializable = false;
$allowsDynamicProperties = false; $allowsDynamicProperties = false;
$attributes = [];
if ($comments) { if ($comments) {
$tags = parseDocComments($comments); $tags = parseDocComments($comments);
@ -4667,7 +4665,7 @@ function parseClass(
return new ClassInfo( return new ClassInfo(
$name, $name,
$flags, $class instanceof Class_ ? $class->flags : 0,
$classKind, $classKind,
$alias, $alias,
$class instanceof Enum_ && $class->scalarType !== null $class instanceof Enum_ && $class->scalarType !== null
@ -4911,8 +4909,7 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
} }
function parseStubFile(string $code): FileInfo { function parseStubFile(string $code): FileInfo {
$lexer = new PhpParser\Lexer\Emulative(); $parser = new PhpParser\Parser\Php7(new PhpParser\Lexer\Emulative());
$parser = new PhpParser\Parser\Php7($lexer);
$nodeTraverser = new PhpParser\NodeTraverser; $nodeTraverser = new PhpParser\NodeTraverser;
$nodeTraverser->addVisitor(new PhpParser\NodeVisitor\NameResolver); $nodeTraverser->addVisitor(new PhpParser\NodeVisitor\NameResolver);
$prettyPrinter = new class extends Standard { $prettyPrinter = new class extends Standard {
@ -5178,8 +5175,7 @@ function generateArgInfoCode(
$framelessFunctionCode = generateCodeWithConditions( $framelessFunctionCode = generateCodeWithConditions(
$fileInfo->getAllFuncInfos(), "\n", $fileInfo->getAllFuncInfos(), "\n",
static function (FuncInfo $funcInfo) { static function (FuncInfo $funcInfo) {
$code = $funcInfo->getFramelessDeclaration($funcInfo); return $funcInfo->getFramelessDeclaration($funcInfo);
return $code;
} }
); );