AC-2375: Complete Twig legacy-alias -> namespaced-class migration - #134
Open
KostasNoreika wants to merge 1 commit into
Open
AC-2375: Complete Twig legacy-alias -> namespaced-class migration#134KostasNoreika wants to merge 1 commit into
KostasNoreika wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates several Twig extensions and console commands to use the modern namespaced Twig classes (such as Twig\Extension\AbstractExtension, Twig\TwigFilter, Twig\TwigFunction, Twig\TwigTest, and Twig\Environment) instead of the deprecated legacy Twig_* classes. I have no feedback to provide as there are no review comments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
KostasNoreika
marked this pull request as ready for review
July 3, 2026 16:38
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.
Jira: AC-2375
Why
The
Twig_*legacy aliases are removed in Twig 3, so any Twig 3 / Symfony 4+ upgrade of this repo cannot even compile until they are gone. The migration was started earlier and abandoned midway:BaseExtension::getFunctions()had one modernnew TwigFunction(...)sitting directly beside 33 legacynew Twig_SimpleFunction(...)calls. This PR completes it. No upgrade is involved —twig/twig ^2.12(resolved: v2.16.1 on a freshcomposer installwith Composer 2.2.9 / PHP 7.4.33) already ships the namespaced API; the legacy names areclass_aliases of the exact classes substituted (verified in vendor sources:AbstractExtension.php:47,TwigFilter.php:145,TwigFunction.php:135,TwigTest.php:113,Environment.php:994).Exact mechanical mapping
Twig_Extension(extends)Twig\Extension\AbstractExtensionnew Twig_SimpleFilter(new Twig\TwigFilter(new Twig_SimpleFunction(new Twig\TwigFunction(new Twig_SimpleTest(new Twig\TwigTest(Twig_Environment(type-hint)Twig\EnvironmentFiles:
CodeGeneratorBundle/Twig/BaseExtension,PhpGeneratorBundle/Twig/{BundleExtension, ApiMethodExtension, FieldDefinitionExtension},JavascriptGeneratorBundle/Twig/{ApiMethodExtension, FieldDefinitionExtension}, plus the 3 commands below.Twig_Environment→Twig\Environmentin the 3 Command classes (GenerateRestClientCommand,GenerateSymfonyBundleCommand,GeneratePackageCommand) — also removed in Twig 3, constructor type-hint +useline only. The injectedtwigservice instance is the same object; DI needs no change (all three service XMLs register the extensions by their own Paysera FQCN).All option arrays preserved verbatim — 23
['needs_context' => true]occurrences across the 6 files (17 in BaseExtension), and both'is_safe'flags. Nothing else touched: no composer.json/lock edits, no DI, no templates, no fixtures.Proof (byte-identical output)
bin/phpunit(PHPUnit 9.6.34, PHP 7.4.33 in Docker) →OK (42 tests, 1736 assertions).OK (42 tests, 1736 assertions). The three golden-master tests (GenerateRestClientCommandTest,GenerateSymfonyBundleCommandTest,GeneratePackageCommandTest) compare generated output against the 910 fixture files undertests/**/Fixtures— all byte-identical,git statuson tests/ clean.bin/console php-generator:rest-clientrun on theaccountRAML fixture before and after the change into separate directories;diff -rof the two trees (9 generated files) → empty.git grep -E 'Twig_(Extension|SimpleFilter|SimpleFunction|SimpleTest|Environment)' -- ':!vendor'→ zero matches.bin/phpunit✓,bin/raml-code-generator✓,composer run compile(box) ✓,dist/raml-code-generator.pharsmoke ✓. The GitHub ActionsCIworkflow runs on this PR and must end green.Draft on purpose (blast radius: medium — touches the core generation path); please review before marking ready.