. */ include_once 'phing/system/io/Reader.php'; /** * Convenience class for reading console input. * * @author Hans Lellelid * @author Matthew Hershberger * @version $Revision: 905 $ * @package phing.system.io */ class ConsoleReader extends Reader { function readLine() { $out = fgets(STDIN); // note: default maxlen is 1kb $out = rtrim($out); return $out; } /** * * @param int $len Num chars to read. * @return string chars read or -1 if eof. */ function read($len = null) { $out = fread(STDIN, $len); return $out; // FIXME // read by chars doesn't work (yet?) with PHP stdin. Maybe // this is just a language feature, maybe there's a way to get // ability to read chars w/o ? } function close() { // STDIN is always open } function open() { // STDIN is always open } /** * Whether eof has been reached with stream. * @return boolean */ function eof() { return feof(STDIN); } /** * Returns path to file we are reading. * @return string */ function getResource() { return "console"; } }