Mantis - Quercus
Viewing Issue Advanced Details
3232 minor always 01-09-09 07:43 01-09-09 16:47
haplo  
nam  
normal  
closed 3.2.1  
fixed  
none    
none 4.0.0  
0003232: PostIncrement doesn't work when fields are accessed using magic getter and setter methods
If a member field is accessed using the php magic getter and setter method the post increment doesnt work on thoes fields

Test:


<?php
class method_test {

private $number;

public function __construct(){
$this->number = 4;
}

public function getNumber(){
return $this->number;
}

public function setNumber($value){
$this->number = $value;
}

public function __get($value){
$getter='get'.$value;
if(method_exists($this,$getter))
{
return $this->$getter();
}
throw new Exception("Method ('$getter') does not exists");
}

public function __set($name, $value){
$setter='set'.$name;
if(method_exists($this,$setter))
{
$this->$setter($value);

} else {
throw new Exception("Method ('$setter') does not exists");
}
}

}

/* 1. Test does work! */
$test = new method_test();
echo '1. Number: ' . $test->Number . '';
$test->Number = $test->Number +1;
echo '2. Number: ' . $test->Number . '';
echo 'Number is 5? ' . ($test->Number == 5 ? 'Yes' : 'No');

/* 2. Test doesn't work */
$test = new method_test();
echo '1. Number: ' . $test->Number . '';
$test->Number ++;
echo '2. Number: ' . $test->Number . '';
echo 'Number is 5? ' . ($test->Number == 5 ? 'Yes' : 'No');

Notes
(0003714)
nam   
01-09-09 16:47   
php/09kp
php/09kq
php/39kp
php/39kq