Beispiel #1
0
 function templateArgs($args)
 {
     if ($args != null) {
         return $args;
     }
     $result = array();
     $rc = new ReflectionObject($this);
     foreach ($rc->getProperties() as $prop) {
         $key = $prop->getName();
         $val = $this->{$key};
         if (is_object($val)) {
             $rcProp = new ReflectionObject($val);
             if ($rcProp->isSubClassOf('TemplateControl')) {
                 $result[$key] = $val->render();
             }
         } else {
             $result[$key] = $val;
         }
     }
     return $result;
 }
 /**
  * @param ReflectionParameter $parameter
  * @param CollectionInterface $properties
  *
  * @return bool
  */
 private function canInject(\ReflectionParameter $parameter, CollectionInterface $properties) : bool
 {
     if (!$parameter->allowsNull() && !$properties->hasKey($parameter->name)) {
         return false;
     } else {
         if ($parameter->allowsNull() && !$properties->hasKey($parameter->name)) {
             return false;
         }
     }
     $property = $properties[$parameter->name];
     if ($parameter->hasType()) {
         $type = $parameter->getType();
         if ($type->isBuiltin()) {
             return (string) $type === gettype($property);
         } else {
             if (!is_object($property)) {
                 return false;
             }
         }
         $refl = new \ReflectionObject($property);
         $wishedClass = (string) $type;
         return get_class($property) === $wishedClass || $refl->isSubClassOf($wishedClass);
     }
     return true;
 }