Making first parameter of Shell::out() and err() optional.

This commit is contained in:
davidpersson 2009-09-26 23:02:54 +02:00
parent 86274357b9
commit 0f6bca7496
2 changed files with 12 additions and 4 deletions

View file

@ -363,13 +363,14 @@ class Shell extends Object {
}
/**
* Outputs a single or multiple messages to stdout.
* Outputs a single or multiple messages to stdout. If no parameters
* are passed outputs just a newline.
*
* @param mixed $message A string or a an array of strings to output
* @param integer $newlines Number of newlines to append
* @access public
*/
function out($message, $newlines = 1) {
function out($message = null, $newlines = 1) {
if (is_array($message)) {
$message = implode($this->nl(), $message);
}
@ -377,13 +378,14 @@ class Shell extends Object {
}
/**
* Outputs a single or multiple error messages to stderr.
* Outputs a single or multiple error messages to stderr. If no parameters
* are passed outputs just a newline.
*
* @param mixed $message A string or a an array of strings to output
* @param integer $newlines Number of newlines to append
* @access public
*/
function err($message, $newlines = 1) {
function err($message = null, $newlines = 1) {
if (is_array($message)) {
$message = implode($this->nl(), $message);
}

View file

@ -235,6 +235,9 @@ class ShellTest extends CakeTestCase {
$this->Shell->Dispatch->expectAt(2, 'stdout', array("Just\na\ntest\n\n", false));
$this->Shell->out(array('Just', 'a', 'test'), 2);
$this->Shell->Dispatch->expectAt(3, 'stdout', array("\n", false));
$this->Shell->out();
}
/**
@ -252,6 +255,9 @@ class ShellTest extends CakeTestCase {
$this->Shell->Dispatch->expectAt(2, 'stderr', array("Just\na\ntest\n\n"));
$this->Shell->err(array('Just', 'a', 'test'), 2);
$this->Shell->Dispatch->expectAt(3, 'stderr', array("\n", false));
$this->Shell->err();
}
/**