---
title: "lint/control-flow/prefer-yield-from"
pagination: false
---

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

<RuleId id="lint/control-flow/prefer-yield-from" />

In the [`code-quality`](/docs/rules/sets/code-quality) set. Safe fix.

## What it does

If the function explicitly returns an array, and has the return type `iterable`, then `yield from` must be used instead of `return`.

## Configuration

```toml title="pun.toml"
[lint.rules]
"control-flow/prefer-yield-from" = "error"
```

To skip it in some files, add an [override](/docs/configuration/pun-toml#lint) or a [`@pun-ignore-file`](/docs/configuration/ignore-comments) comment.

## Replaces

- [`return_to_yield_from`](https://cs.symfony.com/doc/rules/array_notation/return_to_yield_from.html) (php-cs-fixer)

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