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)
Tue, Jun 23, 07:21
Unknown Object (File)
Mon, Jun 22, 23:23
Unknown Object (File)
Sun, Jun 21, 23:29
Unknown Object (File)
Sat, Jun 20, 10:20
Unknown Object (File)
Sat, Jun 20, 08:34
Unknown Object (File)
Thu, Jun 18, 10:45
Unknown Object (File)
Thu, Jun 18, 08:11
Unknown Object (File)
Wed, Jun 17, 23:33
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