Hi
Apologies. The stuff leading up to the PHP 8.6 release was busy.
On 2026-11-09 14:56, Pratik Bhujel wrote:
2. Would it make sense to have a getter that returns the current
raw-mode state? This might be useful to check before calling
readLine().
I left it out because PHP can only tell whether it holds a lease, not
what
the terminal is really set to. stty or another process can change it.
readLine() already throws if a lease on the same terminal is active,
even
from another wrapper. If you think a lease-only check is still useful,
I
can add one.
I don't understand that. PHP must be able to read the current “raw-mode
state” for the lease to reset it, no? Why can't it just read the actual
state once more when calling the getter?
5. For the "Error Model", I wonder if EOF should be returned as a key
instead, similar to Resize.
I'd keep the exception. After Resize the input is still open. After EOF
every call returns right away, so a loop that ignores unknown keys
would
spin forever. In raw mode Ctrl+D comes in as "\x04", so EOF only
happens
when the input is really closed. I added this to the RFC.
Okay, that reasoning makes sense to me.
Perhaps it would be desirable to distinguish between the user
cancelling, and a genuine error, and perhaps also EOF; for example
with subclasses of TerminalException.
I said I wanted to settle this before the vote. I've decided not to add
them in this RFC. Subclasses of TerminalException can be added later
without breaking anything, because existing catch blocks keep working,
and
I'd rather add them once real code shows which distinctions people
need.
I think having a TerminalClosedException (or EofException) or something
like that would be useful now. This seems like the most relevant case
that one would want to distinguish, because the terminal closing very
much sounds like something that the user would need to anticipate and
would want to handle in a special case.
Best regards
Tim Düsterhus