hoaproject / Console

The Hoa\Console library.
https://hoa-project.net/
366 stars 32 forks source link

Improve Output behavior. #59

Closed Metalaka closed 9 years ago

Metalaka commented 9 years ago

See https://github.com/hoaproject/Console/pull/55#discussion_r42047716

Hoa\Console::getOutput return Hoa\Stream\IStream\Out and then type check must be done to allow correct uses of Hoa\Console\Output's multiplexer feature. Requiring type check in methods usage looks like a wrong approach. Hoa\Console\Output can embed an instance of Hoa\Stream\IStream\Out. Like that Output::isMultiplexerConsidered & Output::considerMultiplexer are always available. And when Output::write is called, an internal call to Hoa\Stream\IStream\Out is done.

Hywan commented 9 years ago

I am actually doing the same thing with an Input class in https://github.com/hoaproject/Console/pull/51.

Hywan commented 9 years ago

Looks correct.

Hywan commented 9 years ago

Hmm, there is an issue with tests. We use ->output to test the output. Unfortunately, it does not consider php://stdout, which is different for PHP. So, sorry but… I guess this is dangerous to work on php://stdout with Hoa\File\Write and using echo seems to be a good solution here. Consequently, we need to test if (null === $this->_output) everywhere to put some echos everywhere.

Sorry for this undo!

Hywan commented 9 years ago

This is not an issue with testing only actually. I meant: php://stdout seems different than echo in this low-level. I don't know exactly why though.

Metalaka commented 9 years ago

Corrected.

Hywan commented 9 years ago

Seems correct!