The CList method setReadOnly() is protected and thus cannot be called from the scope you're using, only from within itself or inheriting classes. See http://php.net/manual/en/language.oop5.visibility.php#example-188.
However, the CList class allows the list to be set as read only in its constructor
public function __construct($data=null,$readOnly=false)
{
if($data!==null)
$this->copyFrom($data);
$this->setReadOnly($readOnly);
}
So...
$list = new CList(array('python', 'ruby'), true); // Passing true into the constructor
$anotherList = new CList(array('php'));
$list->mergeWith($anotherList);
Results in the error
CException The list is read only.
I'm not sure if that's the result you're looking for, but if you want a read only CList that's one way to get it.
You might think when merging subsequent CLists you could set readonly true at the end, however mergeWith() only merges the _d data array, not the other class variables, so it remains false.
$list = new CList(array('python', 'ruby'));
$anotherList = new CList(array('php'));
$yetAnotherList = new CList(array('javacript'), true);
$list->mergeWith($anotherList);
$list->mergeWith($yetAnotherList);
var_dump($list); // ["_r":"CList":private]=>bool(false)