@@ -374,7 +374,7 @@ public function walkFunction($function): string
374
374
new FloatType ()
375
375
);
376
376
377
- if (TypeCombinator:: containsNull ($ exprType )) {
377
+ if ($ this -> canBeNull ($ exprType )) {
378
378
$ type = TypeCombinator::addNull ($ type );
379
379
}
380
380
@@ -386,7 +386,7 @@ public function walkFunction($function): string
386
386
$ secondExprType = $ this ->unmarshalType ($ function ->secondArithmetic ->dispatch ($ this ));
387
387
388
388
$ type = IntegerRangeType::fromInterval (0 , null );
389
- if (TypeCombinator:: containsNull ($ firstExprType ) || TypeCombinator:: containsNull ($ secondExprType )) {
389
+ if ($ this -> canBeNull ($ firstExprType ) || $ this -> canBeNull ($ secondExprType )) {
390
390
$ type = TypeCombinator::addNull ($ type );
391
391
}
392
392
@@ -397,7 +397,7 @@ public function walkFunction($function): string
397
397
398
398
foreach ($ function ->concatExpressions as $ expr ) {
399
399
$ type = $ this ->unmarshalType ($ expr ->dispatch ($ this ));
400
- $ hasNull = $ hasNull || TypeCombinator:: containsNull ($ type );
400
+ $ hasNull = $ hasNull || $ this -> canBeNull ($ type );
401
401
}
402
402
403
403
$ type = new StringType ();
@@ -418,7 +418,7 @@ public function walkFunction($function): string
418
418
$ intervalExprType = $ this ->unmarshalType ($ function ->intervalExpression ->dispatch ($ this ));
419
419
420
420
$ type = new StringType ();
421
- if (TypeCombinator:: containsNull ($ dateExprType ) || TypeCombinator:: containsNull ($ intervalExprType )) {
421
+ if ($ this -> canBeNull ($ dateExprType ) || $ this -> canBeNull ($ intervalExprType )) {
422
422
$ type = TypeCombinator::addNull ($ type );
423
423
}
424
424
@@ -432,7 +432,7 @@ public function walkFunction($function): string
432
432
new IntegerType (),
433
433
new FloatType ()
434
434
);
435
- if (TypeCombinator:: containsNull ($ date1ExprType ) || TypeCombinator:: containsNull ($ date2ExprType )) {
435
+ if ($ this -> canBeNull ($ date1ExprType ) || $ this -> canBeNull ($ date2ExprType )) {
436
436
$ type = TypeCombinator::addNull ($ type );
437
437
}
438
438
@@ -442,7 +442,7 @@ public function walkFunction($function): string
442
442
$ stringPrimaryType = $ this ->unmarshalType ($ function ->stringPrimary ->dispatch ($ this ));
443
443
444
444
$ type = IntegerRangeType::fromInterval (0 , null );
445
- if (TypeCombinator:: containsNull ($ stringPrimaryType )) {
445
+ if ($ this -> canBeNull ($ stringPrimaryType )) {
446
446
$ type = TypeCombinator::addNull ($ type );
447
447
}
448
448
@@ -453,7 +453,7 @@ public function walkFunction($function): string
453
453
$ secondExprType = $ this ->unmarshalType ($ this ->walkStringPrimary ($ function ->secondStringPrimary ));
454
454
455
455
$ type = IntegerRangeType::fromInterval (0 , null );
456
- if (TypeCombinator:: containsNull ($ firstExprType ) || TypeCombinator:: containsNull ($ secondExprType )) {
456
+ if ($ this -> canBeNull ($ firstExprType ) || $ this -> canBeNull ($ secondExprType )) {
457
457
$ type = TypeCombinator::addNull ($ type );
458
458
}
459
459
@@ -465,7 +465,7 @@ public function walkFunction($function): string
465
465
$ stringPrimaryType = $ this ->unmarshalType ($ function ->stringPrimary ->dispatch ($ this ));
466
466
467
467
$ type = new StringType ();
468
- if (TypeCombinator:: containsNull ($ stringPrimaryType )) {
468
+ if ($ this -> canBeNull ($ stringPrimaryType )) {
469
469
$ type = TypeCombinator::addNull ($ type );
470
470
}
471
471
@@ -476,7 +476,7 @@ public function walkFunction($function): string
476
476
$ secondExprType = $ this ->unmarshalType ($ this ->walkSimpleArithmeticExpression ($ function ->secondSimpleArithmeticExpression ));
477
477
478
478
$ type = IntegerRangeType::fromInterval (0 , null );
479
- if (TypeCombinator:: containsNull ($ firstExprType ) || TypeCombinator:: containsNull ($ secondExprType )) {
479
+ if ($ this -> canBeNull ($ firstExprType ) || $ this -> canBeNull ($ secondExprType )) {
480
480
$ type = TypeCombinator::addNull ($ type );
481
481
}
482
482
@@ -491,7 +491,7 @@ public function walkFunction($function): string
491
491
$ exprType = $ this ->unmarshalType ($ this ->walkSimpleArithmeticExpression ($ function ->simpleArithmeticExpression ));
492
492
493
493
$ type = new FloatType ();
494
- if (TypeCombinator:: containsNull ($ exprType )) {
494
+ if ($ this -> canBeNull ($ exprType )) {
495
495
$ type = TypeCombinator::addNull ($ type );
496
496
}
497
497
@@ -508,7 +508,7 @@ public function walkFunction($function): string
508
508
}
509
509
510
510
$ type = new StringType ();
511
- if (TypeCombinator:: containsNull ($ stringType ) || TypeCombinator:: containsNull ($ firstExprType ) || TypeCombinator:: containsNull ($ secondExprType )) {
511
+ if ($ this -> canBeNull ($ stringType ) || $ this -> canBeNull ($ firstExprType ) || $ this -> canBeNull ($ secondExprType )) {
512
512
$ type = TypeCombinator::addNull ($ type );
513
513
}
514
514
@@ -639,7 +639,7 @@ public function walkCoalesceExpression($coalesceExpression): string
639
639
}
640
640
641
641
$ type = $ this ->unmarshalType ($ expression ->dispatch ($ this ));
642
- $ allTypesContainNull = $ allTypesContainNull && TypeCombinator:: containsNull ($ type );
642
+ $ allTypesContainNull = $ allTypesContainNull && $ this -> canBeNull ($ type );
643
643
644
644
$ expressionTypes [] = $ type ;
645
645
}
@@ -1399,6 +1399,11 @@ private function resolveDatabaseInternalType(string $typeName, ?string $enumType
1399
1399
return $ type ;
1400
1400
}
1401
1401
1402
+ private function canBeNull (Type $ type ): bool
1403
+ {
1404
+ return !$ type ->accepts (new NullType (), true )->no ();
1405
+ }
1406
+
1402
1407
private function toNumericOrNull (Type $ type ): Type
1403
1408
{
1404
1409
return TypeTraverser::map ($ type , static function (Type $ type , callable $ traverse ): Type {
0 commit comments