Raj
Raj

Reputation: 22956

How to add documentation for my functions in Netbeans PHP?

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) {

Upvotes: 32

Views: 32194

Answers (5)

Benjamin Poignant
Benjamin Poignant

Reputation: 1064

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

Upvotes: 21

toha
toha

Reputation: 5507

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

Upvotes: 2

Paulo
Paulo

Reputation: 14067

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

Upvotes: 7

A Salcedo
A Salcedo

Reputation: 6478

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.

Upvotes: 5

Pekka
Pekka

Reputation: 449783

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

Upvotes: 40

Related Questions