---
title: "lint/php-8.1"
pagination: false
---

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

Upgrade to PHP 8.1: code a newer PHP removes, deprecates or does better.

**[no-closure-from-callable](/docs/rules/lint/php-8-1/no-closure-from-callable)**

Change `Closure::fromCallable()` to first class callable syntax

In the `lint-recommended` preset and every stricter one. In Rector's `rector/php81` set. Safe fix. Runs only when `[php] version` is 8.1 or later.

**[no-null-preg-split-limit](/docs/rules/lint/php-8-1/no-null-preg-split-limit)**

Change null to strict int defined preg_split limit arg function call argument

In the `lint-recommended` preset and every stricter one. In Rector's `rector/php81` set. Safe fix. Runs only when `[php] version` is 8.1 or later.

**[no-null-string-argument](/docs/rules/lint/php-8-1/no-null-string-argument)**

Change null to strict string defined function call args

Not in any preset. Safe fix. Runs only when `[php] version` is 8.1 or later.

**[no-reflection-set-accessible](/docs/rules/lint/php-8-1/no-reflection-set-accessible)**

Remove Reflection::setAccessible() calls

In the `lint-recommended` preset and every stricter one. In Rector's `rector/php81` set. Safe fix. Runs only when `[php] version` is 8.1 or later.

**[prefer-enum-case-over-myclabs-call](/docs/rules/lint/php-8-1/prefer-enum-case-over-myclabs-call)**

Refactor MyCLabs enum fetch to Enum const

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-enum-case-over-spatie-call](/docs/rules/lint/php-8-1/prefer-enum-case-over-spatie-call)**

Refactor Spatie enum method calls

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-enum-from](/docs/rules/lint/php-8-1/prefer-enum-from)**

Refactor MyCLabs Enum using constructor for instantiation

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-first-class-callable](/docs/rules/lint/php-8-1/prefer-first-class-callable)**

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

Not in any preset. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-first-class-callable-argument](/docs/rules/lint/php-8-1/prefer-first-class-callable-argument)**

Upgrade string callback functions to first class callable

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-first-class-callable-over-array](/docs/rules/lint/php-8-1/prefer-first-class-callable-over-array)**

Upgrade array callable to first class callable

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-first-class-callable-over-arrow-function](/docs/rules/lint/php-8-1/prefer-first-class-callable-over-arrow-function)**

Convert nested arrow function call to first class callable

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-first-class-callable-over-closure](/docs/rules/lint/php-8-1/prefer-first-class-callable-over-closure)**

Convert closure with sole nested call to first class callable

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-native-enum-over-myclabs](/docs/rules/lint/php-8-1/prefer-native-enum-over-myclabs)**

Refactor MyCLabs enum class to native Enum

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-native-enum-over-spatie](/docs/rules/lint/php-8-1/prefer-native-enum-over-spatie)**

Refactor Spatie enum class to native Enum

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.

**[prefer-readonly-property](/docs/rules/lint/php-8-1/prefer-readonly-property)**

Decorate read-only property with `readonly` attribute

In the `lint-strict` preset. In Rector's `rector/php81` set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.1 or later.
