PHPackages                             wmde/iterable-functions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wmde/iterable-functions

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

wmde/iterable-functions
=======================

Functions to transform iterables into more specific types

0.2.0(7y ago)216.7k1[2 PRs](https://github.com/wmde/iterable-functions/pulls)GPL-2.0-or-laterPHPPHP &gt;=7.1

Since Jun 17Pushed 4y ago8 watchersCompare

[ Source](https://github.com/wmde/iterable-functions)[ Packagist](https://packagist.org/packages/wmde/iterable-functions)[ Docs](https://github.com/wmde/iterable-functions)[ RSS](/packages/wmde-iterable-functions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (3)Used By (0)

Iterable Functions
==================

[](#iterable-functions)

[![Build Status](https://camo.githubusercontent.com/84f359d7624f2decea9e97aa3143c0e275b06e31fb5547bf3907db5bbfe9366e/68747470733a2f2f7472617669732d63692e6f72672f776d64652f6974657261626c652d66756e6374696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/wmde/iterable-functions)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a5da51ab32eb4a4e380002e59ef5837152726868996eaf2294a21cf8f752dfff/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776d64652f6974657261626c652d66756e6374696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wmde/iterable-functions/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/60b7772f9f11465047defb45958ca12ac24374e80343f27717704a485ca615e7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776d64652f6974657261626c652d66756e6374696f6e732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wmde/iterable-functions/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/e798bac85d7c27a6ff323aa00a87bf4d3fcc0d04f2252155cf4787720600bc83/68747470733a2f2f706f7365722e707567782e6f72672f776d64652f6974657261626c652d66756e6374696f6e732f76657273696f6e2e706e67)](https://packagist.org/packages/wmde/iterable-functions)[![Download count](https://camo.githubusercontent.com/bf5c61db71eb9801deb53d62147162cf69262331dacc8c16f046a840a351535d/68747470733a2f2f706f7365722e707567782e6f72672f776d64652f6974657261626c652d66756e6374696f6e732f642f746f74616c2e706e67)](https://packagist.org/packages/wmde/iterable-functions)

Provides basic functions to work with variables for type `iterable` (added in PHP 7.1). Primarily to transform variables of type `iteratble` into more specific types such as `array`.

If you have an iterable somewhere and you need to pass it to a function that only takes an `array`or an `Iterator`, you have a problem. You will need to add conditional logic to find out the type of the value and transform it if needed, which gets quite involved in the case of needing an `Iterator`.

This problem is quite common, as PHP's standard library, as of version 7.1, tends to either require arrays, iterators or traversables.

Example:

```
function doStuff(iterable $iterable) {
    $iterableMinusFooBar = array_diff( $iterable, [ 'foo', 'bar' ] );
}
// Output: array_diff(): Argument #1 is not an array
```

Installation
------------

[](#installation)

To add this package as a local, per-project dependency to your project, simply add a dependency on `wmde/iterable-functions` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on Iterable Functions 1.x:

```
{
    "require": {
        "wmde/iterable-functions": "~1.0"
    }
}
```

Usage
-----

[](#usage)

**When you need an array**

```
function doStuff(iterable $iterable) {
    $iterableMinusFooBar = array_diff( iterable_to_array( $iterable ), [ 'foo', 'bar' ] );
}
```

**When you need an Iterator**

```
function doStuff(iterable $iterable) {
    $firstFewThings = new LimitIterator( iterable_to_iterator( $iterable ), 42 );
}
```

Running the tests
-----------------

[](#running-the-tests)

For a full CI run

```
composer ci

```

For tests only

```
composer test

```

For style checks only

```
composer cs

```

Release notes
-------------

[](#release-notes)

### 0.2.0 (2018-09-13)

[](#020-2018-09-13)

- Added `iterable_merge`

### 0.1.0 (2017-06-17)

[](#010-2017-06-17)

Initial release with

- `iterable_to_array`
- `iterable_to_iterator`

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~452 days

Total

2

Last Release

2804d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/451bd4039d530fed8f9c3da91bfa519233a397d2182cdfdcad700f6cfea19b7f?d=identicon)[Jeroen De Dauw](/maintainers/Jeroen%20De%20Dauw)

---

Top Contributors

[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (16 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/wmde-iterable-functions/health.svg)

```
[![Health](https://phpackages.com/badges/wmde-iterable-functions/health.svg)](https://phpackages.com/packages/wmde-iterable-functions)
```

###  Alternatives

[yahnis-elsts/admin-notices

A utility library for WordPress plugins that makes it easier to create admin notices. Supports persistently dismissible notices.

311.1k](/packages/yahnis-elsts-admin-notices)[jahvi/magento2-copy-theme-override

Magento 2 command to automatically copy files into active theme

124.5k](/packages/jahvi-magento2-copy-theme-override)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
