Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support converting all options to twig attributes#859

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@Spea
Copy link
Contributor

With this change, all potential options from theTwigFilter andTwigFunction classes will be converted to their counterpart in the attribute, so if you have something like this:

class MyClass{publicfunctiongetFilters():array    {return [new \Twig\TwigFilter('with_environment',$this->withEnvironment(...), ['needs_environment' =>true]),        ];    }publicfunctionwithEnvironment(Environment$env,$value)    {// ...    }}

it will now be converted to the following instead of skipping it:

class MyClass{    #[\Twig\Attribute\AsTwigFilter('with_environment', needsEnvironment:true)]publicfunctionwithEnvironment(Environment$env,$value)    {// ...    }}

@SpeaSpea marked this pull request as ready for reviewOctober 29, 2025 15:40
@TomasVotruba
Copy link
Member

@Spea Looks good to me. Could you check the failing CI?

With this change, all potential options from the `TwigFilter` and `TwigFunction` classes will be converted to their counterpart in the attribute, so if you have something like this:```phpclass MyClass{    public function getFilters(): array    {        return [            new \Twig\TwigFilter('with_environment', $this->withEnvironment(...), ['needs_environment' => true]),        ];    }    public function withEnvironment(Environment $env, $value)    {        // ...    }}```it will now be converted to the following instead of skipping it:```phpclass MyClass{    #[\Twig\Attribute\AsTwigFilter('with_environment', needsEnvironment: true)]    public function withEnvironment(Environment $env, $value)    {        // ...    }}```
@SpeaSpeaforce-pushed theimproved-twig-attributes branch frombb4599e tocc6cff3CompareOctober 30, 2025 07:58
@Spea
Copy link
ContributorAuthor

@Spea Looks good to me. Could you check the failing CI?

Sure, seems like I overlooked some type hints. I added them now and locallyphpstan is successful.

@TomasVotruba
Copy link
Member

Thank you, let's ship this 👍

Spea reacted with rocket emoji

@TomasVotrubaTomasVotruba merged commit7ea6950 intorectorphp:mainOct 30, 2025
5 checks passed
@SpeaSpea deleted the improved-twig-attributes branchOctober 30, 2025 10:25
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@Spea@TomasVotruba

[8]ページ先頭

©2009-2025 Movatter.jp