public function rollOut(&$output)
 {
     // Basically, any this.variables in here never impact this object, they apply to the "this" function
     $masquerading_as_function = $function_name = $this->getFunctionName();
     if (substr($masquerading_as_function, 0, 7) == 'window.') {
         $masquerading_as_function = $function_name = substr($masquerading_as_function, 7);
     }
     $check_keys = array('summary', 'description', 'returns', 'tags', 'exceptions');
     if (!empty($output[$function_name]['aliases'])) {
         unset($output[$function_name]['aliases']);
         // This is implemented, it aliases nothing.
     }
     if ($this->isThis()) {
         $masquerading_as_function = $this->getThis();
     }
     $output[$function_name]['type'] = 'Function';
     if (!empty($output[$masquerading_as_function])) {
         $output[$masquerading_as_function]['type'] = 'Function';
     }
     if ($aliases = $this->getAliases()) {
         foreach ($aliases as $alias) {
             if (empty($output[$alias])) {
                 $output[$alias]['aliases'] = $function_name;
             }
         }
     }
     $parameters = $this->getParameters();
     foreach ($parameters as $parameter) {
         if ($parameter->isA(DojoVariable)) {
             $parameter_name = $parameter->getVariable();
             $parameter_type = $parameter->getType();
             if (strpos($parameter_type, '?')) {
                 $parameter_type = substr($parameter_type, 0, strlen($parameter_type) - 1);
                 $output[$function_name]['parameters'][$parameter_name]['optional'] = true;
             }
             if (strpos($parameter_type, '...')) {
                 $parameter_type = substr($parameter_type, 0, strlen($parameter_type) - 3);
                 $output[$function_name]['parameters'][$parameter_name]['repeating'] = true;
             }
             if (empty($output[$function_name]['parameters'][$parameter_name]['type']) || $parameter_type) {
                 $output[$function_name]['parameters'][$parameter_name]['type'] = $parameter_type;
             }
             $this->addBlockCommentKey($parameter->getVariable());
         }
     }
     if ($this->isAnonymous()) {
         $output[$function_name]['initialized'] = true;
         $declarations = $this->body->getExternalizedFunctionDeclarations($function_name);
         foreach ($declarations as $declaration) {
             $declaration->rollout($output);
         }
         $variables = $this->body->getExternalizedInstanceVariableNames($function_name, $this->getParameterNames());
         foreach ($variables as $variable) {
             $output[$function_name . '.' . $variable]['instance'] = $function_name;
         }
         $variables = $this->body->getExternalizedVariableNames($function_name, $this->getParameterNames());
         foreach ($variables as $variable) {
             list($first, ) = explode('.', $variable, 2);
             if (!is_array($output[$function_name]['parameters']) || !array_key_exists($first, $output[$function_name]['parameters'])) {
                 if (empty($output[$variable])) {
                     $output[$variable] = array();
                 }
             }
         }
     }
     foreach ($check_keys as $ck) {
         $this->addBlockCommentKey($ck);
     }
     $this->addBlockCommentKeySet('example');
     $check_keys[] = 'example';
     $output[$function_name]['source'] = $this->getSource();
     $all_variables = array();
     $instance_variables = $this->getInstanceVariableNames();
     foreach ($instance_variables as $instance_variable) {
         $this->addBlockCommentKey($instance_variable);
         $all_variables[] = $instance_variable;
         $full_variable_name = "{$masquerading_as_function}.{$instance_variable}";
         $output[$full_variable_name]['instance'] = $masquerading_as_function;
     }
     $instance_functions = $this->getInstanceFunctions($function_name);
     foreach ($instance_functions as $instance_function) {
         $instance_function->rollOut($output);
         $output[$instance_function->getFunctionName()]['instance'] = $function_name;
     }
     $comment_keys = $this->getBlockCommentKeys();
     foreach ($comment_keys as $key) {
         if ($key == 'returns') {
             $output[$function_name]['return_summary'] = $this->getBlockComment($key);
         } elseif (in_array($key, $check_keys)) {
             $output[$function_name][$key] = $this->getBlockComment($key);
         }
         if (in_array($key, $all_variables) && ($comment = $this->getBlockComment($key))) {
             list($type, $comment) = preg_split('%\\s+%', $comment, 2);
             $type = preg_replace('%(^[^a-zA-Z0-9._$]|[^a-zA-Z0-9._$?]$)%', '', $type);
             if ($type) {
                 $output[$function_name . '.' . $key]['type'] = $type;
             }
             $output[$function_name . '.' . $key]['summary'] = $comment;
         }
         if (!empty($output[$function_name]['parameters']) && array_key_exists($key, $output[$function_name]['parameters']) && ($comment = $this->getBlockComment($key))) {
             list($tags, $parameter_type, $options, $summary) = DojoFunctionDeclare::parseVariable($comment);
             // If type is specified in the parameters, and it doesn't
             // match the first word in this comment block, assume that
             // this first word doesn't represent its type
             if (!empty($output[$function_name]['parameters'][$key]['type']) && $parameter_type != $output[$function_name]['parameters'][$key]['type']) {
                 $summary = $comment;
                 $parameter_type = $output[$function_name]['parameters'][$key]['type'];
             }
             $output[$function_name]['parameters'][$key] = array_merge($output[$function_name]['parameters'][$key], $options);
             $output[$function_name]['parameters'][$key]['type'] = $parameter_type;
             $output[$function_name]['parameters'][$key]['summary'] = htmlentities($summary);
         }
     }
     $returns = $this->getReturnComments();
     if (count($returns)) {
         $output[$function_name]['returns'] = implode('|', $returns);
     }
     if ($output[$function_name]['example']) {
         $output[$function_name]['examples'] = $output[$function_name]['example'];
         unset($output[$function_name]['example']);
     }
     if ($calls = $this->getThisInheritanceCalls()) {
         foreach ($calls as $call) {
             $output[$function_name]['chains']['call'][] = $call;
         }
     }
     if ($this->getPrototype()) {
         $output[$function_name]['prototype'] = $this->getPrototype();
     }
     if ($this->getInstance()) {
         $output[$function_name]['instance'] = $this->getInstance();
     }
 }
Beispiel #2
0
 public function rollOut(&$output, $item_type = 'Object')
 {
     $package_name = $this->package->getPackageName();
     $name = $this->getName();
     $variables = array();
     $check_keys = array('summary', 'description');
     foreach ($this->getValues() as $key => $values) {
         foreach ($values as $value) {
             if ($value->isA(DojoFunctionDeclare)) {
                 $function = $value->getFunction();
                 $this->declarations[] = $function;
                 if (!$function->isConstructor()) {
                     $function->setFunctionName("{$name}.{$key}");
                     $function->rollOut($output);
                 }
             } elseif ($value->isA(DojoObject)) {
                 $object = $value->getObject();
                 $object->setName("{$name}.{$key}");
                 $object->rollOut($output);
             } else {
                 $this->addBlockCommentKey($key);
                 $full_variable_name = "{$name}.{$key}";
                 if (empty($output[$full_variable_name])) {
                     $output[$full_variable_name] = array();
                 }
                 $variables[] = $key;
             }
         }
     }
     foreach ($check_keys as $ck) {
         $this->addBlockCommentKey($ck);
     }
     $this->addBlockCommentKeySet("example");
     $output[$name]['type'] = $item_type;
     if ($comment = $this->getBlockComment('summary')) {
         $output[$name]['summary'] = $comment;
     }
     if ($comment = $this->getBlockComment('description')) {
         $output[$name]['description'] = $comment;
     }
     $examples = $this->getBlockComment('example');
     if ($examples && count($examples)) {
         $output[$name]['examples'] = $examples;
     }
     foreach ($variables as $key) {
         $full_variable_name = "{$name}.{$key}";
         if ($comment = $this->getBlockComment($key)) {
             list($tags, $parameter_type, $options, $summary) = DojoFunctionDeclare::parseVariable($comment);
             if (!empty($tags)) {
                 $output[$full_variable_name]['tags'] = $tags;
             }
             if (!empty($parameter_type)) {
                 $output[$full_variable_name]['type'] = $parameter_type;
             }
             $output[$full_variable_name]['summary'] = $summary;
         }
     }
     foreach ($check_keys as $ck) {
         if (!$this->isAnonymous() && ($comment = $this->getBlockComment($ck))) {
             $output[$name][$ck] = $comment;
         }
     }
 }