-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[PHP8.4] normalize_index_brace treats property hook's {} as index access #8301
Copy link
Copy link
Closed
Labels
kind/bugtopic/PHP8.4Related to features available in PHP 8.4+Related to features available in PHP 8.4+
Milestone
Description
Problem description
As you can see in #8300, there is a problem with property hooks syntax, which is treated as array index fetch.
This fixer should work only for PHP <8.0, but there is no condition within fixer itself. It seems like the root cause of this is PhpCsFixer\Tokenizer\Transformer\BraceTransformer::transformIntoCurlyIndexBraces(), which replaces { with CT::T_ARRAY_INDEX_CURLY_BRACE_OPEN.
Minimal reproducer
The code like this:
<?php
class PropertyHooks
{
public string $bar {
set(string $value) {
$this -> foo = strtolower($value);
}
}
}is malformed into this:
<?php
class PropertyHooks
{
public string $bar[
set(string $value) {
$this->foo = strtolower($value);
}
]
}Fixer version
3.64.1-DEV
PHP version
8.4.1
How do you run Fixer?
Composer package
Contribution Checks
- I have verified if this problem was already reported
- I am familiar with "Feature or bug?"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/bugtopic/PHP8.4Related to features available in PHP 8.4+Related to features available in PHP 8.4+