Skip to content

[Toolkit] Fix the kit linter crashing on Twig 4 - #4041

Merged
Kocal merged 1 commit into
symfony:3.xfrom
Kocal:fix/toolkit-twig-token-test
Oct 5, 2026
Merged

Kocal merged 1 commit into
symfony:3.xfrom
Kocal:fix/toolkit-twig-token-test

Conversation

@Kocal

@Kocal Kocal commented Oct 5, 2026

Copy link
Copy Markdown
Member
Q A
Bug fix? yes
New feature? no
Deprecations? no
Documentation? no
Issues
License MIT

Twig deprecated Token::getType() in 3.19, and its 4.x branch removes it entirely. ComponentDocScanner calls this method to find the blocks a component renders, and bin/ux-toolkit-kit-lint relies on that scanner. The Lint <kit> CI jobs install Twig 4.x-dev, so they crash with Call to undefined method Twig\Token::getType(). On Twig 3.x the code still works, but every call triggers a deprecation warning.

ComponentDocScanner now uses Token::test() instead, which is the replacement Twig recommends. It exists on both Twig 3.x and 4.x, so the scanner works on both without deprecations.

| Q              | A
| -------------- | ---
| Bug fix?       | yes
| New feature?   | no
| Deprecations?  | no
| Documentation? | no
| Issues         |
| License        | MIT

Twig deprecated `Token::getType()` in 3.19, and its `4.x` branch removes it entirely. `ComponentDocScanner` calls this method to find the blocks a component renders, and `bin/ux-toolkit-kit-lint` relies on that scanner. The `Lint <kit>` CI jobs install Twig 4.x-dev, so they crash with `Call to undefined method Twig\Token::getType()`. On Twig 3.x the code still works, but every call triggers a deprecation warning.

`ComponentDocScanner` now uses `Token::test()` instead, which is the replacement Twig recommends. It exists on both Twig 3.x and 4.x, so the scanner works on both without deprecations.

| Twig | Before | After
| ---- | ------ | -----
| 3.30 | a deprecation for each token | no deprecation
| 4.x-dev | `Call to undefined method Twig\Token::getType()` | the linter passes on every kit
@Kocal Kocal self-assigned this Oct 5, 2026
@carsonbot carsonbot added Bug Bug Fix Toolkit Status: Needs Review Needs to be reviewed labels Oct 5, 2026
@Kocal
Kocal merged commit b9b03f5 into symfony:3.x Oct 5, 2026
36 of 44 checks passed
@Kocal
Kocal deleted the fix/toolkit-twig-token-test branch October 5, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Bug Fix Status: Needs Review Needs to be reviewed Toolkit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants