@@ -21,6 +21,19 @@ class NotNormalizableValueException extends UnexpectedValueException
2121 private ?string $ path = null ;
2222 private bool $ useMessageForUser = false ;
2323
24+ /**
25+ * @param list<string|\Stringable>|null $expectedTypes
26+ */
27+ public function __construct (string $ message = '' , int $ code = 0 , ?\Throwable $ previous = null , ?string $ currentType = null , ?array $ expectedTypes = null , ?string $ path = null , bool $ useMessageForUser = false )
28+ {
29+ parent ::__construct ($ message , $ code , $ previous );
30+
31+ $ this ->currentType = $ currentType ;
32+ $ this ->expectedTypes = $ expectedTypes ? array_map (strval (...), $ expectedTypes ) : $ expectedTypes ;
33+ $ this ->path = $ path ;
34+ $ this ->useMessageForUser = $ useMessageForUser ;
35+ }
36+
2437 /**
2538 * @param list<string|\Stringable> $expectedTypes
2639 * @param bool $useMessageForUser If the message passed to this exception is something that can be shown
@@ -29,14 +42,7 @@ class NotNormalizableValueException extends UnexpectedValueException
2942 */
3043 public static function createForUnexpectedDataType (string $ message , mixed $ data , array $ expectedTypes , ?string $ path = null , bool $ useMessageForUser = false , int $ code = 0 , ?\Throwable $ previous = null ): self
3144 {
32- $ self = new self ($ message , $ code , $ previous );
33-
34- $ self ->currentType = get_debug_type ($ data );
35- $ self ->expectedTypes = array_map (strval (...), $ expectedTypes );
36- $ self ->path = $ path ;
37- $ self ->useMessageForUser = $ useMessageForUser ;
38-
39- return $ self ;
45+ return new self ($ message , $ code , $ previous , get_debug_type ($ data ), $ expectedTypes , $ path , $ useMessageForUser );
4046 }
4147
4248 public function getCurrentType (): ?string
0 commit comments