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.7kApache-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 2d 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

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

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

Total

2

Last Release

933d 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

[deptrac/deptrac

Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.

3.0k8.8M118](/packages/deptrac-deptrac)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87718.9k56](/packages/ticketswap-phpstan-error-formatter)[slam/phpstan-extensions

Slam extension of phpstan

712.6M81](/packages/slam-phpstan-extensions)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

40252.8k34](/packages/ec-europa-toolkit)[ergebnis/rector-rules

Provides rules for rector/rector.

10245.6k52](/packages/ergebnis-rector-rules)

PHPackages © 2026

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