Repository navigation
7.0.0
Overall feeling 🐈
A year and one day without update.
Released on the 11th December 2021, 6.0.3 was the last update.
Today, we are pleased to announce the release of version 7, our first update in over a year. There were several reasons for the delay, including a lack of bug reports and the busy schedules of our team members. We also wanted to take the time to carefully test and prepare the release, given the significant changes and improvements included in this update.
We hope you enjoy this update, and we look forward to continuing to improve and evolve our library in the coming months and years. Please let us know if you have any feedback or suggestions.
Notable changes 🎉
- Minimum version of PHP is now 8
PHP 7.4 support has ended the 28 November 2022, therefore, it's time to support PHP 8. Rector has been used to upgrade the codebase with all the new PHP 8 stuff. - Removal of docker, switch to Nix
We were using a docker-compose file to have the documentation built locally, but since I'm using more and more Nix, I decided to get rid of Docker. With one single file.envrc, all the dependencies we need to built the documentation server, creating changelogs with auto-changelogs, running Sphinx server for documentation and have a proper PHP interpreter. - Removal of PHPSpec, switch to PHPunit
For many reasons, we decided to switch to PHPUnit for testing. Switching to the PHPUnit framework was the opportunity to rewrite all the tests and we are extremelly grateful towards the PHPUnit framework. We also built a specific PHPUnit plugin providing assertions for iterables. To built it, we had to abstract the main classes in use inloophp/collectionin their own project, and that project contains now many Iterator aggregates now in use inloophp/collection. - New
CollectionDecoratorabstract class to create custom collection classes
Since the beginning of the creation of this library, many people expressed the will to not set the main Collection class asfinal. While I'm absolutely not for that, I'm more keen to provide anabstractclass which acts as a decorator and that can be easily extended by using the inheritance mechanism. - Add new operations:
Averages,Compare,Max,Min
A couple of new operations has been added, please read the API documentation to learn more about them. - Use of
IteratorAggregate
Many operations are now usingIteratorAggregatefromloophp/iterators. - The
cacheoperation is using the fastest implementation of Caching iterators existing. I couldn't find a fastest implementation yet. That implementation is available inloophp/iteratorsas an Iterator aggregate. Special thanks to @azjezz for the discussion and tips. - Static analysis coverage has been greatly improved, we are now around 99.2%
BC Breaking changes 💣
- #269
The static constructor is no more variadic. We noticed that when usingunfold, there were some of useless kind of back and forth when it comes to callback arguments handling. Return value is an array, which is expanded, then converted again into an array... that mambo jambo is useless, it has been removed. - #245
TheScanLeft1has always been something that was bugging me out in the edge cases. I was unable to find an elegant way to deal with it when the Collection was empty since we were usingPrependin it. This issue has been fixed now. The implementation is not the best, but it works very well. - #249
The operations:first,foldLeft,foldLeft1,foldRight,foldRight1,implode,reduce,unlines,unwords,last,head,get,compare,min,maxare now returning a value instead of returning a Collection containing one single value. That feature request has been requested many times ago by many users, this is now done. - The
Tailsoperation is now keeping keys.
TheTailsoperation used to return a list of values, it is now returning value keys has well. The implementation is way cleaner and faster has well.
Numbers 🔢
- 233 commits
- 18 issues closed
- No user contribution #SadPandaFace
- ~81k downloads in total (~200 per day) (https://packagist.org/packages/loophp/collection/stats)
Random 👍
- Advent Of Code 2022
This year I decided to participate to the Advent Of Code and guess what... I'm usingloophp/collectionfor finding solutions to the challenges. It turns out that this is actually an excellent tool. I also have in mind to create a dedicated documentation section with the solutions when the challenge is over. In the meantime, you can have a look at the aoc2022 repository and get some inspirations. - Try It Online!
A new badgeon the README has been added. It uses https://play.phpsandbox.io/ and provides a live playground where you can test the library online in a full blown text editor with auto-completion !
Merged
- Psalm 5 upgrade
#283 - add
AbstractCollectionabstract class#270 - chore(deps): update dependency sphinx_rtd_theme to v0.5.2
#275 - chore(deps): update actions/stale action to v6
#276 - chore(deps): add renovate.json
#274 - refactor:
unfoldconstructor is not variadic anymore#269 - Documentation: refactoring
#266 - chore(deps): Bump cachix/install-nix-action from 17 to 18
#267 - Breaking change: refactor: Refactor
Reduceoperation.#259 - Add action on README file.
#263 - chore(deps): Bump shivammathur/setup-php from 2.20.1 to 2.21.1
#261 - chore(deps): Bump shivammathur/setup-php from 2.19.0 to 2.20.1
#258 - New Operations:
Compare,Max,Min#255 - chore(deps): Bump shivammathur/setup-php from 2.18.1 to 2.19.0
#253 - ci: Use
pcovfor coverage.#252 - chore(deps-dev): Update psr/cache requirement from ^1.0 to ^1.0 || ^2.0
#251 - chore(deps): Bump shivammathur/setup-php from 2.18.0 to 2.18.1
#250 - Update Scrutinizer configuration.
#249 - chore(deps): Bump actions/stale from 4 to 5
#248 - feat: Add
Averagesoperation.#238 - Simplify
everyoperation#247 - Get rid of
phpspec/prophecy-phpunit.#246 - Breaking change: fix: Update
scanLeft1operation.#245 - chore(deps): Bump shivammathur/setup-php from 2.17.1 to 2.18.0
#244 - refactor: Update
everyoperation.#242 - chore(deps): Bump actions/cache from 2.1.7 to 3
#243 - misc: Update
CallbackArrayReducer.#241 - chore(deps): Bump actions/checkout from 2.4.0 to 3
#240 - chore(deps): Bump shivammathur/setup-php from 2.17.0 to 2.17.1
#239 - chore(deps): Bump shivammathur/setup-php from 2.16.0 to 2.17.0
#235 - Replace
Iteratorwithiterablealmost everywhere.#233 - refactor: Use
newkeyword on some operations.#231 - refactor: Use
StringIteratorAggregate.#234 - Tests: Switch to PHPUnit
#227 - Refactor: Replace
RandomIterator#230 - Simplify operations that needs more than one instance of the
Generator- usingIteratorAggregate.#229 - Use
loophp/iterators#228
Fixed
- tests: Add new tests.
#264
Commits
- Breaking change: refactor:
Tailsoperation, performance improvementsd71b2ef - Breaking change: refactor: Update
Unpackoperation.34c36da - chore: update
composer.jsonand fixauto-changelogcommand6949831 - chore: update
composer.json1ba6085 - remove obsolete annotation
908d3e5 - refactor:
Tailsoperationea4b92c - refactor:
Tailsoperation, performance improvements1c28be3 - refactor:
Windowoperation: minor performance improvement486567a - refactor: upgrade
testsfor PHP 825067cb - refactor: upgrade
docsfor PHP 81d9c134 - refactor: upgrade
srcfor PHP 84a4a60b - cs: autofix cs
4dc36fe - fix: update
IfThenElseoperationeb78132 - sa: update typing information for PHP 8
8ee1134 - update SA annotations
7154f09 - update SA annotations
0e8b0e5 - disable phpcs statement
d7bba3a - update PHPStan baseline
808578a - reorder
Collectioninterface use statements6bbb829 - fix: update
spanandpartitionoperations31d4b31 - fix: remove static constructors
747e1f8 - docs: fix
unfoldsignatured11addd - sa: update PSalm baseline
f78dc32 - Revert "sa: fix
Wrapableinterface"1cf67d1 - sa: fix
Wrapableinterface3866fe5 - sa: fix
template-extendsannotationsa3f8b45 - cs: reduce the amount of
usestatements19eb14e - cs: reduce the amount of
usestatementsdce7e48 - Autofix code style.
cd4a6f6 - direnv: update
.envrcb402706 - fix: update constructors
c49e62b - fix: Update
GroupBystatic analysis annotations.d74d4f8 - fix: update various operations static analysis annotations.
473f105 - fix: update various operations static analysis annotations.
c1998e9 - fix: update various operations static analysis annotations.
2fb44cf - fix:
SinceandUntiloperation - fix sabde565c - fix:
Compareoperation - fix sa06729d7 - fix: fix operator sign
ea90e23 - fix: remove optional parameters
6a27551 - fix: update interfaces
0dae4c2 - fix missing parameter
69818b3 - docs: Update
pipedocumentationec10eeb - cs: get rid of obsolete
phpcsannotationsa385a6a - ci: update scrutinizer configuration
dae9eb6 - ci: update scrutinizer configuration
ca6f602 - ci: update scrutinizer configuration
2d09f65 - ci: update scrutinizer configuration
bac7f9b - ci: update scrutinizer configuration
376bd66 - ci: update trigger paths
0f2db5b - ci: update scrutinizer configuration
8d12965 - ci: fix indentation
95e60b5 - ci: update trigger paths
e78546e - ci: fix
scrutinizer/ocular583668f - Autofix code style.
079a7b9 - docs: Update changes
a6653b8 scanLeftandscanRighthas been updated and now need two arguments instead of one.9355dea- tests: fix tests
1233c49 - sa: update SA info of various operations.
25ed050 - sa: fixes
6c5e44c - tests: update
diffSA testsece6067 - tests: update
diffSA tests0af490e - fix typos with codespell
28e7663 - fix Collatz example
6ec0563 - chore: remove custom nix files
4197638 - cs: autofix code style
e546136 - refactor: update
Pairoperationeed0c7e - chore: prettify codebase
2a0ed02 - refactor: align
Duplicateoperation withDistinctde09c01 - docs: do not create ArrayIterator.
806fa18 - refactor: prevent the creation of an extra variable
31f87a8 - docs: do not create ArrayIterator.
2e50e49 - refactor: remove files header
aacb5e9 - Revert "chore: Ignore Nix files"
98fe09a - docs: Add
phpsandboxbadge and link.9f02c7c - docs: Fix minor things.
679b353 - chore: Update
flake.nixfile.8ddd35d - chore: Ignore Nix files
d34980d - ci: Add workflow to build a PDF of the documentation for each tag.
7810400 - chore: Add
composercommand to run the documentation server.15dc6bd - docs: Update documentation.
a783394 - chore: Add Nix flakes file for documentation building.
3f90ed6 - chore: Remove
dockerstuff.88e92b6 - cs: Upgrade to
loophp/iterators^2.1343255 - refactor: Upgrade to
loophp/iterators^2.691abd4 - cs: Autofix code style.
6f1eda3 - chore: Update baseline.
4463a37 - chore: Update scrutinizer configuration.
fc3a790 - ci: Add
prettierin required status checks.c8687cf - chore: Prettify codebase.
9551288 - chore: Update
.gitattributes.411f937 - ci: Update required status checks.
5ab0f1f - ci: Fix step name.
a65faf4 - prettier: Autofix.
ff03ea6 - ci: Fix branch name.
bbfb1c8 - ci: Enable prettier on the whole repo.
25d1c25 - ci: Simplify things.
1ef0edc - sa: Fix
distincttests.6147f9c - ci: Include
testssrc directories.ff8fea0 - sa: Fix
distincttests.edc521f - chore: Update test workflow.
7f43d4b - chore: Update test workflow.
738cc6e - Update
FilterandRejectoperations.186c003 - Minor cosmetic changes.
066504a - Autofix code style.
25b2a69 - refactor: Minor optimization in
Packoperation.32462ad - fix:
Equalsoperation, fix typing information.eff8102 - fix:
Sameoperation, fix typing information.5a91d8a - fix:
Reductionoperation, fix typing information.466232b - Use
ReductionIterableAggregate.0d4d7a2 - Use
ReductionIterableAggregate.a168b6d - Autofix code-style.
3b49c3a - Revert "Revert last 3 commits."
16e3c7a - Update typing information.
3017e2a - tests: Disable problematic test on PHP < 8.
c148d16 - Revert last 3 commits.
31cdc99 - Use
ConcatIterableAggregate.d90986d - Use
MapIterableAggregate.ea45575 - Use
FilterIterableAggregate.84b42c2 - fix: Performance improvements using
SimpleCachingIteratorAggregate.51e7d6f - fix: Remove
@psalm-suppressannotation.ab5f9f0 - docs: Add more examples snippets.
a1873a7 - Revert "ci: Disable XDebug."
a6b4791 - ci: Disable XDebug.
447bd03 - SA: Minor changes fix.
0e30363 - SA: Minor changes.
c835e1c - SA: Fix a couple of operations.
679834b - SA: PHPStan 1.6.0 upgrade.
843c9c4 - refactor: Update
Reverseoperation.545bd60 - fix: Remove
ext-xdebugfromcomposer.jsonfor now.6209f4b - fix: Minor static analysis fixes.
2ce3510 - refactor: Minor optimizations here and there.
f08d88e - refactor: Minor optimizations here and there.
e9c4460 - refactor: Minor optimizations.
5987ab7 - refactor:
randomoperation: useRandomIterableAggregate.78e7a6f - tests: Add missing test.
8afedbf - tests: Add missing test.
7a05041 - cs: Autofix code style.
0d2595e - misc: Further optimizations with
Everyoperations.f523cdb - misc: Further optimizations with
Everyoperations.de1edb3 - tests: Remove duplicated tests.
2a0c84d - cs: Minor changes.
f0612e7 - refactor: Optimize
Headoperation.33e2f15 - cs: Autofix code style.
6cc2a05 - fix: SA - Update
Unwindowoperation.c9562fd - refactor: Simplify and optimize
Transpose.38cca46 - refactor: Use
newkeyword everywhere.aacf7df - refactor: Use
newkeyword everywhere.a6db56e - refactor: Minor SA annotations update.
35bf8c2 - refactor: Use
newkeyword everywhere.8a3a05a - refactor: Remove useless intermediary variable.
79ebed1 - refactor:
Droprely onLimitnow.16e220a - refactor: Remove useless intermediary variable.
d6d8aa6 - refactor: Minor optimizations.
9ac298a - refactor: Minor optimizations.
11bee15 - refactor: Use more iterator aggregates.
19616a6 - refactor: Use more iterator aggregates.
669a956 - refactor: Use more iterator aggregates.
7af1d80 - cs: Cleanup
.php-cs-fixer.dist.php.0fba6da - feat: Performance improvements using iterator aggregates.
3b773ad - chore: Normalize composer.json.
e19bde8 - tests:
TypedIterator- Add test.b9aab65 - cs: Autofix code style.
cbc6c20 - tests:
StringIterator- Add test.fe15a5b - tests:
StringIterator- Add test.a66242d - fix: Disable PHPCSFixer on specific files.
eb61a90 - tests:
TypedIterator- Add test.7280ebc - tests: Enable HTML infection reports.
468d71d - ci: Update PHP configuration.
f54b002 - Autofix code style.
04d7531 - Autofix code style.
10e7eed - refactor:
Unpackoperation - UseUnpackIterableAggregate.aaa289a - Update license
741cbce - Normalize composer.json
8ef547d - fix: Add missing
fromkeyword.d179b11 - Autofix code style.
6df94ee - refactor: Minor optimization, remove
returnkeyword.7683362 - sa: Update PHPStan baseline.
782a48e - sa: Fix unresolvable type.
d112149 - cs: Autofix code style.
78d5d7a - sa: Update typing information.
351676b - fix: Remove local variable.
58a3919 - fix:
Sameoperation - proper sign.15bf8de - fix:
Sameoperation must yield.317b519 - cs:
Sameoperation, clear remaining todo.518209b - refactor: Simplify
fromGeneratoroperation.b2e1dc9 - sa: Update typing information to reduce warnings.
b2028d8 - refactor: Simplify
DropWhileoperation.e794b79 - test: Add minor test for
Sortoperation.1935d11 - Fix
scrutinizer/ocularupload.5f956e2 - tests: Only do mutation testing on PHP 8.0.
525e32e - docs: Update
Contributingsection.36cdcd1 - ci: Fix
scrutinizer/ocularupload.5e67380 - docs: Update README.
20a1352 - ci: Fix Grumphp task name.
4fd27fd - docs: Enable badge showing infection tests score.
603eb82 - ci: Enable infection tests reporting.
fed4fbc - sa: Improve static analysis score.
d11d032 - refactor: Update
Intersperseoperation - do not throw when values are negative.1497db7 - chore: Update static files.
47eb342 - chore: Update static files.
401cf20 - chore: Normalize composer.json.
cf34e8d