Page MenuHomeDevCentral

BaseCollection::first now returns an Option
ClosedPublic

Authored by dereckson on Nov 7 2025, 01:30.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Aug 10, 23:25
Unknown Object (File)
Mon, Aug 10, 20:44
Unknown Object (File)
Mon, Aug 10, 17:46
Unknown Object (File)
Sun, Aug 9, 21:42
Unknown Object (File)
Sun, Aug 9, 18:07
Unknown Object (File)
Mon, Aug 3, 02:28
Unknown Object (File)
Mon, Aug 3, 01:53
Unknown Object (File)
Sat, Aug 1, 23:29
Subscribers
None

Details

Summary

Previous behavior: return first item or throw an option on empty collection
Current behavior: similar to Rust, return Some(first item) or None

The behavior of BaseCollection::firstOr is not changed, with eager loading.
For lazy loading, we can now use $collection->first()->getValueOrElse().

Test Plan
  • Unit tests have been updated
  • No-op for Zed code (it uses firstOr)

Diff Detail

Repository
rKERUALD Keruald libraries development repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable