@@ -199,6 +199,7 @@ public static function fromString(string $typeString): SimpleType
199
199
case "mixed " :
200
200
case "static " :
201
201
case "never " :
202
+ case "ref " :
202
203
return new SimpleType (strtolower ($ typeString ), true );
203
204
case "array " :
204
205
return ArrayType::createGenericArray ();
@@ -352,6 +353,8 @@ public function toOptimizerTypeMaskForArrayValue(): string {
352
353
return "MAY_BE_ARRAY_OF_RESOURCE " ;
353
354
case "mixed " :
354
355
return "MAY_BE_ARRAY_OF_ANY " ;
356
+ case "ref " :
357
+ return "MAY_BE_ARRAY_OF_REF " ;
355
358
default :
356
359
throw new Exception ("Type $ this ->name cannot be an array value " );
357
360
}
@@ -391,9 +394,6 @@ class Type {
391
394
/** @var SimpleType[] */
392
395
public $ types ;
393
396
394
- /** @var bool */
395
- public $ isReferenceSupported ;
396
-
397
397
public static function fromNode (Node $ node ): Type {
398
398
if ($ node instanceof Node \UnionType) {
399
399
return new Type (array_map (['SimpleType ' , 'fromNode ' ], $ node ->types ), false );
@@ -417,7 +417,6 @@ public static function fromString(string $typeString): self {
417
417
$ simpleTypes = [];
418
418
$ simpleTypeOffset = 0 ;
419
419
$ inArray = false ;
420
- $ referenceSupported = false ;
421
420
422
421
$ typeStringLength = strlen ($ typeString );
423
422
for ($ i = 0 ; $ i < $ typeStringLength ; $ i ++) {
@@ -440,25 +439,20 @@ public static function fromString(string $typeString): self {
440
439
if ($ char === "| " ) {
441
440
$ simpleTypeName = trim (substr ($ typeString , $ simpleTypeOffset , $ i - $ simpleTypeOffset ));
442
441
443
- if (strtolower ($ simpleTypeName ) === "ref " ) {
444
- $ referenceSupported = true ;
445
- } else {
446
- $ simpleTypes [] = SimpleType::fromString ($ simpleTypeName );
447
- }
442
+ $ simpleTypes [] = SimpleType::fromString ($ simpleTypeName );
448
443
449
444
$ simpleTypeOffset = $ i + 1 ;
450
445
}
451
446
}
452
447
453
- return new Type ($ simpleTypes, $ referenceSupported );
448
+ return new Type ($ simpleTypes );
454
449
}
455
450
456
451
/**
457
452
* @param SimpleType[] $types
458
453
*/
459
- private function __construct (array $ types, bool $ isReferenceSupported ) {
454
+ private function __construct (array $ types ) {
460
455
$ this ->types = $ types ;
461
- $ this ->isReferenceSupported = $ isReferenceSupported ;
462
456
}
463
457
464
458
public function isScalar (): bool {
@@ -541,10 +535,6 @@ public function toOptimizerTypeMaskForArrayValue(): string {
541
535
$ typeMasks [] = $ type ->toOptimizerTypeMaskForArrayValue ();
542
536
}
543
537
544
- if ($ this ->isReferenceSupported ) {
545
- $ typeMasks [] = "MAY_BE_ARRAY_OF_REF " ;
546
- }
547
-
548
538
return implode ("| " , $ typeMasks );
549
539
}
550
540
@@ -586,10 +576,6 @@ public static function equals(?Type $a, ?Type $b): bool {
586
576
}
587
577
}
588
578
589
- if ($ a ->isReferenceSupported !== $ b ->isReferenceSupported ) {
590
- return false ;
591
- }
592
-
593
579
return true ;
594
580
}
595
581
0 commit comments