Skip to content

Commit 72d3f0c

Browse files
committed
Treat ref as a normal simple type
1 parent 3b2f52e commit 72d3f0c

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

build/gen_stub.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public static function fromString(string $typeString): SimpleType
205205
case "mixed":
206206
case "static":
207207
case "never":
208+
case "ref":
208209
return new SimpleType(strtolower($typeString), true);
209210
case "array":
210211
return ArrayType::createGenericArray();
@@ -358,6 +359,8 @@ public function toOptimizerTypeMaskForArrayValue(): string {
358359
return "MAY_BE_ARRAY_OF_RESOURCE";
359360
case "mixed":
360361
return "MAY_BE_ARRAY_OF_ANY";
362+
case "ref":
363+
return "MAY_BE_ARRAY_OF_REF";
361364
default:
362365
throw new Exception("Type $this->name cannot be an array value");
363366
}
@@ -397,9 +400,6 @@ class Type {
397400
/** @var SimpleType[] */
398401
public $types;
399402

400-
/** @var bool */
401-
public $isReferenceSupported;
402-
403403
public static function fromNode(Node $node): Type {
404404
if ($node instanceof Node\UnionType) {
405405
return new Type(array_map(['SimpleType', 'fromNode'], $node->types), false);
@@ -423,7 +423,6 @@ public static function fromString(string $typeString): self {
423423
$simpleTypes = [];
424424
$simpleTypeOffset = 0;
425425
$inArray = false;
426-
$referenceSupported = false;
427426

428427
$typeStringLength = strlen($typeString);
429428
for ($i = 0; $i < $typeStringLength; $i++) {
@@ -446,25 +445,20 @@ public static function fromString(string $typeString): self {
446445
if ($char === "|") {
447446
$simpleTypeName = trim(substr($typeString, $simpleTypeOffset, $i - $simpleTypeOffset));
448447

449-
if (strtolower($simpleTypeName) === "ref") {
450-
$referenceSupported = true;
451-
} else {
452-
$simpleTypes[] = SimpleType::fromString($simpleTypeName);
453-
}
448+
$simpleTypes[] = SimpleType::fromString($simpleTypeName);
454449

455450
$simpleTypeOffset = $i + 1;
456451
}
457452
}
458453

459-
return new Type($simpleTypes, $referenceSupported);
454+
return new Type($simpleTypes);
460455
}
461456

462457
/**
463458
* @param SimpleType[] $types
464459
*/
465-
private function __construct(array $types, bool $isReferenceSupported) {
460+
private function __construct(array $types) {
466461
$this->types = $types;
467-
$this->isReferenceSupported = $isReferenceSupported;
468462
}
469463

470464
public function isScalar(): bool {
@@ -547,10 +541,6 @@ public function toOptimizerTypeMaskForArrayValue(): string {
547541
$typeMasks[] = $type->toOptimizerTypeMaskForArrayValue();
548542
}
549543

550-
if ($this->isReferenceSupported) {
551-
$typeMasks[] = "MAY_BE_ARRAY_OF_REF";
552-
}
553-
554544
return implode("|", $typeMasks);
555545
}
556546

@@ -592,10 +582,6 @@ public static function equals(?Type $a, ?Type $b): bool {
592582
}
593583
}
594584

595-
if ($a->isReferenceSupported !== $b->isReferenceSupported) {
596-
return false;
597-
}
598-
599585
return true;
600586
}
601587

0 commit comments

Comments
 (0)