1.2.113. Cant Use Return Value In Write Context

empty() used to work only on data containers, such as variables. Until PHP 5.5, it was not possible to use directly expressions, such as functioncalls, inside an empty() function call : they were met with a ‘Can’t use function return value in write context’ fatal error.

This also applies to methodcalls, static or not.

<?php

function foo($boolean) {
    return $boolean;
}

// Valid since PHP 5.5
echo empty(foo(true)) : 'true' : 'false';

?>

See also Cant Use Return Value In Write Context.

1.2.113.1. Specs

Short name

Php/CantUseReturnValueInWriteContext

Rulesets

All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54

Exakat since

0.8.4

PHP Version

With PHP 5.5 and more recent

Severity

Major

Time To Fix

Quick (30 mins)

Precision

Very high

Features

return

Available in

Entreprise Edition, Exakat Cloud