---
title: "lint/php-8.1/prefer-first-class-callable"
pagination: false
---

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

<RuleId id="lint/php-8.1/prefer-first-class-callable" />

Not in any set. Unsafe fix: it can change behaviour. Gated by php-8.1.

## What it does

Use first-class callable syntax (`strlen(...)`) instead of closures, Closure::fromCallable() and string or array callables.

## Configuration

```toml title="pun.toml"
[lint.rules]
"php-8.1/prefer-first-class-callable" = "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).

## Replaces

- [`Pun/prefer_first_class_callable`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/) (pun)
- [`prefer-first-class-callable`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#prefer-first-class-callable) (mago-linter)

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