Hey Seifeddine,

I'm not sure why my last message did not receive a response, but I will try
again.

> similar to what we see in TypeScript
This is exactly my concern. Literal types are useful in TypeScript, but
they are also often directly overused. I do not think PHP should encourage
the same pattern.

I would prefer type aliases, such as Robert’s proposal from last year, as a
foundation before considering this direction:
https://wiki.php.net/rfc/typed-aliases

My concern is that the RFC encourages public APIs like function f(1|2|3 $x)
or function sort('asc'|'desc' $direction), where magic scalar values become
part of the runtime API instead of being represented by a properly domain
modeled entity.

Modern AI-assisted engineering makes semantic naming even more important.
Inline literal types such as 1|2|3 or 'asc'|'desc' provide less semantic
signal than named concepts such as enums or type aliases. This can make
code harder not only for humans, but also for AI tools that rely heavily on
names and surrounding context. However, I'm aware that this secondary
argument is not very plausible in this group.

Language features should be evaluated from the long-term user and
API-design perspective, not only from the static-analysis perspective. From
that perspective, I think this RFC approaches the problem from the wrong
side.

Kind regards,

Jorg

Reply via email to