PHP 同名変数の使いまわし 値不具合

津路です。久しぶりに投稿です。
本日、あるクラスを作成して、そこにsetter,getter関数を実装しました。
具体的なコードは以下のようです。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | class Task {     private $_id;     private $_title;     private $_description;     public function __construct($id, $title, $description)     {         $this->setID($id);         $this->setTitle($title);         $this->setDescription($description);     }     public function getID() {         return $this->_id;     }     public function getTitle() {         return $this->_title;     }     public function getDescription() {         return $this->_description;     }     public function setID($id) {         if(($id !== null) && (!is_numeric($id) || $id<=0 || $id > 9223372036854775807 || $this->_id !== null)){             throw new TaskException("Task ID error");         }         $this->_id = $id;             }     public function setTitle($title){         if(strlen($title) < 0 || strlen($title) > 255){             throw new TaskException("Task Title error");         }         $this->_title = $title;             }     public function setDescription($description){         if(strlen($description) < 0 || strlen($description) > 16777215){             throw new TaskException("Task Description error");         }         $this->_description = $description;     } } | 
そして、利用側では、
| 1 2 3 4 5 6 7 8 |             $newtask = new Task(null,$jsonData->title,(isset($jsonData->description) ? $jsonData->description : null));             $title = $newtask->getTitle();             $descripton = $newtask->getDescription();             $query = $writeDB->prepare('insert into tbltasks (title,description) values(:title,:description,:userid)');             $query->bindParam(':title',$title,PDO::PARAM_STR);             $query->bindParam(':description',$description,PDO::PARAM_STR);             $query->bindParam(':userid',$returned_userid,PDO::PARAM_INT);             $query->execute(); | 
jsonDataとは、json形式のデータです。
 $title,$descriptionは、取り出したデータを入れる変数です。useridは、上記でnullです。
 これらをwriteDB変数を使ってデータベースに挿入しているわけですが、実際に、実行して、データベースを確認すると、descriptionがnullのままです。
 そこで、各所にechoを入れて確認したところ、$descripton = $newtask->getDescription(); の行でnullにどうしてもなってました。
 なぜかなと、クラス生成時の値を見ると、入ってます。長さも正常。
$description変数の値がnullというおぞましい結果。。。
 結局、変数名を変えることで、解決しました。
 同じ名前の変数をあちこちで使うといけないようです。
 と、変数名を少しずつチェックしていくと、$descriptonになっていて、iが抜けてることに気づきました。恥ずかしい。
 手動ゴリゴリコードはだめですね。PHPは実行しないとわからないし。。

