PHPackages                             pre/short-closures - 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. pre/short-closures

ActivePre-macro[Utility &amp; Helpers](/categories/utility)

pre/short-closures
==================

0.8.0(7y ago)354805[2 issues](https://github.com/preprocess/pre-short-closures/issues)MITRubyCI failing

Since Jan 27Pushed 5y ago1 watchersCompare

[ Source](https://github.com/preprocess/pre-short-closures)[ Packagist](https://packagist.org/packages/pre/short-closures)[ RSS](/packages/pre-short-closures/feed)WikiDiscussions main Synced 2mo ago

READMEChangelog (10)Dependencies (2)Versions (19)Used By (0)

Short Closures
==============

[](#short-closures)

Documentation can be found at [preprocess.io](https://preprocess.io#short-closures).

> **Since [this RFC](https://wiki.php.net/rfc/arrow_functions_v2) was approved, we have standardised on the same syntax.** We do still allow function bodies and return type hints, but everything in that RFC can be done, with the same syntax, as far back as Yay will allow (7.1).

You can use closures with similar semantics to Javascript:

```
$files = array_map(
    fn($path) => file_get_contents($path),
    $paths
);

$needles = [
    "PHP",
    "Go",
    "Javascript",
];

$matches = array_filter($files, fn($content = "") => {
    foreach ($needles as $needle) {
        if (stristr($content, $needle)) {
            return true;
        }
    }

    return false;
});
```

These are converted to:

```
$files = array_map(
    function ($path) {
        return file_get_contents($path);
    },
    $paths
);

$needles = [
    "PHP",
    "Go",
    "Javascript",
];

$matches = array_filter($files, [$needles = $needles ?? null, $needle = $needle ?? null, "fn" => function ($content = "") use (&$needles, &$needle) {
    foreach ($needles as $needle) {
        if (stristr($content, $needle)) {
            return true;
        }
    }

    return false;
}]["fn"]);
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 91.2% 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 ~48 days

Recently: every ~173 days

Total

18

Last Release

2569d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/00089084814b5b79cd35b9f501bcc48d74c5afb2cb4703562a82e081f31c843c?d=identicon)[assertchris](/maintainers/assertchris)

---

Top Contributors

[![assertchris](https://avatars.githubusercontent.com/u/200609?v=4)](https://github.com/assertchris "assertchris (31 commits)")[![alepeino](https://avatars.githubusercontent.com/u/5054081?v=4)](https://github.com/alepeino "alepeino (3 commits)")

---

Tags

arrowclosuremacropreprocessor

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pre-short-closures/health.svg)

```
[![Health](https://phpackages.com/badges/pre-short-closures/health.svg)](https://phpackages.com/packages/pre-short-closures)
```

PHPackages © 2026

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