PHP renderer generator: moved serialization of the internal representation to PHP to its own class