Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Twig] Creating new projects on PHP 7.1 not possible #39734

Closed
NicoHaase opened this issue Jan 6, 2021 · 9 comments
Closed

[Twig] Creating new projects on PHP 7.1 not possible #39734

NicoHaase opened this issue Jan 6, 2021 · 9 comments

Comments

@NicoHaase
Copy link
Contributor

NicoHaase commented Jan 6, 2021

Symfony version(s) affected: 4.4 / Twig v2

Description
When bootstrapping a new project using PHP 7.1 through composer create-project symfony/website-skeleton, there' a incompatibility: twig/extra-bundle is installed in v3.2.0 and twig/twig in v2.13.1.

Building the container calls registerUndefinedTokenParserCallback in Twig\Extra\TwigExtraBundle\DependencyInjection\Compiler\MissingExtensionSuggestorPass, but this method is not available in Twig v2.

!!  08:33:00 CRITICAL  [php] Uncaught Error: Call to undefined method Twig\Environment::registerUndefinedTokenParserCallback() ["exception" => Error { …}]
!!  
!!  In srcApp_KernelDevDebugContainer.php line 1546:
!!                                                                                                                     
!!    Attempted to call an undefined method named "registerUndefinedTokenParserCallback" of class "Twig\Environment".  
!!    Did you mean to call e.g. "registerUndefinedFilterCallback" or "registerUndefinedFunctionCallback"?              
!!                                                                                                                     
!!  
!!  cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

@derrabus
Copy link
Member

derrabus commented Jan 6, 2021

This sounds like a Twig bug to me.

@fabpot
Copy link
Member

fabpot commented Jan 6, 2021

There was a bug (fixed now in 3.2.1), so you must explicitly require twig/extra-bundle v2

@fabpot fabpot closed this as completed Jan 6, 2021
@NicoHaase
Copy link
Contributor Author

What do you mean by "fixed now"? I ran composer create-project symfony/website-skeleton about 20 minutes ago, and it did not run properly. As this is a documented way to start a new project, this still looks like a bug to me

@fabpot
Copy link
Member

fabpot commented Jan 6, 2021

I've just tried and it installed Twig 3 and Twig extra bundle 3 as well. How did you get Twig 2 with a brand new project?
In any case, I think I'm just going to remove the version from Packagist, there is no other way to fix it properly as the issue is in the composer.json constraints. Having a new version of 3 means that the problem is gone but Composer can still install the package with the constraint issue.

@NicoHaase
Copy link
Contributor Author

...just for nit-picking: did you really install Twig v3 on PHP 7.1? This should not be possible, as this is not marked as compatible

@fabpot
Copy link
Member

fabpot commented Jan 6, 2021

Understood now... I tried with PHP 7.4 :)

@NicoHaase
Copy link
Contributor Author

Thanks for checking again :) Also, is there any chance to check for such bugs before merging them, or is this too complicated?

@fabpot
Copy link
Member

fabpot commented Jan 6, 2021

If I had a magic trick to avoid bugs, I would sell it for a lot of money :)

@NicoHaase
Copy link
Contributor Author

NicoHaase commented Jan 6, 2021

I've checked this once again, and starting a project is possible again. Thanks for your quick response and your overall great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants