File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ abstract class DataObject implements ArrayAccess, JsonSerializable
2828 */
2929 protected array $ arrayCache = [];
3030
31+ /**
32+ * Flag to indicate if auto-casting is enabled.
33+ */
34+ protected static bool $ autoCasting = true ;
35+
3136 /**
3237 * Create an instance of the class using the provided data array.
3338 */
@@ -47,7 +52,9 @@ public static function make(array $data): static
4752 // and convert the value to the correct type automatically
4853 if (array_key_exists ($ dataKey , $ data )) {
4954 $ dataValue = $ data [$ dataKey ];
50- $ dataValue = static ::convertValueToType ($ dataValue , $ parameter );
55+ if (static ::$ autoCasting ) {
56+ $ dataValue = static ::convertValueToType ($ dataValue , $ parameter );
57+ }
5158 // use the default value if available
5259 } elseif ($ parameter ->isDefaultValueAvailable ()) {
5360 $ dataValue = $ parameter ->getDefaultValue ();
You can’t perform that action at this time.
0 commit comments