Quick search:


What is a reference anomaly

uninitialized php variables or associations arbitrarily holding values that come from another variable

Because php 4 tends to copy objects every time they are assigned to a variable or passed by or to a function, phpPeanuts extensively uses variable references. We occasionally ran into a variable or array that suddenly held a value that was clearly not put there by our code. It was previously assigned to a totally different variable. Once it even came out of an array whenever we asked for a key that was not present. In other occasions the variable was uninitialized. 

In version 1.0a a workaround was introduced: When returning a reference to a field value of a primitive type returned by value by a method call, assigning the value to a temporary variable and returning a referency to that variable seemed to solve the problem. Version 2.0 no longer uses variable references for objects.

Because the reproduction of these anomalies requires all the code that was run, including the framework, as well as the data, we did not yet come across a situation feasable to be properly documented in a bug report, so we never reported it to php.net. However, php 4.4.0 release announcement problems are descibed that may be Reference Anomalies or may be related to them. Remarkebly enough a new reference anomaly was found when the changes where made to get rid of reference notifications triggered by php5.2. The anomaly disappeared after the conversion of references to values and vice versa where avoided whenever possible.

PhpPeanuts 2.0 does not support php 4 so variable references are no longer needed for handling objects. Version 1.x is kept portable between php4 and php5, so variable references are still used, but since version 1.3.beta3 we try to avoid reference nofitications, avoid the use of variable references for arrays, avoid returning references to variables that do not exist and try to avoid converting values to references and vice versa. Read How to avoid Reference Anomalies.

PS. Returning a reference to an uninitialized variable is quite an effective way make the current script crash without notice. The fields causing anomalies had been initialized.