Beispiel #1
0
 public function getPublicMethodsStartingWith($startsWith = 'set')
 {
     return ReflectionHelper::getMethodsStartingWith($this, $startsWith);
 }
Beispiel #2
0
 public function isScalarReturn()
 {
     return ReflectionHelper::isScalar($this->getReturnType());
 }
Beispiel #3
0
 /**
  * @param type $path
  * @return DependencyIndex
  */
 public function buildIdex($path)
 {
     $debug = false;
     $index = new DependencyIndex();
     $tokenizers = Helper::getMethodsStartingWith(new \ReflectionClass(__CLASS__), 'tokenize');
     foreach ($this->getDirectoryFiles($path) as $relpath => $filename) {
         $tokenize = new Tokenize($filename);
         #echo $tokenize->dumpAllTokens(array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT));
         /**
          * Get namespace for a file, as if it was PSR0
          */
         $namespace = $tokenize->getNamespace();
         /**
          * Get all classes and prepend a namespace
          */
         foreach ($tokenize->getAllClasses() as $className) {
             $index->addClass($relpath, $namespace, $className);
         }
         /**
          * Classes and interfaces fit the same array
          */
         foreach ($tokenize->getAllInterfaces() as $interfaceName) {
             $index->addClass($relpath, $namespace, $interfaceName);
         }
         /**
          * This option could be configurable, as we may want to process
          * files like bootstraps or smth. But later.
          */
         if (!$index->hasClasses($relpath)) {
             continue;
         }
         if ($debug) {
             echo "Processing {$relpath}", PHP_EOL;
         }
         if ($debug) {
             echo "Classes found: ", join(', ', $index->getClasses($relpath)), PHP_EOL;
         }
         $uses = $tokenize->getUses();
         foreach ($uses as $alias => $className) {
             $index->addAliasedDependency($relpath, $alias, $className);
         }
         foreach (Helper::reduceMethodGroupResultToArray($tokenizers, $this, $tokenize) as $alias) {
             //echo "ALIAS: $relpath: $alias\n";
             $index->addNamespacedDependency($relpath, $namespace, $alias);
         }
         if ($index->hasDependencies($relpath)) {
             if ($debug) {
                 echo "Dependencies found: ", join(', ', $index->getDependencies($relpath)), PHP_EOL;
             }
         }
     }
     return $index;
 }