4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Command\ListCommand;
14 use Symfony\Component\Console\Input\InputInterface;
17 * Trait Enumerator class.
19 class TraitEnumerator extends Enumerator
24 protected function listItems(InputInterface $input, \Reflector $reflector = null, $target = null)
26 // bail early if current PHP doesn't know about traits.
27 if (!function_exists('trait_exists')) {
31 // only list traits when no Reflector is present.
33 // @todo make a NamespaceReflector and pass that in for commands like:
37 // ... for listing traits in the Foo namespace
39 if ($reflector !== null || $target !== null) {
43 // only list traits if we are specifically asked
44 if (!$input->getOption('traits')) {
48 $traits = $this->prepareTraits(get_declared_traits());
60 * Prepare formatted trait array.
62 * @param array $traits
66 protected function prepareTraits(array $traits)
70 // My kingdom for a generator.
73 foreach ($traits as $name) {
74 if ($this->showItem($name)) {
77 'style' => self::IS_CLASS,
78 'value' => $this->presentSignature($name),