/**
  * @inheritDoc
  */
 public function canInject(&$instance, Dependency $dependency) : bool
 {
     foreach ($this->getDependencyInterfaces($dependency->getValue()) as $interface) {
         $injectionInterfaceName = $interface . 'Aware';
         if (is_subclass_of($dependency->getValue(), $injectionInterfaceName)) {
             return true;
         }
     }
     return false;
 }
示例#2
0
 /**
  * @inheritDoc
  */
 public function canInject(&$instance, Dependency $dependency) : bool
 {
     if (!$dependency instanceof PropertyDependency) {
         return false;
     }
     $adderName = $this->getAdderName($instance, $dependency->getPropertyName());
     if (empty($adderName)) {
         return false;
     }
     return true;
 }
 /**
  * @inheritDoc
  */
 public function canInject(&$instance, Dependency $dependency) : bool
 {
     if (!$dependency instanceof PropertyDependency) {
         return false;
     }
     $reflectionClass = new \ReflectionClass($instance);
     $propertyName = $dependency->getPropertyName();
     try {
         $reflectionClass->getProperty($propertyName);
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }
示例#4
0
 /**
  * @param Dependency $dependency
  * @return string
  */
 protected function getFavoriteStrategyDependencyTag(Dependency $dependency)
 {
     if ($dependency instanceof PropertyDependency) {
         $tag = 'property:' . $dependency->getPropertyName();
     } else {
         $value = $dependency->getValue();
         if (gettype($value) !== 'object') {
             $tag = 'type:' . gettype($value);
         } else {
             $tag = 'type:' . get_class($value);
         }
     }
     return $tag;
 }