如何在 Netbeans PHP 中为我的函数添加文档?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4360892/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:48:51  来源:igfitidea点击:

How to add documentation for my functions in Netbeans PHP?

phpnetbeansdocumentation-generationcode-completion

提问by Lenin Raj Rajasekaran

I tried the following,

我尝试了以下,

/*
 * addRelationship
 *
 * Adds a relationship between two entities using the given relation type.
 *
 * @param fromKey the original entity
 * @param toKey the referring entity
 * @param relationTypeDesc the type of relationship
 */

function addRelationship($fromKey, $toKey, $relationTypeDesc) {
    $relationTypeKey = $this->getRelationTypeKey($relationTypeDesc);

But, when I tried to use it in another place, it says PHPDoc not found.

但是,当我尝试在另一个地方使用它时,它说找不到 PHPDoc。

alt text

替代文字

Any Ideas on how to get this to work in NetBeans PHP?

关于如何让它在 NetBeans PHP 中工作的任何想法?

UPDATE :

更新 :

The following is the updated syntax which will work in NetBeans PHP -

以下是适用于 NetBeans PHP 的更新语法 -

/** 
 * addRelationship
 *
 * Adds a relationship between two entities using the given relation type.
 *
 * @param integer $fromKey the original entity
 * @param integet $toKey the referring entity
 * @param string $relationTypeDesc the type of relationship
 */

function addRelationship($fromKey, $toKey, $relationTypeDesc) {

回答by Pekka

You are missing an asterisk *in the first line: Try

*在第一行中缺少一个星号:尝试

/**
 * addRelationship
 *
 * Adds a relationship between two entities using the given relation type.
 *
 * @param fromKey the original entity
 * @param toKey the referring entity
 * @param relationTypeDesc the type of relationship
 */

回答by Benjamin Poignant

Additional hint : Netbeans can make it for you :

附加提示:Netbeans 可以为您制作:

public static function test($var1,$var2) {
    return $array;
}

Now write :

现在写 :

/**[press enter]
public static function test($var1,$var2) {
    return $array;
}

Tadaam :

塔达姆:

/**
 * 
 * @param type $var1
 * @param type $var2
 * @return type
 */
public static function test($var1,$var2) {
    return $array;
}

回答by Paulo

You need 2 ** on the comments opening for Netbeans to recognize it:

您需要 2 ** 在打开的评论上让 Netbeans 识别它:

Should be

应该

/**         
 *           
 */

not just a regular comment

不只是常规评论

/*
 *
 */

Example:

例子:

/**
 * function description
 *
 * @param *vartype* ***param1*** *description*
 * @param int param2 this is param two  
 * @return void  
 */

Netbeans automatically adds the function name

Netbeans 自动添加函数名

@return is optional but usefull

@return 是可选的但很有用

回答by A Salcedo

I believe the way to start you function comment is

我相信开始你的功能评论的方法是

/**
 * addRelationship
 *
 * Adds a relationship between two entities using the given relation type.
 *
 * @param fromKey the original entity
 * @param toKey the referring entity
 * @param relationTypeDesc the type of relationship
 */

Note the double asterisk to start your comment. You might want to check this php documentor.

请注意双星号以开始您的评论。您可能想查看这个php 文档

回答by toha

/**
 *
 * Adds a relationship between two entities using the given relation type.
 *
 * @since 2.1.1
 * @package coreapp
 * @subpackage entity
 * 
 * @param string $fromKey the original entity
 * @param mixed $toKey the referring entity
 * @param string relationTypeDesc the type of relationship
 * @return bool False if value was not updated and true if value was updated.
 */

You may add since which version, what package, what subpackage, add type of parameters, i.e. string, mixed, bool, and what is the return.

您可以添加从哪个版本,哪个包,哪个子包,添加参数类型,即string,mixed,bool,以及返回什么。