Instantiating classes should not be the role of your nodes, but there should be some way to assign data to it
# assignment function
$node->assign(new myclass());
$node->next()->assign(new Foo());
# using public data & next members (no protection of encapsulated data)
$node->data = new myclass();
$node->next->data = new Foo();