@@ -689,7 +689,7 @@ public function toArginfoType(): ArginfoType {
689
689
$ classTypes [] = $ type ;
690
690
}
691
691
}
692
- return new ArginfoType ($ classTypes , $ builtinTypes );
692
+ return new ArginfoType ($ classTypes , $ builtinTypes, $ this -> isIntersection );
693
693
}
694
694
695
695
public function toOptimizerTypeMask (): string {
@@ -784,22 +784,25 @@ class ArginfoType {
784
784
785
785
/** @var SimpleType[] $builtinTypes */
786
786
private $ builtinTypes ;
787
+ private bool $ isIntersection ;
787
788
788
789
/**
789
790
* @param SimpleType[] $classTypes
790
791
* @param SimpleType[] $builtinTypes
791
792
*/
792
- public function __construct (array $ classTypes , array $ builtinTypes ) {
793
+ public function __construct (array $ classTypes , array $ builtinTypes, bool $ isIntersection ) {
793
794
$ this ->classTypes = $ classTypes ;
794
795
$ this ->builtinTypes = $ builtinTypes ;
796
+ $ this ->isIntersection = $ isIntersection ;
795
797
}
796
798
797
799
public function hasClassType (): bool {
798
800
return !empty ($ this ->classTypes );
799
801
}
800
802
801
803
public function toClassTypeString (): string {
802
- return implode ('| ' , array_map (function (SimpleType $ type ) {
804
+ $ separator = $ this ->isIntersection ? '& ' : '| ' ;
805
+ return implode ($ separator , array_map (function (SimpleType $ type ) {
803
806
return $ type ->toEscapedName ();
804
807
}, $ this ->classTypes ));
805
808
}
@@ -808,6 +811,7 @@ public function toTypeMask(): string {
808
811
if (empty ($ this ->builtinTypes )) {
809
812
return '0 ' ;
810
813
}
814
+ /* Intersection types cannot happen with built-in types */
811
815
return implode ('| ' , array_map (function (SimpleType $ type ) {
812
816
return $ type ->toTypeMask ();
813
817
}, $ this ->builtinTypes ));
0 commit comments