Re: [PHP-DEV] [RFC] Deprecations for PHP 8.6
[email protected] (Tim Düsterhus)
| Newsgroups | php.internals |
|---|---|
| Message-ID | <[email protected]> |
Hi Am 2026-07-01 21:25, schrieb Seifeddine Gmati: >> FWIW: I still have a rough draft to make `array()` (or rather: all >> non-object types) proper functions that effectively would “stand in” >> as >> cast operators. For `array()` specifically this would allow a >> named-argument style of defining arrays with “unquoted keys”: >> `array(foo: 1, bar: 2)`. > > This would require deprecating `array()` first anyway, no? Otherwise, > dealing with it during parsing would be hacky (looking ahead at > `array(foo` for `:` or `=>` or `,` or `)` to decide if it's an array > or a function call, possible, but hacky think ). It's not particularly pretty, but possible. The `array()` syntax will not actually be a function call, it will just look like one. Basically the `:` syntax can just parse into the same AST as the `=>` syntax, the grammar just needs to make sure that they may not be mixed. The array() function will be made available in addition to support `\array` (i.e. with a fully-qualified name) and `array(...)` (i.e. a first class callable). My rough draft is in https://github.com/php/php-src/pull/18613, I think there are some issues still with properly compiling the array, because the AST node for `=>` takes the two sides in different order compared to named arguments and I wanted to document the AST structure first (and then got distracted by more important things). Best regards Tim Düsterhus