Beispiel #1
0
 public function __construct(ClassScanner $classScanner, DirectoryScanner $directoryScanner)
 {
     $this->classScanner = $classScanner;
     $this->directoryScanner = $directoryScanner;
     
     $currentScannerClass = $classScanner;
     
     while ($currentScannerClass && $currentScannerClass->hasParentClass()) {
         $currentParentClassName = $currentScannerClass->getParentClass(); 
         //$this->parentClassScanners[$currentParentClassName] = null;
         if ($directoryScanner->hasClass($currentParentClassName)) {
             $currentParentClass = $directoryScanner->getClass($currentParentClassName);
             $this->parentClassScanners[$currentParentClassName] = $currentParentClass;
             $currentScannerClass = $currentParentClass;
         } else {
             $currentScannerClass = false;
         }
     }
     
     foreach ($interfaces = $this->classScanner->getInterfaces() as $iName) {
         if ($directoryScanner->hasClass($iName)) {
             $this->interfaceClassScanners[$iName] = $directoryScanner->getClass($iName);
         }
     }
     
     
 }
Beispiel #2
0
 /**
  * Return the parameters for a method
  * 
  * 3 item array:
  *     #1 - Class name, string if it exists, else null
  *     #2 - Optional?, boolean
  *     #3 - Instantiable, boolean if class exists, otherwise null
  * 
  * @return array 
  */
 public function compileScannerInjectionMethodParmeters(MethodScanner $methodScanner, $introspectionType)
 {
     $params = array();
     $parameterScanners = $methodScanner->getParameters(true);
     
     // rules according to type
     $rules = $this->getIntrospectionRuleset()->getRules($introspectionType);
     
     /* @var $p Zend\Code\Scanner\ParameterScanner */
     foreach ($parameterScanners as $p) {
         
         $paramName = $p->getName();
         
         // create array for this parameter
         $params[$paramName] = array();
         
         // get name, and class if it exists
         $pcName = $p->getClass();
         if ($this->directoryScanner->hasClass($pcName)) {
             $pc = $this->directoryScanner->getClass($pcName);
         }
         
         if ($pcName) {
             // @todo Should we throw an exception if its an unknown type?
             $params[$paramName][] = $pcName;
         } else {
             $params[$paramName][] = null;
         }
         
         if ($introspectionType == IntrospectionRuleset::TYPE_SETTER && $rules['paramCanBeOptional']) {
             $params[$paramName][] = true;
         } else {
             $params[$paramName][] = $p->isOptional(); 
         }
         
         if (isset($pc)) {
             $params[$paramName][] = ($pc->isInstantiable()) ? true : false;
         } else {
             $params[$paramName][] = null;
         }
         
     }
     return $params;
 }