Skip to content

Conversation

gharlan
Copy link
Member

@gharlan gharlan commented Jul 24, 2025

@coveralls
Copy link

coveralls commented Jul 24, 2025

Coverage Status

coverage: 94.718% (-0.01%) from 94.729%
when pulling 0318299 on gharlan:AttributeTransformer-closure
into 61c5c97 on PHP-CS-Fixer:master.

Copy link
Member

@kubawerlos kubawerlos left a 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,
        ];
    }

@kubawerlos kubawerlos added the topic/PHP8.5 Related to features available in PHP 8.5+ label Jul 25, 2025
;
}])]
class Baz {}
PHP,
Copy link
Member Author

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.

Copy link
Member

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.

@kubawerlos kubawerlos changed the title fix: AttributeTransformer - handle closures inside attributes feat: ArrayIndentationFixer - handle closures inside attributes Jul 27, 2025
@kubawerlos kubawerlos merged commit 974f182 into PHP-CS-Fixer:master Jul 27, 2025
32 checks passed
@kubawerlos
Copy link
Member

Thanks @gharlan

@gharlan gharlan deleted the AttributeTransformer-closure branch August 24, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature topic/PHP8.5 Related to features available in PHP 8.5+
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants