HomeDevCentral

BaseCollection::first now returns an Option

Description

BaseCollection::first now returns an Option

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)

Reviewers: dereckson

Reviewed By: dereckson

Differential Revision: https://devcentral.nasqueron.org/D3852

Details

Provenance
derecksonAuthored on Fri, Nov 7, 01:26
derecksonPushed on Fri, Nov 7, 01:31
Reviewer
dereckson
Differential Revision
D3852: BaseCollection::first now returns an Option
Parents
rKERUALDfd7258079ca5: Remove features implemented in PHP 8
Branches
Unknown
Tags
Unknown
References
develop/omnitools-1.x