samlitowitz / unset-foreach-loop-references
v1.0.1
2023-12-14 11:04 UTC
Requires
- php: ^7.2 || ^8.0
- phpstan/phpstan: ^1.10
Requires (Dev)
- nikic/php-parser: ^4.18
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^8.5
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);