Couch on PHP ではまったこと

Couch on PHP の REAEME のサンプルコードより抜粋

// document fetching by ID
$doc = $client->getDoc('some_doc_id');
// updating document
$doc->newproperty = array("hello !","world");
try {
   $client->storeDoc($doc);
} catch (Exception $e) {
   echo "Document storage failed : ".$e->getMessage()."<BR>\n";
}

ここで $client->getDoc() から返ってきた $doc と、

//using couch_document class :
$doc = new couchDocument($client);
$doc->set( array('_id'=>'JohnSmith','name'=>'Smith','firstname'=>'John') ); //create a document and store it in the database
echo $doc->name ; // should echo "Smith"
$doc->name = "Brown"; // set document property "name" to "Brown" and store the updated document in the database

ここで new couchDocument() により返ってくる $doc 。

どうして全くの別物だと思えよう。変数名同じだし。普通のORMならデータベースから取得してきたものと新規で作るものの型が違うなどとは思いも寄らない。
格納の仕方が両者で違うのでおかしいとは思っていたが、結論から言うと前者は stdClass のインスタンス。当然 set メソッドは存在しない。

これと先のトラブルもあいまって1日嵌った。サンプルコードとはいえ、型が違うなら変数名も変えて欲しいと思った。