From 4af64fdbfa32ced473ca10043b46a71faf2805fe Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Tue, 4 Feb 2025 11:02:31 -0800 Subject: [PATCH] gen_stub: convert `parseFramelessFunctionInfo()` to a constructor Also mark `FramelessFunctionInfo::$arity` readonly --- build/gen_stub.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index f3cac6d2683..4f114136566 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -4238,15 +4238,14 @@ function parseDocComment(DocComment $comment): array { } class FramelessFunctionInfo { - public int $arity; -} + public /* readonly */ int $arity; -function parseFramelessFunctionInfo(string $json): FramelessFunctionInfo { - // FIXME: Should have some validation - $json = json_decode($json, true); - $framelessFunctionInfo = new FramelessFunctionInfo(); - $framelessFunctionInfo->arity = $json["arity"]; - return $framelessFunctionInfo; + public function __construct(string $json) { + // FIXME: Should have some validation + $json = json_decode($json, true); + + $this->arity = $json["arity"]; + } } function parseFunctionLike( @@ -4330,7 +4329,7 @@ function parseFunctionLike( break; case 'frameless-function': - $framelessFunctionInfos[] = parseFramelessFunctionInfo($tag->getValue()); + $framelessFunctionInfos[] = new FramelessFunctionInfo($tag->getValue()); break; } }