Skip to content

[Symfony 7.3] Restore merged AsTwig attribute rules as deprecated - #1028

Merged
TomasVotruba merged 1 commit into
mainfrom
restore-deprecated-twig-attribute-rules
Aug 11, 2026
Merged

[Symfony 7.3] Restore merged AsTwig attribute rules as deprecated#1028
TomasVotruba merged 1 commit into
mainfrom
restore-deprecated-twig-attribute-rules

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

PR #1027 merged GetFiltersToAsTwigFilterAttributeRector and GetFunctionsToAsTwigFunctionAttributeRector into a single GetFiltersAndFunctionsToAsTwigAttributeRector, but removed the old classes outright. Anyone referencing them in their own rector.php gets a hard "class not found" crash with no hint where the rule went.

This restores both classes as deprecated stubs that point to the replacement.

What the deprecated rule does

Running either of the old rules now fails fast with a pointer:

"Rector\Symfony\Symfony73\Rector\Class_\GetFiltersToAsTwigFilterAttributeRector" is deprecated,
as it converts getFilters() only and leaves getFunctions()/getTests() behind.
Use "Rector\Symfony\Symfony73\Rector\Class_\GetFiltersAndFunctionsToAsTwigAttributeRector" instead.

Why they were merged

Converting one get*() method in isolation leaves a half-converted extension behind:

 use Twig\Extension\AbstractExtension;
+use Twig\Attribute\AsTwigFilter;

 class SomeExtension extends AbstractExtension
 {
-    public function getFilters()
-    {
-        return [new TwigFilter('filter_name', [$this, 'someFilter'])];
-    }
-
     public function getFunctions()
     {
         return [new TwigFunction('function_name', [$this, 'someFunction'])];
     }

+    #[AsTwigFilter('filter_name')]
     public function someFilter($value)
     {
         return $value;
     }
 }

The merged rule converts filters, functions and tests in one pass instead.

Notes

…es as deprecated

Point users to GetFiltersAndFunctionsToAsTwigAttributeRector instead.
@TomasVotruba
TomasVotruba enabled auto-merge (squash) August 11, 2026 09:50
@TomasVotruba
TomasVotruba merged commit 44d9e0e into main Aug 11, 2026
7 checks passed
@TomasVotruba
TomasVotruba deleted the restore-deprecated-twig-attribute-rules branch August 11, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant