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 2w 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 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

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

979d 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.0k9.8M298](/packages/deptrac-deptrac)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67475.0M1.6k](/packages/phpstan-phpstan-doctrine)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136411.0k14](/packages/rector-rector-src)[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87766.6k61](/packages/ticketswap-phpstan-error-formatter)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

39255.4k37](/packages/ec-europa-toolkit)[worksome/coding-style

Worksomes coding style

49826.1k69](/packages/worksome-coding-style)

PHPackages © 2026

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