1.2.750. Must Use Result, So It Returns

A method or function that uses the #[MustUseResult] attribute, must return a value.

Hence, it cannot use the void and never returntypes, and it must use a return in the body of the method.

See also https://github.com/DaveLiddament/php-language-extensions?tab=readme-ov-file#mustuseresult.

1.2.750.1. Connex PHP features

1.2.750.1.1. Suggestions

  • Add a type and return to the method.

1.2.750.1.2. Specs

Short name

Attributes/MustUseReturnReturns

Rulesets

All, Attributes

Exakat since

2.6.8

PHP Version

With PHP 8.0 and more recent

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Related rule

MustUseResult

Available in