Skip to content

Commit 950345b

Browse files
committed
Treat ref as a normal simple type
1 parent 5d27dcb commit 950345b

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
@@ -199,6 +199,7 @@ public static function fromString(string $typeString): SimpleType
199199
case "mixed":
200200
case "static":
201201
case "never":
202+
case "ref":
202203
return new SimpleType(strtolower($typeString), true);
203204
case "array":
204205
return ArrayType::createGenericArray();
@@ -352,6 +353,8 @@ public function toOptimizerTypeMaskForArrayValue(): string {
352353
return "MAY_BE_ARRAY_OF_RESOURCE";
353354
case "mixed":
354355
return "MAY_BE_ARRAY_OF_ANY";
356+
case "ref":
357+
return "MAY_BE_ARRAY_OF_REF";
355358
default:
356359
throw new Exception("Type $this->name cannot be an array value");
357360
}
@@ -391,9 +394,6 @@ class Type {
391394
/** @var SimpleType[] */
392395
public $types;
393396

394-
/** @var bool */
395-
public $isReferenceSupported;
396-
397397
public static function fromNode(Node $node): Type {
398398
if ($node instanceof Node\UnionType) {
399399
return new Type(array_map(['SimpleType', 'fromNode'], $node->types), false);
@@ -417,7 +417,6 @@ public static function fromString(string $typeString): self {
417417
$simpleTypes = [];
418418
$simpleTypeOffset = 0;
419419
$inArray = false;
420-
$referenceSupported = false;
421420

422421
$typeStringLength = strlen($typeString);
423422
for ($i = 0; $i < $typeStringLength; $i++) {
@@ -440,25 +439,20 @@ public static function fromString(string $typeString): self {
440439
if ($char === "|") {
441440
$simpleTypeName = trim(substr($typeString, $simpleTypeOffset, $i - $simpleTypeOffset));
442441

443-
if (strtolower($simpleTypeName) === "ref") {
444-
$referenceSupported = true;
445-
} else {
446-
$simpleTypes[] = SimpleType::fromString($simpleTypeName);
447-
}
442+
$simpleTypes[] = SimpleType::fromString($simpleTypeName);
448443

449444
$simpleTypeOffset = $i + 1;
450445
}
451446
}
452447

453-
return new Type($simpleTypes, $referenceSupported);
448+
return new Type($simpleTypes);
454449
}
455450

456451
/**
457452
* @param SimpleType[] $types
458453
*/
459-
private function __construct(array $types, bool $isReferenceSupported) {
454+
private function __construct(array $types) {
460455
$this->types = $types;
461-
$this->isReferenceSupported = $isReferenceSupported;
462456
}
463457

464458
public function isScalar(): bool {
@@ -541,10 +535,6 @@ public function toOptimizerTypeMaskForArrayValue(): string {
541535
$typeMasks[] = $type->toOptimizerTypeMaskForArrayValue();
542536
}
543537

544-
if ($this->isReferenceSupported) {
545-
$typeMasks[] = "MAY_BE_ARRAY_OF_REF";
546-
}
547-
548538
return implode("|", $typeMasks);
549539
}
550540

@@ -586,10 +576,6 @@ public static function equals(?Type $a, ?Type $b): bool {
586576
}
587577
}
588578

589-
if ($a->isReferenceSupported !== $b->isReferenceSupported) {
590-
return false;
591-
}
592-
593579
return true;
594580
}
595581

0 commit comments

Comments
 (0)