Zend\Code\Generator\ClassGenerator allows you to attach methods with optional content to your classes. Methods may be
attached as either arrays or concrete Zend\Code\Generator\MethodGenerator instances.

Zend\Code\Generator\FileGenerator can be used to generate the contents of a PHP file. You can include classes as
well as arbitrary content body. When attaching classes, you should attach either concrete
Zend\Code\Generator\ClassGenerator instances or an array defining the class.

In the example below, we will assume you’ve defined $foo per one of the class definitions in a previous
example.

You may add code to an existing class. To do so, first use the static fromReflection() method to map the class
into a generator object. From there, you may add additional properties or methods, and then regenerate the class.