Re: [PHP-DEV] Re: [PHP DEV] [Discussion] Native terminal helpers for PHP CLI

[email protected] (Tim Düsterhus)
Newsgroups php.internals
Message-ID <[email protected]>
Hi

On 2026-09-17 17:30, Pratik Bhujel wrote:
> Curious what you and others think on whether this makes sense as an RFC
> direction for 8.7, or if there are particular areas you would want 
> adjusted
> first?

I don't understand much about the problem you're tackling, so I can't 
meaningfully comment on if the API makes sense on a "high level" domain 
specific perspective. However for the API to become a first class 
citizen some changes will need to be made:

1. With the new polling API introducing the Io namespace, the 
functionality should likely be provided as Io\Terminal. Grouping it 
under Io makes sense to me and avoids reserving another top-level name.

2. Classes are not namespaces: Static methods that are not named 
constructors should be free-standing functions. Thus 
Io\Terminal\enable_ansi(), Io\Terminal\set_title(), etc. Alternatively 
since they almost all seem to take the "file descriptor" as the first 
argument, they could also be instance methods on an Io\Terminal\Terminal 
class that receives the terminal handle in the constructor. I leave it 
up to the domain experts to decide what makes more sense.

3. The enums should be unbacked. A backed enum is almost always the 
wrong design decision, since there is rarely a single canonical and 
obviously correct scalar representation.

Best regards
Tim Düsterhus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.