File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -544,6 +544,11 @@ private static function unionWithSubtractedType(
544
544
$ subtractedType = $ type ->getSubtractedType () === null
545
545
? $ subtractedType
546
546
: self ::union ($ type ->getSubtractedType (), $ subtractedType );
547
+
548
+ $ subtractedType = self ::intersect (
549
+ $ type ->getTypeWithoutSubtractedType (),
550
+ $ subtractedType ,
551
+ );
547
552
if ($ subtractedType instanceof NeverType) {
548
553
$ subtractedType = null ;
549
554
}
Original file line number Diff line number Diff line change @@ -4127,6 +4127,22 @@ public static function dataIntersect(): iterable
4127
4127
IntersectionType::class,
4128
4128
'lowercase-string&uppercase-string ' ,
4129
4129
],
4130
+ [
4131
+ [
4132
+ new ObjectType (DateTime::class),
4133
+ new MixedType (subtractedType: new NullType ()),
4134
+ ],
4135
+ ObjectType::class,
4136
+ 'DateTime ' ,
4137
+ ],
4138
+ [
4139
+ [
4140
+ new ObjectWithoutClassType (),
4141
+ new MixedType (subtractedType: new NullType ()),
4142
+ ],
4143
+ ObjectWithoutClassType::class,
4144
+ 'object ' ,
4145
+ ],
4130
4146
];
4131
4147
4132
4148
if (PHP_VERSION_ID < 80100 ) {
You can’t perform that action at this time.
0 commit comments