---
title: "analyse/types/by-ref-foreach-on-expression"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="analyse/types/by-ref-foreach-on-expression" />

In the [`analyse-basic`](/docs/rules/presets/analyse-basic) preset and every stricter one. Report only. Upstream gates: `bleedingEdge (featureToggles.assignToByRefForeachExpr)`.

## Configuration

```toml title="pun.toml"
[analyse.rules]
"types/by-ref-foreach-on-expression" = "on"
```

To skip it in some files or lines, add an [ignore comment](/docs/configuration/ignore-comments).

## Replaces

- [`AssignToByRefExprFromForeachRule`](https://phpstan.org/error-identifiers/assign.byRefForeachExpr) (phpstan-classes)
- [`assign.byRefForeachExpr`](https://phpstan.org/error-identifiers/assign.byRefForeachExpr) (phpstan)

[More analyse/types rules](/docs/rules/analyse/types) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
