samlitowitz/unset-foreach-loop-references

v1.0.1 2023-12-14 11:04 UTC

This package is auto-updated.

Last update: 2024-10-25 17:41:49 UTC


README

Usage

To use these rules, require it via Composer

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

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

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