Skip to content

Releases: loophp/collection

2.6.0

22 Sep 06:08
Compare
Choose a tag to compare

New

I'm currently busy learning the amazing programming language Haskell and I backported into this library some stuff that I learned recently.

Breaking changes

There are 3 potential breaking changes in this release.

Compact

When compact was called without argument, the only value removed was null.

Starting of 2.6.0, when no argument is provided, it will remove all falsy values: null, false, 0, ''

Before:

$input = ['a', '', null, false, 0];

Collection::fromIterable($input)
    ->compact(); // ['a', '', false, 0]

After:

$input = ['a', '', null, false, 0];

Collection::fromIterable($input)
    ->compact(); // ['a']

Explode

Explode operation now mimic the PHP core function "explode" by removing the values used to explode the collection.

Before:

$input = range('a', 'j');

Collection::fromIterable($input)
    ->explode('b', 'd', 'f', 'h'); // ['a', ['b', 'c'], ['d', 'e'], ['f', 'g'], ['h', 'i', 'j']]

After:

$input = range('a', 'j');

Collection::fromIterable($input)
    ->explode('b', 'd', 'f', 'h'); // ['a', 'c', 'e', 'g', ['i', 'j']]

Split

The Split operation now has an extra integer parameter (a flag) that describe how the split should treat the value
which is used to split the collection into chunks.

  • Splitable::BEFORE: To insert that value at the beginning of the next chunk.
  • Splitable::AFTER: To insert that value at the end of the current chunk.
  • Splitable::REMOVE: To remove that value (the same as the explode operation)

Before:

$input = range('a', 'j');

Collection::fromIterable($input)
    ->split(static function ($value): bool {return $value === 'd';}

After:

$input = range('a', 'j');

Collection::fromIterable($input)
    ->split(
        Splitable::BEFORE, 
        static function ($value): bool {return $value === 'd';}
    )

Commits

  • Breaking change: refactor: Update Compact operation. 10fd55f
  • Breaking change: refactor: Update Explode operation. d28abcd
  • Breaking change: refactor: Update Split operation. 1c669b2
  • feat: Add fromFile static constructor. 7211052
  • feat: Add Words operation. 72df47a
  • feat: Add Unwords operation. b6aef32
  • feat: Add Unlines operation. ab9fde2
  • feat: Add Lines operation. 24cd4a5
  • refactor: Refactor operations using their parent operation counterpart. 0835f2d
  • refactor: Update Reverse operation. 6ce7b13
  • feat: Add scanLeft1 operation. 8b9aaa3
  • feat: Add scanRight1 operation. 1183407
  • feat: Add scanRight operation. c01274f
  • docs: Update FoldLeft and FoldRight. 98ced08
  • feat: Add scanLeft operation. ff0c7e4
  • docs: Update annotations. 317483e
  • feat: Add FoldRight1 operation. 18b9b1d
  • feat: Add FoldLeft1 operation. c034101
  • docs: Update README. ecdbc18
  • docs: Update documentation. 7985455
  • docs: Update API page. 516f786

2.5.5

16 Sep 14:55
Compare
Choose a tag to compare

Merged

  • Update vimeo/psalm requirement from 3.14.2 to 3.16 #26
  • Bump actions/create-release from v1.1.3 to v1.1.4 #25

Commits

  • chore: Update composer.json. 92f9ed8
  • feat: Add Unwindow operation. e240e6a

2.5.4

14 Sep 20:27
Compare
Choose a tag to compare

Commits

  • ci: Update release process to include changelog automatically. abb4e4f
  • Bump actions/stale from v3.0.10 to v3.0.11 f7ba528
  • docs: Update Usage page. 2d5d9f6
  • docs: Update documentation of Append and Prepend operations. 8441ad6
  • feat: Add Duplicate operation. b2d2a82
  • docs: Updated append method documentation. da6caa9

2.5.3

12 Sep 08:57
Compare
Choose a tag to compare

2.5.3

12 September 2020

  • Breaking change: refactor: Update Associate operation. 168eb1a
  • docs: Update annotations. 6cb1e77
  • refactor: Update some operation to make them lazy by default. ff6c556
  • docs: Update documentation. d990886
  • refactor: Update Product operation. 1318e41

2.5.2

08 Sep 20:13
Compare
Choose a tag to compare

2.5.2

8 September 2020

2.5.1

08 Sep 19:45
Compare
Choose a tag to compare

2.5.1

8 September 2020

Bug fixed

Miscellaneous

2.5.0

08 Sep 17:38
Compare
Choose a tag to compare

2.5.0

8 September 2020

Breaking changes

  • Replace Only with IntersectKeys operation. 78a20a3
  • Replace Iterate with Unfold operation. 6401f74
  • Update Window operation. c78813b
    • Remove variadic argument
    • Simplify the calculation of the stack

Improvements

  • Update Limit operation. 95f8856
  • Update Unpack operation. c253472
  • Use Filter operation when it's possible. 841a7c5

Miscellaneous

  • Remove unneeded variable assignations. 8ae26f6
  • Update annotations. 3dbf949

2.4.0

07 Sep 15:55
Compare
Choose a tag to compare

Diff with previous

Breaking changes

  • Rename Skip into Drop. 0c6b01a

    • Just a simple operation rename to match the Haskell Drop operation.
  • Update Last operation. 4ae3d35

    • Now the Last operation doesn't take any argument. If you want to reproduce the old behaviour, you can use a combination of Filter, Reverse and Limit operations.
  • Update First operation. 79a1f5c

    • Now the First operation doesn't take any argument. If you want to reproduce the old behaviour, you can use a combination of Filter and Limit operations.

New

Improvements

  • Update FoldLeft operation. deb825d
  • Refactor reducer callbacks. 9d1e176
  • Update Associate operation. 1b9ca3c
  • Update Reduction operation. f20942c

Miscellaneous

2.3.5

03 Sep 13:59
Compare
Choose a tag to compare

2.3.5

3 September 2020

2.3.4

03 Sep 12:42
Compare
Choose a tag to compare

2.3.4

3 September 2020