Skip to content

Commit

Permalink
gen_stub: document a bunch of properties as read-only
Browse files Browse the repository at this point in the history
In the hopes that it will be clearer that some of the custom clone handling can
be removed the way it was for `ExposedDocComment`, instances of which were
immutable, document a bunch of properties of other classes as read-only.
  • Loading branch information
DanielEScherzer authored and kocsismate committed Dec 28, 2024
1 parent 3817a71 commit 69ff948
Showing 1 changed file with 63 additions and 63 deletions.
126 changes: 63 additions & 63 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ class Context {
}

class ArrayType extends SimpleType {
public Type $keyType;
public Type $valueType;
public /* readonly */ Type $keyType;
public /* readonly */ Type $valueType;

public static function createGenericArray(): self
{
Expand Down Expand Up @@ -222,8 +222,8 @@ public function equals(SimpleType $other): bool {
}

class SimpleType {
public string $name;
public bool $isBuiltin;
public /* readonly */ string $name;
public /* readonly */ bool $isBuiltin;

public static function fromNode(Node $node): SimpleType {
if ($node instanceof Node\Name) {
Expand Down Expand Up @@ -524,8 +524,8 @@ public function equals(SimpleType $other): bool {

class Type {
/** @var SimpleType[] */
public array $types;
public bool $isIntersection;
public /* readonly */ array $types;
public /* readonly */ bool $isIntersection;

public static function fromNode(Node $node): Type {
if ($node instanceof Node\UnionType || $node instanceof Node\IntersectionType) {
Expand Down Expand Up @@ -736,9 +736,9 @@ function ($type) { return $type->name; },

class ArginfoType {
/** @var SimpleType[] $classTypes */
public array $classTypes;
public /* readonly */ array $classTypes;
/** @var SimpleType[] $builtinTypes */
private array $builtinTypes;
private /* readonly */ array $builtinTypes;

/**
* @param SimpleType[] $classTypes
Expand Down Expand Up @@ -774,11 +774,11 @@ class ArgInfo {
const SEND_BY_REF = "1";
const SEND_PREFER_REF = "ZEND_SEND_PREFER_REF";

public string $name;
public string $sendBy;
public bool $isVariadic;
public /* readonly */ string $name;
public /* readonly */ string $sendBy;
public /* readonly */ bool $isVariadic;
public ?Type $type;
public ?Type $phpDocType;
public /* readonly */ ?Type $phpDocType;
public ?string $defaultValue;
/** @var AttributeInfo[] */
public array $attributes;
Expand Down Expand Up @@ -879,7 +879,7 @@ public function isUnknown(): bool
}

class ConstName extends AbstractConstName {
public string $const;
public /* readonly */ string $const;

public function __construct(?Name $namespace, string $const)
{
Expand Down Expand Up @@ -915,8 +915,8 @@ public function getDeclarationName(): string
}

class ClassConstName extends AbstractConstName {
public Name $class;
public string $const;
public /* readonly */ Name $class;
public /* readonly */ string $const;

public function __construct(Name $class, string $const)
{
Expand All @@ -941,8 +941,8 @@ public function getDeclarationName(): string
}

class PropertyName implements VariableLikeName {
public Name $class;
public string $property;
public /* readonly */ Name $class;
public /* readonly */ string $property;

public function __construct(Name $class, string $property)
{
Expand Down Expand Up @@ -973,7 +973,7 @@ public function isDestructor(): bool;
}

class FunctionName implements FunctionOrMethodName {
private Name $name;
private /* readonly */ Name $name;

public function __construct(Name $name) {
$this->name = $name;
Expand Down Expand Up @@ -1041,8 +1041,8 @@ public function isDestructor(): bool {
}

class MethodName implements FunctionOrMethodName {
public Name $className;
public string $methodName;
public /* readonly */ Name $className;
public /* readonly */ string $methodName;

public function __construct(Name $className, string $methodName) {
$this->className = $className;
Expand Down Expand Up @@ -1099,11 +1099,12 @@ class ReturnInfo {
self::REFCOUNT_N,
];

public bool $byRef;
public /* readonly */ bool $byRef;
// NOT readonly - gets removed when discarding info for older PHP versions
public ?Type $type;
public ?Type $phpDocType;
public bool $tentativeReturnType;
public string $refcount;
public /* readonly */ ?Type $phpDocType;
public /* readonly */ bool $tentativeReturnType;
public /* readonly */ string $refcount;

public function __construct(bool $byRef, ?Type $type, ?Type $phpDocType, bool $tentativeReturnType, ?string $refcount) {
$this->byRef = $byRef;
Expand Down Expand Up @@ -1148,19 +1149,19 @@ private function setRefcount(?string $refcount): void
}

class FuncInfo {
public FunctionOrMethodName $name;
public int $classFlags;
public /* readonly */ FunctionOrMethodName $name;
public /* readonly */ int $classFlags;
public int $flags;
public ?string $aliasType;
public /* readonly */ ?string $aliasType;
public ?FunctionOrMethodName $alias;
public bool $isDeprecated;
public /* readonly */ bool $isDeprecated;
public bool $supportsCompileTimeEval;
public bool $verify;
public /* readonly */ bool $verify;
/** @var ArgInfo[] */
public array $args;
public ReturnInfo $return;
public int $numRequiredArgs;
public ?string $cond;
public /* readonly */ array $args;
public /* readonly */ ReturnInfo $return;
public /* readonly */ int $numRequiredArgs;
public /* readonly */ ?string $cond;
public bool $isUndocumentable;
public ?int $minimumPhpVersionIdCompatibility;
/** @var AttributeInfo[] */
Expand Down Expand Up @@ -2100,8 +2101,7 @@ public function __clone()

class EvaluatedValue
{
/** @var mixed */
public $value;
public /* readonly */ mixed $value;
public SimpleType $type;
public Expr $expr;
public bool $isUnknownConstValue;
Expand Down Expand Up @@ -2284,12 +2284,12 @@ abstract class VariableLike
{
public int $flags;
public ?Type $type;
public ?Type $phpDocType;
public ?string $link;
public /* readonly */ ?Type $phpDocType;
public /* readonly */ ?string $link;
public ?int $phpVersionIdMinimumCompatibility;
/** @var AttributeInfo[] */
public array $attributes;
public ?ExposedDocComment $exposedDocComment;
public /* readonly */ ?ExposedDocComment $exposedDocComment;

/**
* @var AttributeInfo[] $attributes
Expand Down Expand Up @@ -2464,11 +2464,11 @@ protected function addFlagForVersionsAbove(array $flags, string $flag, int $mini

class ConstInfo extends VariableLike
{
public ConstOrClassConstName $name;
public Expr $value;
public /* readonly */ ConstOrClassConstName $name;
public /* readonly */ Expr $value;
public bool $isDeprecated;
public ?string $valueString;
public ?string $cond;
public /* readonly */ ?string $cond;
public ?string $cValue;
public bool $isUndocumentable;
public bool $isFileCacheAllowed;
Expand Down Expand Up @@ -2824,12 +2824,12 @@ protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fie

class PropertyInfo extends VariableLike
{
public int $classFlags;
public PropertyName $name;
public ?Expr $defaultValue;
public ?string $defaultValueString;
public bool $isDocReadonly;
public bool $isVirtual;
public /* readonly */ int $classFlags;
public /* readonly */ PropertyName $name;
public /* readonly */ ?Expr $defaultValue;
public /* readonly */ ?string $defaultValueString;
public /* readonly */ bool $isDocReadonly;
public /* readonly */ bool $isVirtual;

// Map possible variable names to the known string constant, see
// ZEND_KNOWN_STRINGS
Expand Down Expand Up @@ -3143,8 +3143,8 @@ public function __clone()
}

class EnumCaseInfo {
public string $name;
public ?Expr $value;
public /* readonly */ string $name;
public /* readonly */ ?Expr $value;

public function __construct(string $name, ?Expr $value) {
$this->name = $name;
Expand All @@ -3169,9 +3169,9 @@ public function getDeclaration(array $allConstInfos): string {
}

class AttributeInfo {
public string $class;
public /* readonly */ string $class;
/** @var \PhpParser\Node\Arg[] */
public array $args;
public /* readonly */ array $args;

/** @param \PhpParser\Node\Arg[] $args */
public function __construct(string $class, array $args) {
Expand Down Expand Up @@ -3222,30 +3222,30 @@ public function generateCode(string $invocation, string $nameSuffix, array $allC
}

class ClassInfo {
public Name $name;
public /* readonly */ Name $name;
public int $flags;
public string $type;
public ?string $alias;
public ?SimpleType $enumBackingType;
public bool $isDeprecated;
public /* readonly */ ?string $alias;
public /* readonly */ ?SimpleType $enumBackingType;
public /* readonly */ bool $isDeprecated;
public bool $isStrictProperties;
/** @var AttributeInfo[] */
public array $attributes;
public ?ExposedDocComment $exposedDocComment;
public bool $isNotSerializable;
/** @var Name[] */
public array $extends;
public /* readonly */ array $extends;
/** @var Name[] */
public array $implements;
public /* readonly */ array $implements;
/** @var ConstInfo[] */
public array $constInfos;
public /* readonly */ array $constInfos;
/** @var PropertyInfo[] */
public array $propertyInfos;
public /* readonly */ array $propertyInfos;
/** @var FuncInfo[] */
public array $funcInfos;
/** @var EnumCaseInfo[] */
public array $enumCaseInfos;
public ?string $cond;
public /* readonly */ array $enumCaseInfos;
public /* readonly */ ?string $cond;
public ?int $phpVersionIdMinimumCompatibility;
public bool $isUndocumentable;

Expand Down Expand Up @@ -4119,8 +4119,8 @@ public function shouldGenerateLegacyArginfo(): bool {
}

class DocCommentTag {
public string $name;
public ?string $value;
public /* readonly */ string $name;
public /* readonly */ ?string $value;

public function __construct(string $name, ?string $value) {
$this->name = $name;
Expand Down

0 comments on commit 69ff948

Please sign in to comment.