Skip to content

Commit 155613d

Browse files
committed
Add dynamic properties to stubs for ext/dom classes
1 parent 5f21062 commit 155613d

File tree

3 files changed

+470
-3
lines changed

3 files changed

+470
-3
lines changed

build/gen_stub.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,20 +1000,30 @@ class PropertyInfo
10001000
public $type;
10011001
/** @var Expr|null */
10021002
public $defaultValue;
1003+
/** @var bool */
1004+
public $dynamic;
1005+
/** @var bool */
1006+
public $readonly;
10031007

1004-
public function __construct(PropertyName $name, int $flags, ?Type $type, ?Expr $defaultValue)
1008+
public function __construct(PropertyName $name, int $flags, ?Type $type, ?Expr $defaultValue, bool $dynamic, bool $readonly)
10051009
{
10061010
$this->name = $name;
10071011
$this->flags = $flags;
10081012
$this->type = $type;
10091013
$this->defaultValue = $defaultValue;
1014+
$this->dynamic = $dynamic;
1015+
$this->readonly = $readonly;
10101016
}
10111017

10121018
public function discardInfoForOldPhpVersions(): void {
10131019
$this->type = null;
10141020
}
10151021

10161022
public function getDeclaration(): string {
1023+
if ($this->dynamic) {
1024+
return "";
1025+
}
1026+
10171027
$code = "\n";
10181028

10191029
$propertyName = $this->name->property;
@@ -1543,12 +1553,18 @@ function parseProperty(
15431553
?DocComment $comment
15441554
): PropertyInfo {
15451555
$docType = false;
1556+
$dynamic = false;
1557+
$readonly = false;
15461558

15471559
if ($comment) {
15481560
$tags = parseDocComment($comment);
15491561
foreach ($tags as $tag) {
15501562
if ($tag->name === 'var') {
15511563
$docType = true;
1564+
} else if ($tag->name === 'dynamic') {
1565+
$dynamic = true;
1566+
} else if ($tag->name === 'readonly') {
1567+
$readonly = true;
15521568
}
15531569
}
15541570
}
@@ -1573,7 +1589,9 @@ function parseProperty(
15731589
new PropertyName($class, $property->name->__toString()),
15741590
$flags,
15751591
$propertyType,
1576-
$property->default
1592+
$property->default,
1593+
$dynamic,
1594+
$readonly
15771595
);
15781596
}
15791597

0 commit comments

Comments
 (0)