Timber: PHP 7 and Twig compatibility

Created on 17 Jan 2017  Â·  4Comments  Â·  Source: timber/timber

Hi
I am using Timber with php v7
After update timber to v1.2.1 twig updated to version ^2.0 from ^1.0

Actual behavior results in error

Argument 1 passed to Twig_Filter::__construct() must be an instance of string, string given, called in wp-content/plugins/timber-library/lib/Twig.php on line 40 and defined in /vendor/twig/twig/lib/Twig/Filter.php on line 35

When I remove string declaration I get another error

Argument 1 passed to Twig_Environment::addFunction() must be an instance of Twig_Function, instance of Twig_SimpleFunction given, ...

etc.
I think it's something with php V7 and scalars. Is this problem of Timber or it's Twig problem?

WordPress 4.7.1, PHP 7.0.14, Timber 1.2.1
Timber installed via Composer

Thanks

bug help wanted

Most helpful comment

@ogrosko Just add composer dependency for Twig 1 and everything should be working again.

All 4 comments

@ogrosko this looks to be Timber's problem with how this line is handled...

$twig->addFilter(new \Twig_SimpleFilter('resize', array('Timber\ImageHelper', 'resize')));

... based on some reading it seems that at least one of those strings should be a string instance. This is where I get lost (also I'm not able to re-create the error) — is this something you could help isolate and debug @ogrosko?

@ogrosko Just add composer dependency for Twig 1 and everything should be working again.

@mahagr Temporary I solve the problem like you wrote
@jarednova I'll check that

Closed by #1359

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chetzof picture chetzof  Â·  4Comments

chaimaech picture chaimaech  Â·  4Comments

bambamboole picture bambamboole  Â·  6Comments

lmartins picture lmartins  Â·  4Comments

jarednova picture jarednova  Â·  5Comments