Subject: Re: [PHP-DEV] [Concept] declare(strict_identifiers=1)
Hi internals,
A week on, and no answer to the question I ended up with, so let me close
this rather than let it go quiet on its own.
Thank you to everyone who replied. The proposal I opened with did not
survive the thread, and I think it was right that it did not. Three things
it established that I did not know a week ago:
Claude Pache: names are not identifiers. A name is any string that reaches
a symbol table; an identifier is a lexical token. I had been conflating
them, and the distinction is PHP's own, not something a proposal has to
invent.
Rowan Tommins: rejecting and normalising are different questions, and PHP
already normalises via ASCII case folding. Sorted along that axis, what I
brought is not one feature but three, with three different audiences and
three different prices -- which is why bundling them behind one declare
drew objections from three directions at once.
Larry Garfield: 250 packages was not enough. At 5,000 packages and 520,802
files the answer changes character. It is not "one oddball class in
Symfony": markrogoyski/math-php has 888 identifiers that a mandatory rule
would break, and they are deliberate -- variable names that spell the
formula. Outside that one package, 135 non-ASCII identifiers exist and only
25 fail, 15 of them in a single test file. Vincenty geodesy in
mjaschen/phpgeo, Latte's U+029F prefix in tracy/tracy and generated Russian
WSDL accessors in wsdltophp all already conform. Across both corpora,
627,515 files, not one identifier is outside NFC.
The question that stayed unanswered is whether non-ASCII identifiers are a
supported feature of PHP. The manual says they are not and explains that
they work by accident; 1,447 of them in the top 5,000 packages say
otherwise. Without an answer I cannot tell which of the three parts is
worth building, so I am not going to write an RFC on a guess.
What I will do is send a documentation PR describing what actually happens
today -- names compared as bytes, encoding neither interpreted nor
validated, two names that render identically able to be distinct -- without
claiming in either direction that they are supported, since that is the
part this list has not decided.
The survey stays up, with tooling, self-test, raw scanner output and
per-identifier CSVs, so that anyone who picks this up later starts from
data rather than from zero: https://github.com/Otzie2023/PHP
One loose end, in case it is ever useful. Claude Pache said he would like
the compiler to complain when he accidentally types a no-break space. That
is the smallest piece of what I proposed, it needs no declare and no opt-in,
and the measurement is 68 identifiers with an invisible character across
520,802 files. If there is ever appetite for that on its own, I will write
it.
Regards,
Luca