当使用 PHPDoc 或类似方法记录 PHP 代码时,如何声明数组名称 => 值对


When documenting PHP code with PHPDoc or similar how do you state array name => value pairs?

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

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

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

您应该将参数声明为数组,最终您可以在代码标记中描述一些细节。像这样:

/**
 * 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
 */ 
$email->from = 'tes@test.nl';
$email->to = 'to@test.nl';