/**
  * {@inheritdoc}
  */
 public function getDefinition($name, MergeableDefinition $parentDefinition = null)
 {
     // Only merges with class definition
     if ($parentDefinition && !$parentDefinition instanceof ClassDefinition) {
         return null;
     }
     $className = $parentDefinition ? $parentDefinition->getClassName() : $name;
     if (!class_exists($className) && !interface_exists($className)) {
         return null;
     }
     $class = new ReflectionClass($className);
     $definition = new ClassDefinition($name);
     // Constructor
     $constructor = $class->getConstructor();
     if ($constructor && $constructor->isPublic()) {
         $definition->setConstructorInjection($this->getConstructorInjection($constructor));
     }
     // Merge with parent
     if ($parentDefinition) {
         $definition = $parentDefinition->merge($definition);
     }
     return $definition;
 }
 /**
  * {@inheritdoc}
  * @throws AnnotationException
  * @throws InvalidArgumentException The class doesn't exist
  */
 public function getDefinition($name, MergeableDefinition $parentDefinition = null)
 {
     // Only merges with class definition
     if ($parentDefinition && !$parentDefinition instanceof ClassDefinition) {
         return null;
     }
     $className = $parentDefinition ? $parentDefinition->getClassName() : $name;
     if (!class_exists($className) && !interface_exists($className)) {
         return $parentDefinition;
     }
     $class = new ReflectionClass($className);
     $definition = new ClassDefinition($name);
     $this->readInjectableAnnotation($class, $definition);
     // Browse the class properties looking for annotated properties
     $this->readProperties($class, $definition);
     // Browse the object's methods looking for annotated methods
     $this->readMethods($class, $definition);
     // Merge with parent
     if ($parentDefinition) {
         $definition = $parentDefinition->merge($definition);
     }
     return $definition;
 }
 /**
  * {@inheritdoc}
  * @throws AnnotationException
  * @throws InvalidArgumentException The class doesn't exist
  */
 public function getDefinition($name, MergeableDefinition $parentDefinition = null)
 {
     // Only merges with class definition
     if ($parentDefinition && !$parentDefinition instanceof ClassDefinition) {
         return null;
     }
     $className = $parentDefinition ? $parentDefinition->getClassName() : $name;
     if (!class_exists($className) && !interface_exists($className)) {
         return $parentDefinition;
     }
     $class = new ReflectionClass($className);
     $definition = new ClassDefinition($name);
     // Injectable annotation
     /** @var $injectableAnnotation Injectable|null */
     try {
         $injectableAnnotation = $this->getAnnotationReader()->getClassAnnotation($class, 'DI\\Annotation\\Injectable');
     } catch (UnexpectedValueException $e) {
         throw new DefinitionException(sprintf('Error while reading @Injectable on %s: %s', $class->getName(), $e->getMessage()), 0, $e);
     }
     if ($injectableAnnotation) {
         if ($injectableAnnotation->getScope()) {
             $definition->setScope($injectableAnnotation->getScope());
         }
         if ($injectableAnnotation->isLazy() !== null) {
             $definition->setLazy($injectableAnnotation->isLazy());
         }
     }
     // Browse the class properties looking for annotated properties
     $this->readProperties($class, $definition);
     // Browse the object's methods looking for annotated methods
     $this->readMethods($class, $definition);
     // Merge with parent
     if ($parentDefinition) {
         $definition = $parentDefinition->merge($definition);
     }
     return $definition;
 }