* [13.x] Add conditional return types to several methods
Make PHPStan/Psalm narrow the return type at call sites for methods
whose return depends on whether a nullable argument is passed:
- Paginator/CursorPaginator fragment() (concrete + contracts)
- Route::domain()
- Password/File validation rule defaults() (matching Email)
- __() helper
- ComponentAttributeBag::data()
Adds assertType coverage for the paginator and route cases.
* Add more conditional return types and simplify defaults() docblocks
More candidates (found via func_num_args / ternary-return / === null guards):
- Enumerable + LazyCollection random() (mirror Collection::random)
- Arr::random()
- Lottery::choose()
- Route::getMetadata()
Simplify Password/File/Email defaults() to a plain
@return ($callback is null ? static : void) instead of the verbose
@phpstan-return; plain @return conditional types are understood by
PHPStan, Psalm and PhpStorm.
Adds assertType coverage and updates LazyCollection random() expectations.
* Widen Route::getMetadata() return to array<array-key, mixed>
Metadata setters accept any array and preserve numeric keys, so the
getter can return non-string keys. Use array<array-key, mixed> instead
of array<string, mixed>.