Issue #1 new

setVar() methods do not pass by reference

Ferry Boender
repo owner created an issue

The setVar() methods do not pass variables by reference. Instead, they are passed by value, which means a copy will be made by PHP. This is both slower and does not allow the user to modify the variable (in the case of arrays, most commonly) after it is set in the templum or template instance.

This can be changed by modifying the following lines:

public function setVar($varName, $varValue) {
    $this->varsUniversal[$varName] = $varValue;

into:

public function setVar($varName, &$varValue) {
    $this->varsUniversal[$varName] = &$varValue;

This solution needs to be tested. It may not work properly in PHP4 (which may be dropped as a supported version).

Comments (0)

  1. Log in to comment