deprecated: try to magically resolve constructor

This commit is contained in:
icefox 2026-02-18 19:32:14 -03:00
parent aa7b062b29
commit bef42b3352
No known key found for this signature in database
3 changed files with 6 additions and 9 deletions

View file

@ -24,11 +24,13 @@ class ValueFactory
return $mapper($rawValue);
}
if (is_array($rawValue)) {
return App::makeWith($className, $rawValue);
// Plain values or numeric arrays are passed as a single parameter to the constructor
if (!is_array($rawValue) || array_key_exists(0, $rawValue)) {
return new $className($className);
}
return new $className($rawValue);
// Associative arrays leverage Laravel service container
return App::makeWith($className, $rawValue);
}
public static function resolveTypedValue(mixed $rawValue, Type $type): mixed