In console/Controller.php we can read:
/**
* Prints a string to STDOUT.
*
* You may optionally format the string with ANSI codes by
* passing additional parameters using the constants defined in [[\yii\helpers\Console]].
*
* Example:
*
* ```
* $this->stdout('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE);
* ```
*
* @param string $string the string to print
* @return int|bool Number of bytes printed or false on error
*/
public function stdout($string)
The function arguments do not match the docs above.
The Yii2 tutorial is also showing two arguments.
Is this an error or do I miss something?
As you can see some lines among, the function arguments are loaded via func_get_args:
/**
* Prints a string to STDOUT.
*
* You may optionally format the string with ANSI codes by
* passing additional parameters using the constants defined in [[\yii\helpers\Console]].
*
* Example:
*
* ```
* $this->stdout('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE);
* ```
*
* @param string $string the string to print
* @return int|bool Number of bytes printed or false on error
*/
public function stdout($string)
{
if ($this->isColorEnabled()) {
$args = func_get_args();
array_shift($args);
So no, there is no error.
Wow. I didn't see this.
What's the reason not to supply additional parameters as in PHP's `json_encode function, e.g. as bit defined flags or a options array?
Using this way documentation may be misleading and function definitions do not give a full understanding of how to use the function.
It's more like PHP's array_merge function. It can have 0-∞ additional styling parameters (after $string parameter). But you're right, the documentation might be more clear about this (maybe like BaseArrayHelper).
Most helpful comment
As you can see some lines among, the function arguments are loaded via
func_get_args:So no, there is no error.