0

I have two questions actually:

  1. 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']
            ......
    }
    
  2. From some function I am returning data as JSON, how to mention JSON as return type and format:

     /* some descriptions 
      *
      * @return JSON [{id, name,...}]
      */
    
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Waqar Haider
  • 929
  • 10
  • 33

1 Answers1

1

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.

avy
  • 644
  • 6
  • 16