1.2.881. Only Variable Passed By Reference

Some methods require a variable as argument. Those arguments are passed by reference, and they must operate on a variable, or any data container (property, array element).

This means that literal values, constants cannot be used as argument. This is also the case of literal values, returned by other methods.

This is also the case of isset(), althought with a different error message.

<?php

echo end([1,2,3]);

function foo() {
     return [4,5,6];
}

echo end(foo());

?>

1.2.881.1. Suggestions

  • Put the value in a variable before using it with the function.

1.2.881.2. Specs

Short name

Php/OnlyVariablePassedByReference

Rulesets

All, Analyze, Changed Behavior, LintButWontExec

Exakat since

2.6.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Note

This issue may lint but will not run

Available in

Entreprise Edition, Exakat Cloud