Пример #1
0
 /**
  * Check if the found trait name is the one that we need to reflect.
  *
  * @param string $name The name of the trait found.
  * @return boolean
  */
 private function isSearchedTrait($name)
 {
     if ($this->name === $name) {
         return true;
     }
     if (strpos($name, '\\') === 0) {
         return $this->name === $name || '\\' . $this->name === $name;
     }
     $name = $this->declaringClass->getNamespaceName() . '\\' . $name;
     return $this->name === $name || $this->name === '\\' . $name;
 }
 /**
  * Generates a trait class
  *
  * @param ReflectionClass $reflectionClass
  *
  * @return string
  */
 protected function generateTrait(ReflectionClass $reflectionClass) : string
 {
     $generator = new TraitGenerator($reflectionClass->getShortName(), $reflectionClass->getNamespaceName());
     $this->getTraitGeneratorEnhancerTraverser()->traverse($generator);
     return '<?php' . str_repeat(PHP_EOL, 2) . $generator->generate();
 }