---
title: "lint/phpunit/prefer-will-return-callback"
pagination: false
---

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

<RuleId id="lint/phpunit/prefer-will-return-callback" />

In the [`code-quality`](/docs/rules/sets/code-quality) set. Safe fix. Runs when phpunit is installed.

## What it does

Merge ->with($this->callback()) and ->willReturn() into willReturnCallback().

## Configuration

```toml title="pun.toml"
[lint.rules]
"phpunit/prefer-will-return-callback" = "error"
```

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

## Options

| Name | Type | Allowed values | Default | Upstream name |
| --- | --- | --- | --- | --- |
| `checks` | `list` | `merge-with-callable`, `void-method` | `["merge-with-callable", "void-method"]` | None (Pun's own) |

## Replaces

- [`MergeWithCallableAndWillReturn`](https://getrector.com/rule-detail/merge-with-callable-and-will-return-rector) (rector-phpunit)
- [`VoidMethodWithCallbackToWillReturnCallback`](https://getrector.com/rule-detail/void-method-with-callback-to-will-return-callback-rector) (rector-phpunit)

## Merged rules

These old IDs are now this rule. A config that still names one stops with an error. See [merged rules](/docs/migrate/merged-rules).

- `lint/phpunit/prefer-merged-will-return-callback`

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