Maravel-Framework 10.68 backports Laravel 12 feature/improvement (breaking change) introduced in pull request 53522 but with on-off switch, disabled by default to maintain backward compatibility.
It also applies the logic to the BoundMethod::call logic.
When autowiring:cache is used, the behavior is preserved as when it is not used.
To enable the optimized resolution path, add the following constant to your app/Application.php in both Maravel and Maravelith:
class Application extends \Illuminate\Foundation\Application
{
public const DEFAULT_PARAMETER_TAKES_PRECEDENCE_WHEN_AUTOWIRING = true;
}
Behavioral Example:
class Example
{
public function __construct(public ?Carbon $date = null) {}
}
$example = \app(Example::class);
// Legacy (Constant = false):
// Container attempts to build Carbon, catches exception if any, returns null.
$example->date instanceof Carbon;
// (Constant = true):
// Container skips resolving the parameter and instantly returns null when
// Carbon class is not bound already and when no contextual bindings are used
$example->date === null;

Top comments (0)