Beispiel #1
0
 /**
  * Create sources
  */
 public function dump()
 {
     /* dump project map */
     $this->put('report/project_map.txt', ToolKit::dump($this->project));
     /* import helpers and resources */
     $this->import(['gitignore' => '.gitignore']);
     $this->import('koda_helper.h');
     $this->import('koda_helper.c', true);
     /* dump main module C-file */
     $this->file('php_' . $this->code, $this->extH(), $this->extC());
     /* dump classes */
     foreach ($this->project->classes as $class) {
         $this->file(str_replace('\\', '/', $class->name), $this->classH($class), $this->classC($class));
     }
     /* generate config.m4 for unix-like system, see http://www.php.net/manual/en/internals2.buildsys.configunix.php */
     $this->put('config.m4', $this->m4());
     /* generate config.w32 for windows, see http://www.php.net/manual/en/internals2.buildsys.configwin.php */
     $this->put('config.w32', $this->w32());
 }
Beispiel #2
0
 /**
  *
  * @param EntityFunction $callable
  * @param \ReflectionFunctionAbstract $reflection
  * @return $this
  */
 public static function parseCallable(EntityFunction $callable, \ReflectionFunctionAbstract $reflection)
 {
     $doc = $reflection->getDocComment();
     $params = [];
     if ($doc) {
         $info = ToolKit::parseDoc($doc);
         $callable->setDescription($info['desc']);
         $callable->setReturnInfo($info['return']['type'], $reflection->returnsReference(), $info['return']['desc']);
         $callable->setOptions($info['options']);
         $params = $info["params"];
     } else {
         $info = [];
     }
     /* @var \ReflectionParameter[] $params */
     foreach ($reflection->getParameters() as $param) {
         $argument = new EntityArgument($param->name);
         if (isset($params[$param->name]["desc"])) {
             $argument->description = $params[$param->name]["desc"];
         }
         if ($callable->getLine()) {
             $argument->setLine($callable->getLine());
         }
         $argument->setOptional($param->isOptional());
         $argument->setNullAllowed($param->allowsNull());
         $argument->setValue($param->isDefaultValueAvailable() ? $param->getDefaultValue() : null, $param->isPassedByReference());
         $argument->setByRef($param->isPassedByReference());
         /** @var \ReflectionParameter $param */
         if ($param->isArray()) {
             $argument->setCast(Types::ARR);
         }
         if ($c = $param->getClass()) {
             $argument->setCast(Types::OBJECT, $c->name);
         } elseif (isset($info['params'][$param->name])) {
             $_type = $info['params'][$param->name]["type"];
             if (strpos($_type, "|") || $_type === "mixed") {
                 // multiple types or mixed
                 $argument->setCast(Types::MIXED);
             } else {
                 if (strpos($_type, "[]")) {
                     $argument->setCast(Types::ARR, rtrim($_type, '[]'));
                 }
                 if (isset(Types::$codes[$_type])) {
                     $argument->setCast(Types::getType($_type));
                 } else {
                     $argument->setCast(Types::OBJECT, ltrim($_type, '\\'));
                 }
             }
         } else {
             $argument->warning("not documented");
         }
         $callable->pushArgument($argument);
     }
 }
 /**
  * @param string $name
  */
 public function __construct($name)
 {
     $this->name = $name;
     list($this->ns, $this->short) = ToolKit::splitNames($name);
 }
Beispiel #4
0
 /**
  * @param string $name
  */
 public function __construct($name)
 {
     $this->name = $name;
     list($this->ns, $short_class, $this->short) = ToolKit::splitNames($name);
     $this->class_name = $this->ns . '\\' . $short_class;
 }
Beispiel #5
0
 /**
  * Dump project to stdout
  * @return string
  */
 public function getDump()
 {
     $project = \Koda\Project::composer($this->root);
     $project->scan();
     return ToolKit::dump($project);
 }
Beispiel #6
0
 /**
  * @param string $class
  */
 public function __construct($class)
 {
     $this->name = $class;
     list($this->ns, $this->short) = ToolKit::splitNames($class);
     $this->cname = str_replace('\\', '_', $class);
     $this->escaped = addslashes($class);
     //        $this->extension  = $ref->getExtension();
 }
 /**
  * @param string $name
  */
 public function __construct($name)
 {
     list($this->ns, $base, $item) = ToolKit::splitNames($name);
     $this->short = $item ?: $base;
     $this->name = $name;
 }