Avoid passing the variables of a function by reference(PHP) | CAST Appmarq

Avoid passing the variables of a function by reference(PHP)


Rule Definition
Most of the times the functions only need to use the values from their parameters without changing them. In such cases, you can safely pass those parameters by reference (e.g., function(&$parameter) rather than value (e.g function($parameter)) and avoid having to make memory-intensive copies and therefore increase the performance of the application.

Remediation
try and passe the parameters by reference when these parameters are only used in read mode.

Violation Code Sample
<?php

function($parameter) 
{
$test = $parameter
}
?>
Fixed Code Sample
<?php

function(&$parameter) 
{
$test = $parameter
}
?>

Related Technologies

Health Factor

  Efficiency


Technical Criterion
Efficiency - Memory, Network and Disk Space Management

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.

Benchmark Statistics

Global Compliance

100.00%

Total Violations
0
Total Opportunities
72,554
Average Violations / App.
0.00
The compliance score represents 1 minus the ratio between the number of times a rule has been violated compared to the number of opportunities in a set of applications that the rule could have been violated.

Industry Insights

Don't Know

100.00%

Energy

100.00%

Government

100.00%