Nicolas Grekas and I would like to propose this new RFC to the
discussion. This proposes to introduce two new cast operators to the
language: `(?type)` and `(!type)`.
Please find the details here:
https://wiki.php.net/rfc/nullable-not-nullable-cast-operator
Hi, Alexandre.
I was just starting to think about writing such RFC, and you already did
it )) As for me, now is good time to return to idea of such operators. I
really needed it some days ago ))
The idea is not new, here is https://wiki.php.net/rfc/nullable-casting
previous simular RFC, but you did not refer it in your RFC. Please list
it in you references.
Previous RFC described settype function behavior changes. Please
describe it (as well as not changing, if you prefer).
But your RFC brings two ideas, of (?type) and (!type) operator. I think,
it's not good idea to discuss and bring them together.
(?type)
* the idea came up a long time ago and by several independent people
(see previous rfc).
* "spelling" of the type corresponds to the "spelling" of the types of
parameters and results of functions and class properties
* such operator is just syntax sugar and could be transpiled to simple
ternary operator (if php was js ))) )
* discussion about that operator could be same level as about ?? or
??= operators
(!type)
* This is a relatively new idea
* the "spelling" can be interpreted ambiguously, ! is widely used as
boolean NOT, and currently in php never as strictness. Here can be
separate discussion about best symbol to such semantics
* it correlates with strict_types option, can throw new error type and
can not be considered syntax sugar
* there can be much more discussion about exception type to throw (see
Larry's Garfield message)
* to reduce cohesion with strict_types directive, we may introduce as
new declare(strict_casts=1) directive. That's subject of discussion too
May be it would be better to separate RFC for two different features. It
will simplify discussions.