Skip to content

Commit ef5771d

Browse files
gen_stub: use real readonly modifier
1 parent b83dd10 commit ef5771d

File tree

1 file changed

+69
-69
lines changed

1 file changed

+69
-69
lines changed

build/gen_stub.php

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ class Context {
210210
}
211211

212212
class ArrayType extends SimpleType {
213-
private /* readonly */ Type $keyType;
214-
private /* readonly */ Type $valueType;
213+
private readonly Type $keyType;
214+
private readonly Type $valueType;
215215

216216
public static function createGenericArray(): self
217217
{
@@ -249,8 +249,8 @@ public function equals(SimpleType $other): bool {
249249
}
250250

251251
class SimpleType {
252-
public /* readonly */ string $name;
253-
public /* readonly */ bool $isBuiltin;
252+
public readonly string $name;
253+
public readonly bool $isBuiltin;
254254

255255
public static function fromNode(Node $node): SimpleType {
256256
if ($node instanceof Node\Name) {
@@ -525,8 +525,8 @@ public function equals(SimpleType $other): bool {
525525
// when held by an object that is cloned
526526
class Type {
527527
/** @var SimpleType[] */
528-
public /* readonly */ array $types;
529-
public /* readonly */ bool $isIntersection;
528+
public readonly array $types;
529+
public readonly bool $isIntersection;
530530

531531
public static function fromNode(Node $node): Type {
532532
if ($node instanceof Node\UnionType || $node instanceof Node\IntersectionType) {
@@ -723,9 +723,9 @@ function ($type) { return $type->name; },
723723

724724
class ArginfoType {
725725
/** @var SimpleType[] $classTypes */
726-
public /* readonly */ array $classTypes;
726+
public readonly array $classTypes;
727727
/** @var SimpleType[] $builtinTypes */
728-
private /* readonly */ array $builtinTypes;
728+
private readonly array $builtinTypes;
729729

730730
/**
731731
* @param SimpleType[] $classTypes
@@ -761,11 +761,11 @@ class ArgInfo {
761761
public const SEND_BY_REF = "1";
762762
public const SEND_PREFER_REF = "ZEND_SEND_PREFER_REF";
763763

764-
public /* readonly */ string $name;
765-
public /* readonly */ string $sendBy;
766-
public /* readonly */ bool $isVariadic;
764+
public readonly string $name;
765+
public readonly string $sendBy;
766+
public readonly bool $isVariadic;
767767
public ?Type $type;
768-
private /* readonly */ ?Type $phpDocType;
768+
private readonly ?Type $phpDocType;
769769
public ?string $defaultValue;
770770
/** @var AttributeInfo[] */
771771
public array $attributes;
@@ -895,7 +895,7 @@ public function isUnknown(): bool
895895
}
896896

897897
class ConstName extends AbstractConstName {
898-
private /* readonly */ string $const;
898+
private readonly string $const;
899899

900900
public function __construct(?Name $namespace, string $const)
901901
{
@@ -926,8 +926,8 @@ public function getDeclarationName(): string
926926
}
927927

928928
class ClassConstName extends AbstractConstName {
929-
public /* readonly */ Name $class;
930-
private /* readonly */ string $const;
929+
public readonly Name $class;
930+
private readonly string $const;
931931

932932
public function __construct(Name $class, string $const)
933933
{
@@ -947,8 +947,8 @@ public function getDeclarationName(): string
947947
}
948948

949949
class PropertyName implements VariableLikeName {
950-
public /* readonly */ Name $class;
951-
private /* readonly */ string $property;
950+
public readonly Name $class;
951+
private readonly string $property;
952952

953953
public function __construct(Name $class, string $property)
954954
{
@@ -978,7 +978,7 @@ public function isDestructor(): bool;
978978
}
979979

980980
class FunctionName implements FunctionOrMethodName {
981-
private /* readonly */ Name $name;
981+
private readonly Name $name;
982982

983983
public function __construct(Name $name) {
984984
$this->name = $name;
@@ -1042,8 +1042,8 @@ public function isDestructor(): bool {
10421042
}
10431043

10441044
class MethodName implements FunctionOrMethodName {
1045-
public /* readonly */ Name $className;
1046-
public /* readonly */ string $methodName;
1045+
public readonly Name $className;
1046+
public readonly string $methodName;
10471047

10481048
public function __construct(Name $className, string $methodName) {
10491049
$this->className = $className;
@@ -1096,12 +1096,12 @@ class ReturnInfo {
10961096
self::REFCOUNT_N,
10971097
];
10981098

1099-
private /* readonly */ bool $byRef;
1099+
private readonly bool $byRef;
11001100
// NOT readonly - gets removed when discarding info for older PHP versions
11011101
public ?Type $type;
1102-
public /* readonly */ ?Type $phpDocType;
1103-
public /* readonly */ bool $tentativeReturnType;
1104-
public /* readonly */ string $refcount;
1102+
public readonly ?Type $phpDocType;
1103+
public readonly bool $tentativeReturnType;
1104+
public readonly string $refcount;
11051105

11061106
public function __construct(bool $byRef, ?Type $type, ?Type $phpDocType, bool $tentativeReturnType, ?string $refcount) {
11071107
$this->byRef = $byRef;
@@ -1320,19 +1320,19 @@ public function generateVersionDependentFlagCode(
13201320
}
13211321

13221322
class FuncInfo {
1323-
public /* readonly */ FunctionOrMethodName $name;
1324-
private /* readonly */ int $classFlags;
1323+
public readonly FunctionOrMethodName $name;
1324+
private readonly int $classFlags;
13251325
public int $flags;
1326-
public /* readonly */ ?string $aliasType;
1326+
public readonly ?string $aliasType;
13271327
public ?FunctionOrMethodName $alias;
1328-
private /* readonly */ bool $isDeprecated;
1328+
private readonly bool $isDeprecated;
13291329
private bool $supportsCompileTimeEval;
1330-
public /* readonly */ bool $verify;
1330+
public readonly bool $verify;
13311331
/** @var ArgInfo[] */
1332-
public /* readonly */ array $args;
1333-
public /* readonly */ ReturnInfo $return;
1334-
private /* readonly */ int $numRequiredArgs;
1335-
public /* readonly */ ?string $cond;
1332+
public readonly array $args;
1333+
public readonly ReturnInfo $return;
1334+
private readonly int $numRequiredArgs;
1335+
public readonly ?string $cond;
13361336
public bool $isUndocumentable;
13371337
private ?int $minimumPhpVersionIdCompatibility;
13381338
/** @var AttributeInfo[] */
@@ -2250,7 +2250,7 @@ public function __clone()
22502250

22512251
class EvaluatedValue
22522252
{
2253-
public /* readonly */ mixed $value;
2253+
public readonly mixed $value;
22542254
public SimpleType $type;
22552255
public Expr $expr;
22562256
public bool $isUnknownConstValue;
@@ -2439,12 +2439,12 @@ abstract class VariableLike
24392439
{
24402440
protected int $flags;
24412441
public ?Type $type;
2442-
public /* readonly */ ?Type $phpDocType;
2443-
private /* readonly */ ?string $link;
2442+
public readonly ?Type $phpDocType;
2443+
private readonly ?string $link;
24442444
protected ?int $phpVersionIdMinimumCompatibility;
24452445
/** @var AttributeInfo[] */
24462446
public array $attributes;
2447-
protected /* readonly */ ?ExposedDocComment $exposedDocComment;
2447+
protected readonly ?ExposedDocComment $exposedDocComment;
24482448

24492449
/**
24502450
* @param AttributeInfo[] $attributes
@@ -2589,14 +2589,14 @@ protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fie
25892589

25902590
class ConstInfo extends VariableLike
25912591
{
2592-
public /* readonly */ AbstractConstName $name;
2593-
public /* readonly */ Expr $value;
2592+
public readonly AbstractConstName $name;
2593+
public readonly Expr $value;
25942594
private bool $isDeprecated;
2595-
private /* readonly */ ?string $valueString;
2596-
public /* readonly */ ?string $cond;
2597-
public /* readonly */ ?string $cValue;
2598-
public /* readonly */ bool $isUndocumentable;
2599-
private /* readonly */ bool $isFileCacheAllowed;
2595+
private readonly ?string $valueString;
2596+
public readonly ?string $cond;
2597+
public readonly ?string $cValue;
2598+
public readonly bool $isUndocumentable;
2599+
private readonly bool $isFileCacheAllowed;
26002600

26012601
/**
26022602
* @param AttributeInfo[] $attributes
@@ -3118,12 +3118,12 @@ public static function getString(
31183118

31193119
class PropertyInfo extends VariableLike
31203120
{
3121-
private /* readonly */ int $classFlags;
3122-
public /* readonly */ PropertyName $name;
3123-
private /* readonly */ ?Expr $defaultValue;
3124-
private /* readonly */ ?string $defaultValueString;
3125-
private /* readonly */ bool $isDocReadonly;
3126-
private /* readonly */ bool $isVirtual;
3121+
private readonly int $classFlags;
3122+
public readonly PropertyName $name;
3123+
private readonly ?Expr $defaultValue;
3124+
private readonly ?string $defaultValueString;
3125+
private readonly bool $isDocReadonly;
3126+
private readonly bool $isVirtual;
31273127

31283128
/**
31293129
* @param AttributeInfo[] $attributes
@@ -3292,8 +3292,8 @@ protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fie
32923292
}
32933293

32943294
class EnumCaseInfo {
3295-
public /* readonly */ string $name;
3296-
private /* readonly */ ?Expr $value;
3295+
public readonly string $name;
3296+
private readonly ?Expr $value;
32973297

32983298
public function __construct(string $name, ?Expr $value) {
32993299
$this->name = $name;
@@ -3319,9 +3319,9 @@ public function getDeclaration(array $allConstInfos): string {
33193319
// Instances of AttributeInfo are immutable and do not need to be cloned
33203320
// when held by an object that is cloned
33213321
class AttributeInfo {
3322-
public /* readonly */ string $class;
3322+
public readonly string $class;
33233323
/** @var \PhpParser\Node\Arg[] */
3324-
private /* readonly */ array $args;
3324+
private readonly array $args;
33253325

33263326
/** @param \PhpParser\Node\Arg[] $args */
33273327
public function __construct(string $class, array $args) {
@@ -3412,32 +3412,32 @@ public static function createFromGroups(array $attributeGroups): array {
34123412
}
34133413

34143414
class ClassInfo {
3415-
public /* readonly */ Name $name;
3415+
public readonly Name $name;
34163416
private int $flags;
34173417
public string $type;
3418-
public /* readonly */ ?string $alias;
3419-
private /* readonly */ ?SimpleType $enumBackingType;
3420-
private /* readonly */ bool $isDeprecated;
3418+
public readonly ?string $alias;
3419+
private readonly ?SimpleType $enumBackingType;
3420+
private readonly bool $isDeprecated;
34213421
private bool $isStrictProperties;
34223422
/** @var AttributeInfo[] */
34233423
private array $attributes;
34243424
private ?ExposedDocComment $exposedDocComment;
34253425
private bool $isNotSerializable;
34263426
/** @var Name[] */
3427-
private /* readonly */ array $extends;
3427+
private readonly array $extends;
34283428
/** @var Name[] */
3429-
private /* readonly */ array $implements;
3429+
private readonly array $implements;
34303430
/** @var ConstInfo[] */
3431-
public /* readonly */ array $constInfos;
3431+
public readonly array $constInfos;
34323432
/** @var PropertyInfo[] */
3433-
private /* readonly */ array $propertyInfos;
3433+
private readonly array $propertyInfos;
34343434
/** @var FuncInfo[] */
34353435
public array $funcInfos;
34363436
/** @var EnumCaseInfo[] */
3437-
private /* readonly */ array $enumCaseInfos;
3438-
public /* readonly */ ?string $cond;
3437+
private readonly array $enumCaseInfos;
3438+
public readonly ?string $cond;
34393439
public ?int $phpVersionIdMinimumCompatibility;
3440-
public /* readonly */ bool $isUndocumentable;
3440+
public readonly bool $isUndocumentable;
34413441

34423442
/**
34433443
* @param AttributeInfo[] $attributes
@@ -4736,8 +4736,8 @@ function (FuncInfo $funcInfo) use (&$generatedFunctionDeclarations) {
47364736
}
47374737

47384738
class DocCommentTag {
4739-
public /* readonly */ string $name;
4740-
public /* readonly */ ?string $value;
4739+
public readonly string $name;
4740+
public readonly ?string $value;
47414741

47424742
public function __construct(string $name, ?string $value) {
47434743
$this->name = $name;
@@ -4828,7 +4828,7 @@ public static function makeTagMap(array $tags): array {
48284828
// Instances of ExposedDocComment are immutable and do not need to be cloned
48294829
// when held by an object that is cloned
48304830
class ExposedDocComment {
4831-
private /* readonly */ string $docComment;
4831+
private readonly string $docComment;
48324832

48334833
public function __construct(string $docComment) {
48344834
$this->docComment = $docComment;
@@ -4869,7 +4869,7 @@ public static function extractExposedComment(array $comments): ?ExposedDocCommen
48694869
// Instances of FramelessFunctionInfo are immutable and do not need to be cloned
48704870
// when held by an object that is cloned
48714871
class FramelessFunctionInfo {
4872-
public /* readonly */ int $arity;
4872+
public readonly int $arity;
48734873

48744874
public function __construct(string $json) {
48754875
// FIXME: Should have some validation

0 commit comments

Comments
 (0)