@@ -374,7 +374,7 @@ public function walkFunction($function): string
374374 new FloatType ()
375375 );
376376
377- if (TypeCombinator:: containsNull ($ exprType )) {
377+ if ($ this -> canBeNull ($ exprType )) {
378378 $ type = TypeCombinator::addNull ($ type );
379379 }
380380
@@ -386,7 +386,7 @@ public function walkFunction($function): string
386386 $ secondExprType = $ this ->unmarshalType ($ function ->secondArithmetic ->dispatch ($ this ));
387387
388388 $ type = IntegerRangeType::fromInterval (0 , null );
389- if (TypeCombinator:: containsNull ($ firstExprType ) || TypeCombinator:: containsNull ($ secondExprType )) {
389+ if ($ this -> canBeNull ($ firstExprType ) || $ this -> canBeNull ($ secondExprType )) {
390390 $ type = TypeCombinator::addNull ($ type );
391391 }
392392
@@ -397,7 +397,7 @@ public function walkFunction($function): string
397397
398398 foreach ($ function ->concatExpressions as $ expr ) {
399399 $ type = $ this ->unmarshalType ($ expr ->dispatch ($ this ));
400- $ hasNull = $ hasNull || TypeCombinator:: containsNull ($ type );
400+ $ hasNull = $ hasNull || $ this -> canBeNull ($ type );
401401 }
402402
403403 $ type = new StringType ();
@@ -418,7 +418,7 @@ public function walkFunction($function): string
418418 $ intervalExprType = $ this ->unmarshalType ($ function ->intervalExpression ->dispatch ($ this ));
419419
420420 $ type = new StringType ();
421- if (TypeCombinator:: containsNull ($ dateExprType ) || TypeCombinator:: containsNull ($ intervalExprType )) {
421+ if ($ this -> canBeNull ($ dateExprType ) || $ this -> canBeNull ($ intervalExprType )) {
422422 $ type = TypeCombinator::addNull ($ type );
423423 }
424424
@@ -432,7 +432,7 @@ public function walkFunction($function): string
432432 new IntegerType (),
433433 new FloatType ()
434434 );
435- if (TypeCombinator:: containsNull ($ date1ExprType ) || TypeCombinator:: containsNull ($ date2ExprType )) {
435+ if ($ this -> canBeNull ($ date1ExprType ) || $ this -> canBeNull ($ date2ExprType )) {
436436 $ type = TypeCombinator::addNull ($ type );
437437 }
438438
@@ -442,7 +442,7 @@ public function walkFunction($function): string
442442 $ stringPrimaryType = $ this ->unmarshalType ($ function ->stringPrimary ->dispatch ($ this ));
443443
444444 $ type = IntegerRangeType::fromInterval (0 , null );
445- if (TypeCombinator:: containsNull ($ stringPrimaryType )) {
445+ if ($ this -> canBeNull ($ stringPrimaryType )) {
446446 $ type = TypeCombinator::addNull ($ type );
447447 }
448448
@@ -453,7 +453,7 @@ public function walkFunction($function): string
453453 $ secondExprType = $ this ->unmarshalType ($ this ->walkStringPrimary ($ function ->secondStringPrimary ));
454454
455455 $ type = IntegerRangeType::fromInterval (0 , null );
456- if (TypeCombinator:: containsNull ($ firstExprType ) || TypeCombinator:: containsNull ($ secondExprType )) {
456+ if ($ this -> canBeNull ($ firstExprType ) || $ this -> canBeNull ($ secondExprType )) {
457457 $ type = TypeCombinator::addNull ($ type );
458458 }
459459
@@ -465,7 +465,7 @@ public function walkFunction($function): string
465465 $ stringPrimaryType = $ this ->unmarshalType ($ function ->stringPrimary ->dispatch ($ this ));
466466
467467 $ type = new StringType ();
468- if (TypeCombinator:: containsNull ($ stringPrimaryType )) {
468+ if ($ this -> canBeNull ($ stringPrimaryType )) {
469469 $ type = TypeCombinator::addNull ($ type );
470470 }
471471
@@ -476,7 +476,7 @@ public function walkFunction($function): string
476476 $ secondExprType = $ this ->unmarshalType ($ this ->walkSimpleArithmeticExpression ($ function ->secondSimpleArithmeticExpression ));
477477
478478 $ type = IntegerRangeType::fromInterval (0 , null );
479- if (TypeCombinator:: containsNull ($ firstExprType ) || TypeCombinator:: containsNull ($ secondExprType )) {
479+ if ($ this -> canBeNull ($ firstExprType ) || $ this -> canBeNull ($ secondExprType )) {
480480 $ type = TypeCombinator::addNull ($ type );
481481 }
482482
@@ -491,7 +491,7 @@ public function walkFunction($function): string
491491 $ exprType = $ this ->unmarshalType ($ this ->walkSimpleArithmeticExpression ($ function ->simpleArithmeticExpression ));
492492
493493 $ type = new FloatType ();
494- if (TypeCombinator:: containsNull ($ exprType )) {
494+ if ($ this -> canBeNull ($ exprType )) {
495495 $ type = TypeCombinator::addNull ($ type );
496496 }
497497
@@ -508,7 +508,7 @@ public function walkFunction($function): string
508508 }
509509
510510 $ 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 )) {
512512 $ type = TypeCombinator::addNull ($ type );
513513 }
514514
@@ -639,7 +639,7 @@ public function walkCoalesceExpression($coalesceExpression): string
639639 }
640640
641641 $ type = $ this ->unmarshalType ($ expression ->dispatch ($ this ));
642- $ allTypesContainNull = $ allTypesContainNull && TypeCombinator:: containsNull ($ type );
642+ $ allTypesContainNull = $ allTypesContainNull && $ this -> canBeNull ($ type );
643643
644644 $ expressionTypes [] = $ type ;
645645 }
@@ -1399,6 +1399,11 @@ private function resolveDatabaseInternalType(string $typeName, ?string $enumType
13991399 return $ type ;
14001400 }
14011401
1402+ private function canBeNull (Type $ type ): bool
1403+ {
1404+ return !$ type ->accepts (new NullType (), true )->no ();
1405+ }
1406+
14021407 private function toNumericOrNull (Type $ type ): Type
14031408 {
14041409 return TypeTraverser::map ($ type , static function (Type $ type , callable $ traverse ): Type {
0 commit comments