8000 Type error: Argument 1 passed to Twig_Environment::addExtension() must implement interface Twig_ExtensionInterface, boolean given · Issue #28657 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
< 8000 template class="js-flash-template">

Type error: Argument 1 passed to Twig_Environment::addExtension() must implement interface Twig_ExtensionInterface, boolean given #28657

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

Closed
hanzx opened this issue Oct 1, 2018 · 16 comments

Comments

@hanzx
Copy link
hanzx commented Oct 1, 2018

Symfony version(s) affected: 3.4.16

Description
After update Symfony from v.3.4.15 to 3.4.16

How to reproduce
Type error: Argument 1 passed to Twig_Environment::addExtension() must implement interface Twig_ExtensionInterface, boolean given, called in /var/www/artikul/website/var/cache/dev/ContainerDhxuzns/appDevDebugProjectContainer.php on line 1586

@xabbuh
Copy link
Member
xabbuh commented Oct 1, 2018

Can you please provide some instructions on how to reproduce this issue?

@hanzx
Copy link
Author
hanzx commented Oct 1, 2018

composer update :) its all

@MWMathieu
Copy link
MWMathieu commented Oct 1, 2018

Same problem just composer update for reproduce

@fracsi
Copy link
Contributor
fracsi commented Oct 1, 2018

For me FMElfinderBundle's Twig extension causes the problem.
The relevant code from the compiled container is:

$instance->addExtension(${($_ = isset($this->services['twig.extension.fm_elfinder_init']) ? $this->services['twig.extension.fm_elfinder_init'] : $this->getTwig_Extension_FmElfinderInitService()) && false ?: '_'});`

The function call for the service:

protected function getTwig_Extension_FmElfinderInitService()
{
    $a = ${($_ = isset($this->services['twig']) ? $this->services['twig'] : $this->getTwigService()) && false ?: '_'};

    if (isset($this->privates['twig.extension.fm_elfinder_init'])) {
        return $this->privates['twig.extension.fm_elfinder_init'];
    }

    return $this->services['twig.extension.fm_elfinder_init'] = new \FM\ElfinderBundle\Twig\Extension\FMElfinderExtension($a);
}

If i make the twig.extension.fm_elfinder_init service public, the problem disappears.

@dpfaffenbauer
Copy link

Yep, same here. Doesn't even apply to just Twig, also happens to other private services. I tracked the problem down, and I think it comes from this commit:

e5c5405#diff-f7b23d463cba27ac5e4cb677f2be7623

@crazyball
Copy link

Same problem here since 3.4.16, all my private services are returning boolean instead of themselves.

@NathanVss
Copy link

Same problem here.

@pierredup
Copy link
Contributor

Seems related to #28658

@yellow1912
Copy link
yellow1912 commented Oct 1, 2018

This is the 2nd time we get this issue with private services, it break tons of things and is a serious bug. I think this is a very serious issue and some kind of testing code must be put in place to prevent this from happening in the future.

I'm referring to this one: #27756

@xabbuh
Copy link
Member
xabbuh commented Oct 1, 2018

I am going to close here. Even if this issue is newer than #28658 the other one is easier for us to handle as it contains a reproducible example. Thank you for reporting. 👍

@xabbuh xabbuh closed this as completed Oct 1, 2018
@suknaic
Copy link
suknaic commented Apr 24, 2019

Same problem here.

$container['view'] = function ($container) {
    $view = new \Slim\Views\Twig(__DIR__ . '/../templates');

    $view->addExtension(new \Slim\Views\TwigExtension(
        $container->router,
        $container->request->getUri()
    ));

    $view->addExtension(new \Twig_Extension_Debug());
    $view->enableDebug();

    $view->getEnvironment()->addGlobal('flash', $container->flash);

    return $view;
};
``
Expected type 'Twig_ExtensionInterface'. Found 'Slim\Views\TwigExtension'.intelephense(10006)

@xabbuh
Copy link
Member
xabbuh commented Apr 24, 2019

Please open a new issue with some example that allows to reproduce what you experience.

@afilina
Copy link
Contributor
afilina commented May 17, 2019

I got this issue after I updated composer packages. I then ran bin/console cache:clear for this error to go away. I hope this helps someone.

@andres030405
Copy link

tienes @afilina , gracias a mi me funciono

@andres030405
Copy link
andres030405 commented Jan 7, 2020

en el directorio raíz se tiene que ejecutar en la consola: php bin/console cache:clear --env=prod

@SoheibOuad
Copy link
SoheibOuad commented Jun 5, 2020

Hi everyone , i have this error when i lunch my application symfony , can anyone help me ? :
Type error: Argument 1 passed to Twig\Environment::tokenize() must be an instance of Twig\Source, string given, called in /mnt/c/Users/sol/Documents/gestion_projet/vendor/kriswallsmith/assetic/src/Assetic/Extension/Twig/TwigFormulaLoader.php on line 34
@afilina @jan Pukovský

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

No branches or pull requests

0