Home » Php » How to add documentation for my functions in Netbeans PHP?

How to add documentation for my functions in Netbeans PHP?

Posted by: admin April 23, 2020 Leave a comment

Questions:

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.

alt text

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

UPDATE :

The following is the updated syntax which will work in 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) {
How to&Answers:

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
 */

Answer:

Additional hint :
Netbeans can make it for you :

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;
}

Answer:

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

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

@return is optional but usefull

Answer:

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.

Answer:

/**
 *
 * 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.