CRITICAL
Rule Definition
If the variable is passed by reference when calling a function even though function signature does not accept parameter by reference, it may give unexpected result if value is changed and it is not expected behaviour.
Remediation
If the value change is expected, change the function signature to denote that variables will be passed by reference or return changed value and assign it to variable.
Violation Code Sample
<?php
class myclass extends yourclass implements someint {
function myfunc($var) {
echo $var;
}
}
$myvar = true;
myfunc(&$myvar);
Fixed Code Sample
<?php
class myclass extends yourclass implements someint {
function myfunc($var) {
echo $var;
}
}
$myvar = true;
myfunc($myvar);
Reference
Code Sniffer - https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php
Related Technologies
Technical Criterion
Complexity - Dynamic Instantiation
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.