Re: [RFC] Io\Terminal
| From: | Tim Düsterhus | Date: | Mon, 28 Sep 2026 09:46:54 +0000 |
| Subject: | Re: [RFC] Io\Terminal | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132672@lists.php.net to get a copy of this message | ||
Hi
On 2026-09-27 19:19, Pratik Bhujel wrote:
I would like to formally propose the Io\Terminal API for PHP 8.7: https://wiki.php.net/rfc/io_terminalThank you for the RFC. Some questions to start of the discussion: 1. Should TerminalSize have a regular constructor? It seems to be safe to allow constructing it from userland, e.g. for testing purposes. 2. It would help readability if the stub would indicate the non-serializability (and strict properties) instead of mentioning it in the prose. Basically you can just take the stub file from your PR and include it in the RFC. 3. Terminal::create() should probably be ::fromStdio() or similar. 4. I'm not sure about false vs Exception for the various methods.
enableRawMode() should probably be Exception, for readKey() the false return is not explained. Also the behavior of what happens when a timeout strikes is not explained.
5. Should ModeToken have a property that points back to the corresponding Terminal? Overall the interaction between the destructors and ModeToken and restoreMode should be explained more. As an example, what happens if the Terminal object dies before the ModeToken object? What if I create two Terminal objects for the same terminal?
Best regards
Tim Düsterhus