Skip to content

Releases: oliverearl/fixed-array-functions

v3.1.0

18 Mar 07:56
071dd6d

Choose a tag to compare

🎉 Version 3.1.0 - Collection Parity Release

We're excited to announce Fixed Array Functions v3.1.0, bringing 23 new methods for full Laravel Collection parity! This release adds essential aggregation, conditional, and transformation methods while maintaining 100% backward compatibility.


✨ What's New

Aggregation Methods

Make data analysis a breeze with new aggregate functions:

  • isEmpty() / isNotEmpty() - Check if your array has data
  • reduce() - Reduce array to a single value with a callback
  • sum() - Sum numeric values (supports property names!)
  • avg() / average() - Calculate averages
  • min() / max() - Find minimum and maximum values
$orders = fixedArray($orderArray);
$total = $orders->sum('amount');          // Sum by property
$average = $orders->avg('price');         // Average by property
$isEmpty = $orders->isEmpty();            // Quick empty check

Conditional Methods

Add powerful conditional logic to your chains:

  • every() / all() - Check if all items pass a test
  • some() - Check if at least one item passes a test
  • when() / unless() - Conditional transformations
$data = fixedArray([2, 4, 6, 8])
    ->when($shouldDouble, fn($arr) => $arr->map(fn($v) => $v * 2))
    ->unless($skipSort, fn($arr) => $arr->sort());

$allEven = $data->every(fn($v) => $v % 2 === 0);  // true
$hasLarge = $data->some(fn($v) => $v > 5);        // true

Transformation Methods

Transform and extract data like a pro:

  • reject() - Filter out items that pass the test (opposite of filter)
  • partition() - Split array into two groups based on a condition
  • pluck() - Extract values from a specific property
  • join() / implode() - Join array elements with a string
  • keys() / values() - Get all keys or values
// Split valid/invalid records
[$valid, $invalid] = fixedArray($records)
    ->partition(fn($r) => $r->isValid())
    ->toArray();

// Extract and process
$names = fixedArray($users)
    ->pluck('name')
    ->join(', ');  // "Alice, Bob, Charlie"

Utility Methods

Enhance your workflows with:

  • tap() - Execute a callback and return the array (great for debugging)
  • pipe() - Pass the array through a callback and return the result
$result = fixedArray($data)
    ->tap(fn($arr) => logger()->info('Processing', ['count' => $arr->count()]))
    ->map(fn($v) => $v * 2)
    ->pipe(fn($arr) => $arr->sum());  // Returns the sum

🐛 Bug Fixes

Critical: filter() Now Passes Key to Callback

The filter() method now correctly passes both $value and $key to callbacks, matching Laravel Collection behavior:

// Before: Only $value was passed ❌
$filtered = $array->filter(fn($value) => $value > 5);

// Now: Both $value and $key are passed ✅
$filtered = $array->filter(fn($value, $key) => $value > 5 && $key < 10);

This enhances functionality without breaking existing code (the $key parameter is optional).

Performance Improvements

  • filter() now iterates directly over SplFixedArray (no array conversions)
  • Aggregate methods work without intermediate array allocations
  • join() has improved type safety for null and non-scalar values

📚 Documentation

This release includes comprehensive open-source governance:

  • CONTRIBUTING.md - Contribution guidelines, dev setup, and coding standards
  • SECURITY.md - Security policy and vulnerability reporting
  • GitHub Issue Templates - Structured bug reports and feature requests
  • Pull Request Template - Comprehensive PR checklist

Plus an enhanced README with:

  • Performance guidance (when to use SplFixedArray)
  • Real-world usage examples
  • Complete method reference (70+ methods!)

📊 By The Numbers

  • 23 new methods (bringing total to 70+)
  • 290 tests with 100% code coverage
  • PHPStan Level 9 (strictest) - zero errors
  • Fully backward compatible - safe upgrade from 3.0.0

🚀 Upgrade Guide

From 3.0.x

Simply update your composer.json:

composer update petrobolos/fixed-array-functions

No breaking changes! All existing code will continue to work. The filter() enhancement is backward compatible (the key parameter is optional)

What's Changed (Autogenerated notes)

Full Changelog: v3.0.0...v3.1.0

v3.0.0

09 Dec 11:14
5486050

Choose a tag to compare

What's Changed

Full Changelog: v2.1.2...v3.0.0

v2.1.2

13 May 08:18
6348cac

Choose a tag to compare

What's Changed

  • Bump dependabot/fetch-metadata from 2.3.0 to 2.4.0 by @dependabot in #26

Full Changelog: v2.1.1...v2.1.2

v2.1.1

22 Mar 12:41
e799567

Choose a tag to compare

What's Changed

  • Update orchestra/testbench requirement from ^9.0.0 to ^10.1.0 by @dependabot in #25

Full Changelog: v2.1.0...v2.1.1

v2.1.0

05 Mar 21:39
3318e9f

Choose a tag to compare

What's Changed

Full Changelog: v2.0.1...v2.1.0

v2.0.1

28 Jan 12:50
3b95931

Choose a tag to compare

What's Changed

  • Bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 by @dependabot in #22

Full Changelog: v2.0.0...v2.0.1

v2.0.0

14 Dec 15:17
28de582

Choose a tag to compare

Breaking Changes

This drops support for versions of PHP below 8.3, and versions of Laravel below 11.

What's Changed

Full Changelog: v1.2.6...v2.0.0

v1.2.6

14 Dec 14:31
63bca5b

Choose a tag to compare

What's Changed

Full Changelog: v.1.2.5...v1.2.6

v1.2.5

28 Apr 21:55
93863d3

Choose a tag to compare

What's Changed

Full Changelog: v1.2.4...v.1.2.5

v1.2.4

30 Jan 22:45
9475466

Choose a tag to compare

What's Changed

  • Bump dependabot/fetch-metadata from 1.3.5 to 1.3.6 by @dependabot in #12

Full Changelog: v1.2.3...v1.2.4