On 22/01/2026 09:12, Tim Düsterhus wrote:
Hi
we just opened the vote on the “let construct (Block Scoping)” RFC
(which was originally proposed as “use construct”, but the keyword
changed as a result of the discussion).
I have voted No.
I really want block scoping as a feature in PHP, but I do not want this
syntax.
For those who didn't follow the discussion thread, I will try to
summarise my reasons:
- I don't think PHP is special enough to break with a strong tradition
here. A huge family of languages use roughly the same syntax for
variable declarations, even though they have very different details of
how they work. That includes C and Java, but also JS and Perl, and even
VisualBasic (all ultimately traceable to ALGOL).
- Users are likely to be coming from those related languages,
particularly JS, and are likely to be confused by how this syntax works.
- For instance, they would not expect a comma-separated list to be
equivalent to a set of nested blocks, which affects the behaviour of
cases like let($a=new Foo, $a=new Bar)
- The use cases for combining with "if" or "foreach" are interesting,
but the result is confusing - the important control flow keyword ends up
in the middle of the line.
- For other use cases, requiring an extra block adds noise. For
instance, if we ever add auto-capture closures, a JS-style a concise
block-scoped declaration would be very useful to avoid accidental capture.
PHP itself already has "ALGOL-style" declarations, for "const",
"global", and "static". I think adding a "let" or "var" keyword with the
same syntax would be more consistent, and more useful.
There would be details to work out, but dozens of other languages to
learn from.
My thanks to Seifeddine and Tim for their work on this, and to Tim in
particular for patient and respectful discussion.
--
Rowan Tommins
[IMSoP]