Hello,

thinking a bit again on the whole topic, which I thought I was pretty much
completely opposed to because of the arbitrary-new-set-of-rules issue in
die validation details, I noticed that from my writing PHP code, there _is_
a single thing that I really _would_ like to be able to express as a type
hint. It would be a different kind of compromise. I wonder whether that
would please enough of the mysterious group of people who want such a
feature somehow.

Idea: have a "scalar" type hint. Have it admit null, int, float etc, but
not array, not object, and maybe not resource. No type juggling, casting,
or anything else that messes with the passed in zval - just a check that it
is scalar.

I come to this idea because in practise, what I often find myself checking
inside functions, is "if (is_array($arg) || is_object($arg)) fail; -
because these kinds of arguments tend to immediately mess up when treated
like scalars in further expressions in the function - while the usual type
juggling for scalar types works out fine in most other cases.

What do you think?

best regards
  Patrick

Reply via email to