1.2.888. Only Variable Returned By Reference¶
Function can’t return literals by reference.
When a function returns a reference, it is only possible to return variables, properties or static properties.
Anything else, like literals or static expressions, yield a warning at execution time.
<?php
// Can't return a literal number
function &foo() {
return 3 + rand();
}
// bar must return values that are stored in a
function &bar() {
$a = 3 + rand();
return $a;
}
?>
1.2.888.1. Connex PHP features¶
1.2.888.1.1. Specs¶
Short name |
Structures/OnlyVariableReturnedByReference |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |