I have two questions actually:
For some functions I am posting forms to them, can I mention them as @params
in comments or what:
/* some descriptions
*
* @param string userName
*/
public function add(){
$userName = $_POST['user']
......
}
From some function I am returning data as JSON, how to mention JSON as return type and format:
/* some descriptions
*
* @return JSON [{id, name,...}]
*/
You can write anything you like in comments. That said, it's not a conventional use - @param
and @return
should describe the actual parameters and return values of the function in question. See e.g. the draft PHP-FIG recommendation for what's (mostly) conventional.
If you're returning a JSON string it would be better to document it as
@return string Text here describing what is being returned
since as far as PHP is concerned it's just another string.