/**
  * detects name for binding
  *
  * @param   \ReflectionParameter     $param
  * @param   string|\ReflectionClass  $default
  * @return  string|\ReflectionClass
  */
 private function detectBindingName(\ReflectionParameter $param, $default = null)
 {
     $annotations = annotationsOf($param);
     if ($annotations->contain('List')) {
         return $annotations->firstNamed('List')->getValue();
     }
     if ($annotations->contain('Map')) {
         return $annotations->firstNamed('Map')->getValue();
     }
     if ($annotations->contain('Named')) {
         return $annotations->firstNamed('Named')->getName();
     }
     if ($annotations->contain('Property')) {
         return $annotations->firstNamed('Property')->getValue();
     }
     return $default;
 }
 /**
  * @test
  * @since  5.4.0
  */
 public function annotationsPresentOnClass()
 {
     assertTrue(annotationsOf($this->exceptionLogger)->contain('Singleton'));
 }
Example #3
0
 /**
  * returns binding denoted by annotations on type to create
  *
  * An annotated binding is when the type to create is annotated with
  * @ImplementedBy oder @ProvidedBy.
  *
  * If this is not the case it will fall back to the implicit binding.
  *
  * @param   \ReflectionClass  $class
  * @return  \stubbles\ioc\binding\Binding|null
  */
 private function getAnnotatedBinding(\ReflectionClass $class)
 {
     $annotations = annotationsOf($class);
     if ($class->isInterface() && $annotations->contain('ImplementedBy')) {
         return $this->bind($class->getName())->to($this->findImplementation($annotations, $class->getName()));
     } elseif ($annotations->contain('ProvidedBy')) {
         return $this->bind($class->getName())->toProviderClass($annotations->firstNamed('ProvidedBy')->getProviderClass());
     }
     return $this->getImplicitBinding($class);
 }