Expose validation callbacks and restorable URL overrides

Merged
BI
10h ago
+165-4

Problem and change

Closure validation rules hide their callback even though Laravel exposes it publicly. Restore public access so tools inspecting parsed validation rules can read the original closure.

Temporary URL origins and route defaults cannot currently be restored without reading protected state or saving resolved values that can override later resolver results. Add getForcedOrigin(), getForcedAssetOrigin(), and getDefaultParameterOverrides() so callers can save and restore their values through the existing setters. Document this usage and correct the documented precedence of request defaults. No URL generation or coroutine storage behavior changes.

Also clarify the repository's user documentation style guidance.

Fixes #729. Addresses discussion #730.

Supporting evidence

The new parser regression fails with Cannot access protected property ClosureValidationRule::$callback before the visibility fix and passes afterwards. URL tests cover restoration of absent, empty, and explicit origins, dynamic resolvers, asset origins, and request defaults without capturing worker or resolved defaults.

Verification

  • composer analyse — passed, including type fixtures and the application skeleton.
  • composer test:parallel -- --processes=4 tests/Validation — 1,995 tests passed.
  • composer test:parallel -- --processes=4 tests/Routing — 585 tests passed.
  • composer lint:fix — passed; no formatting changes required.
  • git diff --check — passed.

Both changed test files also passed individually during implementation. The URL facade annotations were regenerated with composer facade 'Hypervel\Support\Facades\URL'.

[!NOTE]

Add getters for URL origin overrides and expose closure validation callbacks

  • Adds UrlGenerator::getForcedOrigin, getForcedAssetOrigin, and getDefaultParameterOverrides, which read the current coroutine's overrides from CoroutineContext and return null or an empty array when unset. Adds matching static annotations to the URL facade.
  • Makes ClosureValidationRule::$callback public so callers holding an exploded rule can access the original closure.
  • Updates urls.md with examples for saving, temporarily replacing, and restoring origin and default-parameter overrides, including the priority order of worker defaults, resolved defaults, request-scoped overrides, and route parameters.
  • Adds data-driven tests in RoutingUrlGeneratorTest.php for restoring overrides and effective defaults, plus a callback-exposure test in ValidationRuleParserTest.php.
  • Behavioral Change: ClosureValidationRule::$callback visibility changes from protected to public in ClosureValidationRule.php.

Macroscope summarized 46c81fd.