PHPackages                             samlitowitz/unset-foreach-loop-references - 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. samlitowitz/unset-foreach-loop-references

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

samlitowitz/unset-foreach-loop-references
=========================================

v1.0.1(2y ago)02.0kApache-2.0PHPPHP ^7.2 || ^8.0

Since Dec 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/samlitowitz/unset-foreach-loop-references)[ Packagist](https://packagist.org/packages/samlitowitz/unset-foreach-loop-references)[ RSS](/packages/samlitowitz-unset-foreach-loop-references/feed)WikiDiscussions master Synced 1mo ago

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

A PHPStan rule to enforce the unsetting of foreach value references immediately after use
=========================================================================================

[](#a-phpstan-rule-to-enforce-the-unsetting-of-foreach-value-references-immediately-after-use)

Usage
=====

[](#usage)

To use these rules, require it via [Composer](https://getcomposer.org/)

```
composer require samlitowitz/unset-foreach-loop-references --dev

```

Include rules.neon in your project's PHPStan config

```
includes:
    - vendor/samlitowitz/unset-foreach-loop-references/rules.neon

```

Examples
========

[](#examples)

Not Allowed
-----------

[](#not-allowed)

```
$a = [1, 2, 3];
foreach ($a as &$r1) {
}
foreach ($a as $v) {
	print_r($a);
}
```

```
$a = [1, 2, 3];
foreach ($a as &$r1) {
}
foreach ($a as $v) {
	print_r($a);
}
unset($r1);
```

Allowed
-------

[](#allowed)

```
$a = [1, 2, 3];
foreach ($a as &$r2) {
}
unset($r2);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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 ~0 days

Total

2

Last Release

879d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e6d6a1f93b670732d251551067a2e17b9f1a180d164036f0a84896bc95f9edba?d=identicon)[samlitowitz](/maintainers/samlitowitz)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/samlitowitz-unset-foreach-loop-references/health.svg)

```
[![Health](https://phpackages.com/badges/samlitowitz-unset-foreach-loop-references/health.svg)](https://phpackages.com/packages/samlitowitz-unset-foreach-loop-references)
```

###  Alternatives

[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87578.8k35](/packages/ticketswap-phpstan-error-formatter)[slam/phpstan-extensions

Slam extension of phpstan

702.5M74](/packages/slam-phpstan-extensions)[ramsey/devtools

A Composer plugin to aid PHP library and application development.

7134.7k26](/packages/ramsey-devtools)[johnbillion/wp-compat

PHPStan extension to help verify that your PHP code is compatible with a given version of WordPress

24115.0k10](/packages/johnbillion-wp-compat)

PHPackages © 2026

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