zendframework/zf2 — pull request #6339 by steverhoades (2014-05-30 22:28:31+00:00)
Title: Closes issue #4876 - added support for trait generation and trait scanning

This is a first attempt at adding generation and scanning support for Traits.

For example usage please see ZendTest/Code/Generation/ClassGenerationTest.php

Example 1: Add a trait
```
$traitGenerator = new TraitGenerator();
$traitGenerator->setName('myTrait');
$traitGenerator->generate();
```

Outputs:
```
trait myTrait
{

}
```

Example 2: Add a trait to a class
```
$classGenerator = new ClassGenerator();
$classGenerator->setName('myClass');
$classGenerator->addTrait('myTrait');
```

Outputs:
```
class myClass
{
use myTrait;

}
```

Example 2: Add multiple traits with aliases and overrides
```
$classGenerator = new ClassGenerator();
$classGenerator->setName('myClass');
$classGenerator->addTraits(array('myTrait', 'hisTrait'));
$classGenerator->addTraitAlias('myTrait::foo', 'newfoo');
$classGenerator->addTraitOverride('hisTrait::bar', 'myTrait');
```

Outputs:
```
class myClass
{
use myTrait, hisTrait {
myTrait::foo as newfoo;
hisTrait::bar insteadof myTrait;
}

}
```