How to document parameters received by function "func_get_args"?

2

How can I be documenting parameters that are received through the func_get_args function?

The reason is to be able to pass several parameters to the function for the same purpose!

/**
 * Gets a smart text filtered and formatted of according with the property name provided
 *
 * @param string $code The property name to be called
 *
 * @return string Returns the content of property in '$code' with formatting filter as a string
 * @see   Skreth\Code\Text::getTexts()
 * @since 0.2
 */
public static function code($code)
{
    if (!is_string($code)) throw new InvalidArgumentException("Smart text is not a string");

    return StringFilter::formatting(self::getTexts($code));
}

As well, it may be possible to pass several $code :

public static function code()
{
    $code = func_num_args();
    $result = [];

    foreach ($code as $value) {
        if (!is_string($value)) throw new InvalidArgumentException("Smart text is not a string");

        $result[] =  StringFilter::formatting(self::getTexts($value));
    }

    // OU, TALVEZ (Acredito que foreach seja mais perfomático, estou certo?)...
    $result = array_map(function ($value) {
        if (!is_string($value)) throw new InvalidArgumentException("Smart text is not a string");

        return StringFilter::formatting(self::getTexts($value));
    }, $code);

    return implode(' ', $result);
}

I accept good programming practice tips too: D

    
asked by anonymous 25.07.2016 / 21:11

1 answer

2

As the answer in the SOen

The old way would be:

link

/**
 * @param int $param,...
 **/

However this is no longer supported, since PHP5.6 the Variadic Method Parameters are part of PHP and PHPDoc has also updated it. It seems to work in PhpStorm IDE since EAP 139.659 (8.0.2+). I'm not sure about other IDEs.

link

In all cases the appropriate syntax is this:

/**
 * @param int ...$param
 **/
    
25.07.2016 / 22:38