Adding return to Shell::out() and ShellDispatcher::stdout(). They now return the number of bytes written to stdout. Fixes #164

This commit is contained in:
mark_story 2009-10-15 00:23:54 -04:00
parent 6c956c27ee
commit 957be00d2e
2 changed files with 5 additions and 3 deletions

View file

@ -477,13 +477,14 @@ class ShellDispatcher {
* *
* @param string $string String to output. * @param string $string String to output.
* @param boolean $newline If true, the outputs gets an added newline. * @param boolean $newline If true, the outputs gets an added newline.
* @return integer Returns the number of bytes output to stdout.
* @access public * @access public
*/ */
function stdout($string, $newline = true) { function stdout($string, $newline = true) {
if ($newline) { if ($newline) {
fwrite($this->stdout, $string . "\n"); return fwrite($this->stdout, $string . "\n");
} else { } else {
fwrite($this->stdout, $string); return fwrite($this->stdout, $string);
} }
} }

View file

@ -370,13 +370,14 @@ class Shell extends Object {
* *
* @param mixed $message A string or a an array of strings to output * @param mixed $message A string or a an array of strings to output
* @param integer $newlines Number of newlines to append * @param integer $newlines Number of newlines to append
* @return integer Returns the number of bytes returned from writing to stdout.
* @access public * @access public
*/ */
function out($message = null, $newlines = 1) { function out($message = null, $newlines = 1) {
if (is_array($message)) { if (is_array($message)) {
$message = implode($this->nl(), $message); $message = implode($this->nl(), $message);
} }
$this->Dispatch->stdout($message . $this->nl($newlines), false); return $this->Dispatch->stdout($message . $this->nl($newlines), false);
} }
/** /**