@param Closure|Function_|ClassMethod $function
@param bool $docblock_only

@return void
346055
private static function addOrUpdateReturnType(
        FunctionLike $function,
        ProjectAnalyzer $project_analyzer,
        Type\Union $inferred_return_type,
        StatementsSource $source,
        FunctionLikeAnalyzer $function_like_analyzer,
        $docblock_only = false,
        FunctionLikeStorage $function_like_storage = null
    ) {
        $manipulator = FunctionDocblockManipulator::getForFunction(
            $project_analyzer,
            $source->getFilePath(),
            $function_like_analyzer->getMethodId(),
            $function
        );
        $manipulator->setReturnType(
            !$docblock_only && $project_analyzer->getCodebase()->php_major_version >= 7
                ? $inferred_return_type->toPhpString(
                    $source->getNamespace(),
                    $source->getAliasedClassesFlipped(),
                    $source->getFQCLN(),
                    $project_analyzer->getCodebase()->php_major_version,
                    $project_analyzer->getCodebase()->php_minor_version
                ) : null,
            $inferred_return_type->toNamespacedString(
                $source->getNamespace(),
                $source->getAliasedClassesFlipped(),
                $source->getFQCLN(),
                false
            ),
            $inferred_return_type->toNamespacedString(
                $source->getNamespace(),
                $source->getAliasedClassesFlipped(),
                $source->getFQCLN(),
                true
            ),
            $inferred_return_type->canBeFullyExpressedInPhp(),
            $function_like_storage ? $function_like_storage->return_type_description : null
        );
    }
242244
protected function visitFunction(Node $function)
    {
        $this->metrics['functions']++;

        if ($function instanceof Node\Expr\Closure) {
            $this->metrics['anonymousFunctions']++;
        } else {
            $this->metrics['namedFunctions']++;
        }
    }
1362458
protected function resolveSubTemplateDependencies($function)
	{
		$body = $this->templatePlugins[$function]['body'];
		foreach ($this->templatePlugins as $func => $attr) {
			if ($func !== $function && !isset($attr['called']) && strpos($body, 'Dwoo_Plugin_'.$func) !== false) {
				$this->templatePlugins[$func]['called'] = true;
				$this->resolveSubTemplateDependencies($func);
			}
		}
		$this->templatePlugins[$function]['checked'] = true;
	}
1262659
private function buildDefinition(\ReflectionMethod $method, DocBlock $docBlock, $token = null)
    {
        $definition = new InputDefinition();

        foreach ($docBlock->getTags() as $tag) {
            if ($tag instanceof DocBlock\Tags\Param) {
                $tagsDescription[$tag->getVariableName()] = $tag->getDescription()->render();
            }
        }

        foreach ($method->getParameters() as $parameter) {

            if ($parameter->isDefaultValueAvailable()) {
                //option
                $definition->addOption(new InputOption($parameter->getName(), null, InputOption::VALUE_REQUIRED, $tagsDescription[$parameter->getName()], $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null));
            } else {
                //argument
                $definition->addArgument(new InputArgument($parameter->getName(), InputArgument::REQUIRED, $tagsDescription[$parameter->getName()], null));
            }
        }

        $definition->addOption(new InputOption('token', null, InputOption::VALUE_REQUIRED, 'Auth token to use', $token));
        $definition->addOption(new InputOption('debug', null, InputOption::VALUE_NONE, 'Display raw response'));

        return $definition;
    }
1366573
protected function addReturnAnnotation(File $phpcsFile, int $docBlockStartIndex, int $docBlockEndIndex, string $returnType = 'void'): void
    {
        $indentation = $this->getIndentationWhitespace($phpcsFile, $docBlockEndIndex);

        $lastLineEndIndex = $phpcsFile->findPrevious([T_DOC_COMMENT_WHITESPACE], $docBlockEndIndex - 1, null, true);

        $phpcsFile->fixer->beginChangeset();
        $phpcsFile->fixer->addNewline($lastLineEndIndex);
        $phpcsFile->fixer->addContent($lastLineEndIndex, $indentation . '* @return ' . $returnType);
        $phpcsFile->fixer->endChangeset();
    }
885620
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        switch ( $functionName )
        {
            case $this->BlockName:
            {
                // Check for disabled cache.
                $ini = eZINI::instance();
                if ( $ini->variable( 'TemplateSettings', 'TemplateCache' ) != 'enabled' )
                {
                    $text = eZTemplateCacheFunction::processUncached( $tpl, $functionChildren,
                                                                      $rootNamespace, $currentNamespace );
                    $textElements[] = $text;
                    return;
                }
                else
                {
                    $text = eZTemplateCacheFunction::processCachedPreprocess( $tpl,  $functionChildren,
                                                                              $functionParameters, $functionPlacement,
                                                                              $rootNamespace, $currentNamespace );
                    $textElements[] = $text;
                }
            } break;
        }
    }
853662
protected function _inflect($function, $words) {
		$this->out($words);
		if ($function === 'all') {
			foreach ($this->validMethods as $method) {
				$functionName = $this->_getMessage($method);
				$this->out("{$functionName}: " . Inflector::$method($words));
			}
		} else {
			$functionName = $this->_getMessage($function);
			$this->out("{$functionName}: " . Inflector::$function($words));
		}
	}
381417
protected function checkExistingDocBlock(File $phpCsFile, int $docBlockEndPosition): void
    {
        if ($this->hasCorrectContent($phpCsFile, $docBlockEndPosition)) {
            return;
        }

        $fix = $phpCsFile->addFixableError('Constants interface doc block outdated.', $docBlockEndPosition, 'DocBlockOutdated');
        if (!$fix) {
            return;
        }

        $tokens = $phpCsFile->getTokens();
        $docBlockStartPosition = $tokens[$docBlockEndPosition]['comment_opener'];

        $phpCsFile->fixer->beginChangeset();
        for ($i = $docBlockStartPosition; $i <= $docBlockEndPosition; $i++) {
            $phpCsFile->fixer->replaceToken($i, '');
        }

        $docBlockStartPosition--;
        $this->insertDocBlock($phpCsFile, $docBlockStartPosition);
        $phpCsFile->fixer->endChangeset();
    }
420324
function todoWriter(&$doclet) {

        parent::MDWriter($doclet);

        $rootDoc = & $this->_doclet->rootDoc();

        $todoClasses = array();
        $classes = & $rootDoc->classes();
        $todoFields = array();
        $todoMethods = array();
        if ($classes) {
            foreach ($classes as $class) {
                if ($class->tags("@todo")) {
                    $todoClasses[] = $class;
                }
                $fields = & $class->fields();
                if ($fields) {
                    foreach ($fields as $field) {
                        if ($field->tags("@todo")) {
                            $todoFields[] = $field;
                        }
                    }
                }
                $classes = & $class->methods();
                if ($classes) {
                    foreach ($classes as $method) {
                        if ($method->tags("@todo")) {
                            $todoMethods[] = $method;
                        }
                    }
                }
            }
        }
        $todoGlobals = array();
        $globals = & $rootDoc->globals();
        if ($globals) {
            foreach ($globals as $global) {
                if ($global->tags("@todo")) {
                    $todoGlobals[] = $global;
                }
            }
        }
        $todoFunctions = array();
        $functions = & $rootDoc->functions();
        if ($functions) {
            foreach ($functions as $function) {
                if ($function->tags("@todo")) {
                    $todoFunctions[] = $function;
                }
            }
        }

        ob_start();

        echo "- - -\n\n";

        echo "#Todo#";

        echo "\n\n- - -\n\n";

        if ($todoClasses || $todoFields || $todoMethods || $todoGlobals || $todoFunctions) {
            echo "##Contents##\n\n";

            echo "<ul>\n";
            if ($todoClasses) {
                echo "<li><a href=\"#todo_class\">Todo Classes</a></li>";
            }
            if ($todoFields) {
                echo "<li><a href=\"#todo_field\">Todo Fields</a></li>";
            }
            if ($todoMethods) {
                echo "<li><a href=\"#todo_method\">Todo Methods</a></li>";
            }
            if ($todoGlobals) {
                echo "<li><a href=\"#todo_global\">Todo Globals</a></li>";
            }
            if ($todoFunctions) {
                echo "<li><a href=\"#todo_function\">Todo Functions</a></li>";
            }
            echo "</ul>\n";
        }

        if ($todoClasses) {
            echo "<table id=\"todo_class\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Classes</th></tr>", "\n";
            foreach ($todoClasses as $class) {
                $todoTag = & $class->tags("@todo");
                echo "<tr><td class=\"name\"><a href=\"", $this->_asURL($class), "\">", $class->qualifiedName(), "</a></td>";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td></tr>\n";
            }
            echo "</table>\n\n";
        }

        if ($todoFields) {
            echo "<table id=\"todo_field\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Fields</th></tr>", "\n";
            foreach ($todoFields as $field) {
                $todoTag = & $field->tags("@todo");
                echo "<tr>\n";
                echo "<td class=\"name\"><a href=\"", $this->_asURL($field), "\">", $field->qualifiedName(), "</a></td>\n";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td>\n";
                echo "</tr>\n";
            }
            echo "</table>\n\n";
        }

        if ($todoMethods) {
            echo "<table id=\"todo_method\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Methods</th></tr>", "\n";
            foreach ($todoMethods as $method) {
                $todoTag = & $method->tags("@todo");
                echo "<tr>\n";
                echo "<td class=\"name\"><a href=\"", $this->_asURL($method), "\">", $method->qualifiedName(), "</a></td>\n";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td>\n";
                echo "</tr>\n";
            }
            echo "</table>\n\n";
        }

        if ($todoGlobals) {
            echo "<table id=\"todo_global\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Globals</th></tr>", "\n";
            foreach ($todoGlobals as $global) {
                $todoTag = & $global->tags("@todo");
                echo "<tr>\n";
                echo "<td class=\"name\"><a href=\"", $this->_asURL($global), "\">", $global->qualifiedName(), "</a></td>\n";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td>\n";
                echo "</tr>\n";
            }
            echo "</table>\n\n";
        }

        if ($todoFunctions) {
            echo "<table id=\"todo_function\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Functions</th></tr>", "\n";
            foreach ($todoFunctions as $function) {
                $todoTag = & $function->tags("@todo");
                echo "<tr>\n";
                echo "<td class=\"name\"><a href=\"", $this->_asURL($function), "\">", $function->qualifiedName(), "</a></td>\n";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td>\n";
                echo "</tr>\n";
            }
            echo "</table>\n\n";
        }

        $this->_output = ob_get_contents();
        ob_end_clean();

        $this->_write("todo-list.md");
    }
1189016
private function extractDocTags(array $arguments, ReflectionFunctionAbstract $function): array
    {
        if (!$function->getDocComment()) {
            return $arguments;
        }

        $context = (new Types\ContextFactory())->createFromReflector($function);
        $docBlock = DocBlockFactory::createInstance()->create($function, $context);

        /** @var Param $paramTag */
        foreach ($docBlock->getTagsByName('param') as $paramTag) {
            $name = $paramTag->getVariableName();
            if (!isset($arguments[$name])) {
                continue;
            }
            $arg = $arguments[$name];

            $type = $paramTag->getType();
            if ($type !== null) {
                if ($type instanceof Types\Array_) {
                    $type = $type->getValueType();
                    $arg->optional = true;
                    $arg->default = $arg->default ?? [];
                }

                if ($type instanceof Types\Object_ && $type->getFqsen()) {
                    $arg->key = ltrim((string)$type->getFqsen(), '\\');
                }
            }

            $paramDescription = (string)$paramTag->getDescription();

            if (preg_match(static::INJECT_TAG_REGEX, $paramDescription, $matches)) {
                $arg->key = $matches[1];
            }

            if (preg_match(static::OPTIONAL_TAG_REGEX, $paramDescription)) {
                $arg->optional = true;
            }
        }

        return $arguments;
    }
1018883
function functionWriter(&$doclet) {

        parent::MDWriter($doclet);

        $this->_id = "definition";

        $rootDoc = & $this->_doclet->rootDoc();

        $packages = & $rootDoc->packages();
        ksort($packages);

        foreach ($packages as $packageName => $package) {
            $this->_depth = $package->depth() + 1;

            ob_start();

            echo "- - -\n\n";

            echo "#Functions#\n\n";

            echo "- - -\n\n";

            $functions = & $package->functions();

            if ($functions) {
                ksort($functions);
                echo "<table id=\"summary_function\" class=\"title\">", "\n";
                echo "<tr><th colspan=\"2\" class=\"title\">Function Summary</th></tr>", "\n";
                foreach ($functions as $function) {
                    $textTag = & $function->tags("@text");
                    echo "<tr>\n";
                    echo "<td>", $this->_methodSignature($function), "</td>\n";
                    echo "<td class=\"description\">";
                    echo "<p class=\"name\"><a href=\"#", $this->_asURL($function),"\">", $function->name(), "</a>", $this->_flatSignature($function), "</p>";
                    if ($textTag) {
                        echo "<p class=\"description\">", strip_tags($this->_processInlineTags($textTag, TRUE), "<a><b>**<u><em>"), "</p>";
                    }
                    echo "</td>\n";
                    echo "</tr>\n";
                }
                echo "</table>\n\n";

                echo "<h2 id=\"detail_function\">Function Detail</h2>", "\n";
                foreach ($functions as $function) {
                    $textTag = & $function->tags("@text");
                    $this->_sourceLocation($function);
                    echo "<h3 id=\"", $function->name(), "()\">", $function->name(), "</h3>\n";
                    echo $this->_methodSignature($function);
                    echo " {$function->name()} {$this->_flatSignature($function)}\n\n";
                    echo "<div class=\"details\">\n";
                    if ($textTag) {
                        echo $this->_processInlineTags($textTag), "\n";
                    }
                    $this->_processTags($function->tags());
                    echo "</div>\n\n";
                    echo "- - -\n\n";
                }
            }

            $this->_output = ob_get_contents();
            ob_end_clean();

            $this->_write($this->_normalize($package->_name) . "_package-functions.md");
        }
    }
1183450
private function _checkDocBlockParameters() {

		// For anonymous functions, we don't check the docblock
		$isAnonymous = $this->statementStack->getCurrentStackItem()->visibility === 'ANONYMOUS';

		if ($this->_isActive('docBlocks') && !$isAnonymous && !$this->_config->isException('docBlocks', $this->_currentFunctionName) && !$this->statementStack->getParentStackItem()->docblocInheritDoc) {

			// If the function is not private and we check the doc
			$isPrivateExcluded = $this->_config->getTestProperty('docBlocks', 'excludePrivateMembers');
			if (!($isPrivateExcluded && $this->_functionVisibility === 'PRIVATE')) {

				// Check the docblock @return
				if (($this->_config->getTestProperty('docBlocks', 'testReturn') !== 'false')) {

					if ($this->_functionReturns && ($this->statementStack->getParentStackItem()->docblocNbReturns === 0)) {
						$msg = $this->_getMessage('DOCBLOCK_RETURN', $this->_currentFunctionName);
						$this->_writeError('docBlocks', $msg);
					}
				}

				// Check the docblock @param
				if (($this->_config->getTestProperty('docBlocks', 'testParam') !== 'false')) {
					if ($this->_nbFunctionParameters !== $this->statementStack->getParentStackItem()->docblocNbParams) {
						$msg = $this->_getMessage('DOCBLOCK_PARAM', $this->_currentFunctionName);
						$this->_writeError('docBlocks', $msg);
					}
				}

				// Check the docblock @throw
				if (($this->_config->getTestProperty('docBlocks', 'testThrow') !== 'false')) {

					if ($this->_functionThrows && ($this->statementStack->getParentStackItem()->docblocNbThrows === 0)) {
						$msg = $this->_getMessage('DOCBLOCK_THROW', $this->_currentFunctionName);
						$this->_writeError('docBlocks', $msg);
					}
				}
			}
		}
	}
767891
protected function checkBeginningOfDocBlock(File $phpCsFile, int $docBlockStartIndex, int $nextIndex): void
    {
        $tokens = $phpCsFile->getTokens();

        $diff = $tokens[$nextIndex]['line'] - $tokens[$docBlockStartIndex]['line'];
        if ($diff < 2) {
            return;
        }

        $fix = $phpCsFile->addFixableError('Expected no extra blank line before tags, got ' . ($diff - 1), $nextIndex, 'NoExtraNewlineBeforeTags');
        if ($fix) {
            return;
        }

        $phpCsFile->fixer->beginChangeset();

        for ($i = $docBlockStartIndex; $i < $nextIndex; $i++) {
            if ($tokens[$i]['line'] <= $tokens[$docBlockStartIndex]['line'] || $tokens[$i]['line'] >= $tokens[$nextIndex]['line']) {
                continue;
            }
            $phpCsFile->fixer->replaceToken($i, '');
        }

        $phpCsFile->fixer->endChangeset();
    }
482607
protected function getMethodDescription($docBlock): string
    {
        if ($docBlock->hasTag(self::API_METHOD_DESCRIPTION)) {
            $tags = $docBlock->getTagsByName(self::API_METHOD_DESCRIPTION);

            return (string)$tags[0];
        }

        return $docBlock->getSummary();
    }
1070540
protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from, $extra)
    {
        if (!empty($this->action_function) and is_callable($this->action_function)) {
            call_user_func($this->action_function, $isSent, $to, $cc, $bcc, $subject, $body, $from, $extra);
        }
    }
550727
private function generateSingleArgumentDocblock(ClientMethodContext $context): DocBlockGenerator
    {
        $method = $context->getMethod();
        $class = $context->getClass();
        $param = current($method->getParameters());

        return DocBlockGeneratorFactory::fromArray(
            [
                'tags' => [
                    [
                        'name' => 'param',
                        'description' => sprintf(
                            '%s|%s $%s',
                            $this->generateClassNameAndAddImport(RequestInterface::class, $class),
                            $this->generateClassNameAndAddImport($param->getType(), $class, true),
                            $param->getName()
                        ),
                    ],
                    [
                        'name' => 'return',
                        'description' => sprintf(
                            '%s|%s',
                            $this->generateClassNameAndAddImport(ResultInterface::class, $class),
                            $this->generateClassNameAndAddImport(
                                $method->getNamespacedReturnType(),
                                $class,
                                true
                            )
                        ),

                    ],
                    [
                        'name' => 'throws',
                        'description' => $this->generateClassNameAndAddImport(
                            SoapException::class,
                            $class
                        ),
                    ],
                ],
            ]
        )->setWordWrap(false);
    }
446495
function reset_methods(doc) {

				if(is.array(doc)) {
					return ARRAY(doc).map(reset_methods).valueOf();
				}

				if(is.object(doc)) {
					ARRAY(methods).forEach(function(method) {
						delete doc[method.$name];
					});
				}

				return doc;
			}