feat: ArrayIndentationFixer - handle closures inside attributes#8888
Merged
kubawerlos merged 3 commits intoPHP-CS-Fixer:masterfrom Jul 27, 2025
Merged
feat: ArrayIndentationFixer - handle closures inside attributes#8888kubawerlos merged 3 commits intoPHP-CS-Fixer:masterfrom
ArrayIndentationFixer - handle closures inside attributes#8888kubawerlos merged 3 commits intoPHP-CS-Fixer:masterfrom
Conversation
kubawerlos
reviewed
Jul 25, 2025
Member
kubawerlos
left a comment
There was a problem hiding this comment.
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,
];
}
gharlan
commented
Jul 26, 2025
| ; | ||
| }])] | ||
| class Baz {} | ||
| PHP, |
Member
Author
There was a problem hiding this comment.
@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.
Member
There was a problem hiding this comment.
It should, and it is... after your change, on master it is not, currently.
AttributeTransformer - handle closures inside attributesArrayIndentationFixer - handle closures inside attributes
kubawerlos
approved these changes
Jul 27, 2025
Member
|
Thanks @gharlan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For PHP 8.5 compatibility: https://wiki.php.net/rfc/closures_in_const_expr