thekid/rfc — Issue #120: RFC 0120: Console::$out and Console::$err
Author: thekid
Created: 2011-10-09 15:13:49+00:00
State: open
Labels: implemented, rfc

Scope of Change
====
The util.cmd.Console class will support writing to standard error. For
this to work, a static $err supporting all the write* methods will be
added, and to make it consistent, a $out property will also exist.

Rationale
====
Support writing to STDERR / make Console class testable / forwards-
compatibility with Unicode support.

Functionality
====
All the write* methods will proxy to Console::$out. Console::$out and
Console::$err will make use of the io.streams.OutputStreamWriter API.

Current (and still valid) functionality
----
The following piece of code prints "Hello" and a CRLF to standard output:

```php

```

Using the streams
----
The following is the equivalent of the above shorthand:

```php
writeLine('Hello');
?>
```

This is the variant that writes to standard *error*, which was previously
unsupported:

```php
writeLine('Hello');
?>
```

Reassigning the streams
----
The $out and $err properties may be reassigned, for example, to redirect
output to nirvana:

```php

```

Security considerations
====
n/a

Speed impact
====
Slower.

Dependencies
====
n/a

Related documents
====
- http://xp-framework.net/rfc/contrib/rfc0120.diff
Implementing patch

- http://xp-framework.net/rfc/contrib/rfc0120-unittest.diff
Unittests for Console class

Comments
====
n/a