public function getFunctions($ann, &$isCached = null)
 {
     $ann = strtolower(str_replace("@", "", $ann));
     $dirs = array_merge(array($ann), $this->dirs);
     $isCached = true;
     $loader = Remember::wrap('function-discovery', function ($args) use(&$isCached) {
         $functions = array();
         $isCached = false;
         $query = array_shift($args);
         $fs = new Filesystem($args);
         foreach ($fs->get($query, 'Callable') as $annotation) {
             $function = $annotation->getObject();
             $static = false;
             if ($function->isMethod()) {
                 $callback = [$function->getClass()->getName(), $function->getName()];
                 $static = $function->isStatic();
             } else {
                 $callback = $function->getName();
             }
             try {
                 $name = strtolower($annotation->getArg());
             } catch (Exception $e) {
                 $name = null;
             }
             $annotations = [];
             foreach ($annotation->getParent() as $annotation) {
                 $annotations[] = [strtolower($annotation->getName()), $annotation->getArgs()];
             }
             $wrapper = new TFunction($function->getFile(), $callback, $static);
             $wrapper->setAnnotations($annotations);
             if ($name) {
                 $functions[$name] = $wrapper;
             } else {
                 $functions[] = $wrapper;
             }
         }
         return $functions;
     });
     return $loader($dirs);
 }
Ejemplo n.º 2
0
 protected function getAnnotations()
 {
     $parser = new Notoj\Filesystem($this->dir);
     return $parser->getClasseS('Validate');
 }