Skip to content

Install Twig for the test suite again and run the Twig tests #626

Closed

Description

@armanist

Summary

Make twig/twig a required dependency again, so the Twig renderer works out of the box, its tests run instead of being skipped, and PHPStan analyzes the adapter against the real Twig classes.

Why

Twig is a rendering engine, and it was a normal required dependency of the framework until 3.0.3. It was taken out of the install in 3.0.3 (#532): vulnerable Twig releases were fixed only in versions that need PHP 8.1, and the framework still supported PHP 8.0. Twig became an optional renderer, its tests skip when it is missing, and stubs/Twig.stub stands in for it in PHPStan.

PHP 8.1 is the minimum now (#595). Composer resolves twig/twig:^3.27 on PHP 8.1 (currently v3.30.0), and composer audit reports no advisories. Four tests skip today because Twig is not installed: TwigAdapterTest::testTwigAdapterRenderView, RendererFactoryTest::testRendererFactoryTwigAdapter, RendererTest::testRendererGetTwigAdapter and ViewTest::testRenderViewWithTwig.

Scope

  • Move "twig/twig": "^3.27" from suggest to require in composer.json.
  • Remove stubs/Twig.stub and its entry in phpstan.neon.dist, so PHPStan analyzes src/Renderer/Adapters/TwigAdapter.php against the real Twig classes. Any new finding is fixed or reported.
  • Check that the four skipped tests run and pass on PHP 8.1, 8.2 and 8.3.
  • RendererException::twigNotInstalled(), the class_exists guard in TwigAdapter and TwigAdapterTest::testTwigAdapterThrowsActionableExceptionWhenTwigIsMissing become dead code once Twig is required: remove them, or keep them as a safety net (decided in the pull request).
  • Add the CHANGELOG.md entry.

Acceptance Criteria

  • twig/twig ^3.27 is in require and no longer in suggest
  • the four Twig tests run and pass
  • the Twig stub is gone and composer phpstan passes
  • composer test, composer cs:check and composer rector:check pass on PHP 8.1 to 8.3
  • the changelog lists the change

Activity

  1. added this to the 3.1.1 milestone on Oct 27, 2026
  2. self-assigned this
    on Oct 27, 2026
  3. added 3 commits that reference this issue on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions