diff --git a/src/EventHandler/Type/Optional/FunctionReturnTypeProvider.php b/src/EventHandler/Type/Optional/FunctionReturnTypeProvider.php index 896f434..2c0fbb3 100644 --- a/src/EventHandler/Type/Optional/FunctionReturnTypeProvider.php +++ b/src/EventHandler/Type/Optional/FunctionReturnTypeProvider.php @@ -28,6 +28,9 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte return null; } - return $argument_type->setPossiblyUndefined(true); + $clone = clone $argument_type; + $clone->possibly_undefined = true; + + return $clone; } }