ZF-9831: Apparent difference b/w documentation for add() and sub() and actual behavior
The 1.10 documentation reads: http://zendframework.com/manual/en/…
bq. ... Each addition will create a new object for the result. The actual object will never be changed by the class.
Considering a simple example, slightly modified from the documentation:
require_once('Zend/Measure/Length.php'); $unit = new Zend_Measure_Length(200, Zend_Measure_Length::CENTIMETER); $unit2 = new Zend_Measure_Length(1, Zend_Measure_Length::METER); echo "$unit + $unit2 = ?\n"; $sum = $unit->add($unit2); echo "$unit + $unit2 = $sum\n";
Has an actual result of:
200 cm + 1 m = ? 300 cm + 100 cm = 300 cm
By my reading of the documentation, I expect that the $unit variable will not be modified. Note that, however, $unit IS modified.
I do not know if this is a change from previous versions, a documentation issue, an issue in my version/build (5.2.12-pl0-gentoo) or a misunderstanding on my part.