【问题标题】:When documenting PHP code with PHPDoc or similar how do you state array name => value pairs?使用 PHPDoc 或类似方法记录 PHP 代码时,如何声明数组名称 => 值对?
【发布时间】:2014-12-07 15:56:03
【问题描述】:

如果我有一个函数,并且我当前将值全部作为字符串传递并记录了如下内容:

/**
 * Sends mail using the built-in Swift Mailer component
 * @param string $from The email address who it's from
 * @param string $to The email address who we are sending it to
 * @param string $message The text-based message to send
 * @param string $html_msg The html-based message to send
 * @param string $from_name The name of the person/company it is from
 * @param string $to_name The name/company of the person who we are sending it to
 * @param string $reply_to The reply to email address
 * @return bool true or false if sending succeeded
 */

但是想要在一个数组中传递以下所有内容,我将如何正确记录每个键?

【问题讨论】:

    标签: php comments phpdoc


    【解决方案1】:

    你应该将参数声明为一个数组,最终你可以在代码标签中描述一些细节。比如:

    /**
     * Sends mail using the built-in Swift Mailer component
     *
     * Example:
     * <code>
     *
     *    $expectedArray = array(
     *        'from' => 'value',
     *        'to'   => 'another value',
     *        ... 
     *    );
     *
     *    yourfunc($expectedArray)
     *
     * </code> 
     *
     * @param array $yourarray an array bla bla... 
     * @return bool true or false if sending succeeded
     */ 
    

    【讨论】:

      【解决方案2】:
      $email->from = 'tes@test.nl';
      $email->to = 'to@test.nl';
      

      【讨论】:

        猜你喜欢
        • 2021-06-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-05
        • 1970-01-01
        • 2010-11-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多