-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: ArrayIndentationFixer
- handle closures inside attributes
#8888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ArrayIndentationFixer
- handle closures inside attributes
#8888
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍🏼
Can we make this a feature for a fixer? E.g. for ArrayIndentationFixerTest
, if I'm not wrong, this is passing on master
and is not after your changes:
/**
* @dataProvider provideFix85Cases
*
* @requires PHP 8.5
*/
public function testFix85(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
/**
* @return iterable<string, array{string, string}>
*/
public static function provideFix85Cases(): iterable
{
yield 'nested attribute' => [
<<<'PHP'
<?php
#[Foo([static function (#[SensitiveParameter] $a) {
return [
fn (#[Bar([1, 2])] $b) => [
$b[1]
]
]
;
}])]
class Baz {}
PHP,
];
}
; | ||
}])] | ||
class Baz {} | ||
PHP, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kubawerlos Not sure if I understand your test case correctly. Actually the fixer should fix that, so I've added the expected string with aligned array closing bracket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should, and it is... after your change, on master
it is not, currently.
AttributeTransformer
- handle closures inside attributesArrayIndentationFixer
- handle closures inside attributes
Thanks @gharlan |
For PHP 8.5 compatibility: https://wiki.php.net/rfc/closures_in_const_expr