Exemple #1
0
 /**
  * Main constructor.
  *
  * @param String $name  Name of the component
  */
 public function __construct($parent, $name, $parentClass)
 {
     parent::__construct($parent, $name);
     $this->parentClass = $parentClass;
 }
 /**
  * Extract all libs of the project. 'Base' classes are excluded no keep quiet
  * a clean list of class used. Class starting as sf and Doctrine are considered
  * as symfony native classes.
  */
 protected function processLib($path = null, $required = true, $prune = array(), $not_name = array())
 {
     $classes = array();
     $interfaces = array();
     if (is_null($path)) {
         $path = $this->paths['sf_lib_dir'];
     }
     $libObjects = $this->extractClasses($path, $prune, $not_name);
     $ignoredClasses = $this->getIgnoredObjects('classes');
     foreach ($libObjects as $class => $filePath) {
         // Exclude Base classes
         if (0 === strpos($class, 'Base')) {
             continue;
         }
         $object = null;
         if (class_exists($class)) {
             // Create the reflection object
             $reflectionClass = new ReflectionClass($class);
             try {
                 $parent = $reflectionClass->getParentClass();
             } catch (Exception $e) {
             }
             while ($parent instanceof ReflectionClass) {
                 // Break if no parent class
                 if (!$parent->getParentClass()) {
                     break;
                 }
                 // Break on 1st symfony parent
                 if (strpos($parent->getName(), 'sf') === 0 || strpos($parent->getName(), 'Doctrine_Table') === 0) {
                     break;
                 }
                 $parent = $parent->getParentClass();
             }
             // Test if the class is an extension of a symfony class
             if ($parent instanceof ReflectionClass && (strpos($parent->getName(), 'sf') === 0 || strpos($parent->getName(), 'Doctrine_Table') === 0)) {
                 $object = new paSfClass($this, $class, $parent->getName());
             } else {
                 $object = new paClass($this, $class);
             }
             // Look if we choose th ignore the class
             if (!in_array($object->getName(), $ignoredClasses)) {
                 $classes[] = $object;
             }
         } elseif (interface_exists($class)) {
             // Look if we choose th ignore the class
             if (!in_array($class, $ignoredClasses)) {
                 $object = new paInterface($this, $class);
                 $interfaces[] = $object;
             }
         } else {
             // Error
             if ($required) {
                 throw new RuntimeException('Class : ' . $class . ' not found, verify both its class name and file name case, if it seems like a bug of the plugin send me an email. :)');
             }
         }
         // Compute file length
         $fileContent = file_get_contents($filePath);
         // Keep the file name in the object ??
         if ($object) {
             $object->setCodeLength(empty($fileContent) ? 0 : count(explode("\n", $fileContent)));
         }
     }
     $this->interfaces = array_merge($this->interfaces, $interfaces);
     $this->classes = array_merge($this->classes, $classes);
 }