Skip to content

Issue/626 Require Twig again - #630

Merged
armanist merged 3 commits into
quantum-php:3.1.xfrom
armanist:issue/626-require-twig
Oct 28, 2026
Merged

armanist merged 3 commits into
quantum-php:3.1.xfrom
armanist:issue/626-require-twig

Conversation

@armanist

Copy link
Copy Markdown
Collaborator

Closes #626.

What changed

  • composer.json: twig/twig ^3.27 moves from suggest to require. Twig is a rendering engine, and it was a required dependency of the framework until 3.0.3.
  • stubs/Twig.stub and its scanFiles entry in phpstan.neon.dist are removed, so PHPStan analyzes TwigAdapter against the real Twig classes.
  • RendererException::twigNotInstalled() and the class_exists check in TwigAdapter that threw it are removed: they only existed while Twig was optional. RendererException keeps its inherited constructors (adapterNotSupported(), fileNotFound(), methodNotSupported()).
  • The markTestSkipped('… not installed') guards in the four Twig tests, and the test for the missing package, are removed.
  • CHANGELOG.md: a Changed entry that reverses the 3.0.3 note (Prepare Quantum Framework for quantum-php org transition with PHP 8+ baseline #532).

Why

Twig was moved to suggest in 3.0.3 (#532) as a temporary measure: the vulnerable Twig releases were fixed only in versions that need PHP 8.1, and the framework still supported PHP 8.0. PHP 8.1 is the minimum now (#595), twig/twig:^3.27 resolves on it (currently v3.30.0), and composer audit reports no advisories.

Breaking changes

An application that pins Twig below 3.27 (the old requirement pinned it below 3.26 for PHP 7.4 and 8.0, #529) has to allow ^3.27 on its next composer update. Code that caught the exception from RendererException::twigNotInstalled() no longer has anything to catch, because Twig is always installed. The changelog says so.

Testing

  • TwigAdapterTest::testTwigAdapterRenderView, RendererFactoryTest::testRendererFactoryTwigAdapter, RendererTest::testRendererGetTwigAdapter and ViewTest::testRenderViewWithTwig were skipped (0 assertions) and now run and pass.
  • The test for the missing package is removed together with the code it covered.
  • I also rendered a richer template against Twig v3.30.0 (a loop, the upper and number_format filters, autoescaping of <script> and <b>, and a framework helper and a PHP function called from Twig) on PHP 8.1, and ran the Renderer and View tests on PHP 8.2 with all error levels on. No deprecations.

Notes for reviewers

  • This pull request targets 3.1.x, the maintenance branch of the 3.1 line.
  • The adapter registers every defined PHP function as a Twig function, so where a PHP function has the same name as a Twig built-in (date, max, min, range, random), the PHP one wins. That is not new and is not changed here.
  • The renderer pages of the docs still say Twig is optional; they are updated separately.

armanist and others added 3 commits October 28, 2026 19:34
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9cdf5ef7-79ef-4df4-b6ea-fd3422e7c701

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@armanist
armanist merged commit 6f4ea1e into quantum-php:3.1.x Oct 28, 2026
6 checks passed
@armanist
armanist deleted the issue/626-require-twig branch October 28, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant