¿Cuál es la forma correcta de mostrar un multi-line @param usando PHPDoc?
Por lo que he investigado, parece que no puedo encontrar un método correcto para formatear una línea phpdoc @param
multilínea. ¿Cuál es la forma recomendada de hacerlo?
Aquí hay un ejemplo:
/**
* Prints 'Hello World'.
*
* Prints out 'Hello World' directly to the output.
* Can be used to render examples of PHPDoc.
*
* @param string $noun Optional. Sends a greeting to a given noun instead.
* Input is converted to lowercase and capitalized.
* @param bool $surprise Optional. Adds an exclamation mark after the string.
*/
function helloYou( $noun = 'World', $surprise = false ) {
$string = 'Hello ' . ucwords( strtolower( $string ) );
if( !!$surprise ) {
$string .= '!';
}
echo $string;
}
¿Sería eso correcto, o no agregaría sangría, o simplemente mantendría todo en una línea larga?
24
1 answers
Simplemente puedes hacerlo de esta manera:
/**
*
* @param string $string Optional. Sends a greeting to a given noun instead.
* Input is converted to lowercase and capitalized.
* @param bool $surprise
*/
function helloYou( $string = 'World', $surprise = false )
{
$string = 'Hello ' . ucwords( strtolower( $string ) );
if( !!$surprise ) {
$string .= '!';
}
echo $string;
}
Así que tu ejemplo está bien excepto por una cosa : el PHPDoc @param necesita tener el mismo nombre que el parámetro PHP. Lo llamaron $sustantivo en el doc y $cadena en el código real.
21
Author: Dany Caissy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-21 15:05:29
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-21 15:05:29