Skip to content

Commit 28cac94

Browse files
committed
Fix registration of readonly classes
Properties of readonly classes should be implicitly marked as readonly.
1 parent 7b2ca07 commit 28cac94

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

build/gen_stub.php

+8
Original file line numberDiff line numberDiff line change
@@ -2888,6 +2888,7 @@ protected function addModifiersToFieldSynopsis(DOMDocument $doc, DOMElement $fie
28882888

28892889
class PropertyInfo extends VariableLike
28902890
{
2891+
public int $classFlags;
28912892
public PropertyName $name;
28922893
public ?Expr $defaultValue;
28932894
public ?string $defaultValueString;
@@ -2898,6 +2899,7 @@ class PropertyInfo extends VariableLike
28982899
*/
28992900
public function __construct(
29002901
PropertyName $name,
2902+
int $classFlags,
29012903
int $flags,
29022904
?Type $type,
29032905
?Type $phpDocType,
@@ -2910,6 +2912,7 @@ public function __construct(
29102912
?ExposedDocComment $exposedDocComment
29112913
) {
29122914
$this->name = $name;
2915+
$this->classFlags = $classFlags;
29132916
$this->defaultValue = $defaultValue;
29142917
$this->defaultValueString = $defaultValueString;
29152918
$this->isDocReadonly = $isDocReadonly;
@@ -3024,6 +3027,8 @@ protected function getFlagsByPhpVersion(): array
30243027

30253028
if ($this->flags & Modifiers::READONLY) {
30263029
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_READONLY", PHP_81_VERSION_ID);
3030+
} elseif ($this->classFlags & Modifiers::READONLY) {
3031+
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_READONLY", PHP_82_VERSION_ID);
30273032
}
30283033

30293034
return $flags;
@@ -4383,6 +4388,7 @@ function parseConstLike(
43834388
*/
43844389
function parseProperty(
43854390
Name $class,
4391+
int $classFlags,
43864392
int $flags,
43874393
Stmt\PropertyProperty $property,
43884394
?Node $type,
@@ -4425,6 +4431,7 @@ function parseProperty(
44254431

44264432
return new PropertyInfo(
44274433
new PropertyName($class, $property->name->__toString()),
4434+
$classFlags,
44284435
$flags,
44294436
$propertyType,
44304437
$phpDocType ? Type::fromString($phpDocType) : null,
@@ -4713,6 +4720,7 @@ function handleStatements(FileInfo $fileInfo, array $stmts, PrettyPrinterAbstrac
47134720
foreach ($classStmt->props as $property) {
47144721
$propertyInfos[] = parseProperty(
47154722
$className,
4723+
$classFlags,
47164724
$classStmt->flags,
47174725
$property,
47184726
$classStmt->type,

0 commit comments

Comments
 (0)