Hello, I have a PHP error :
A PHP Error was encountered
Severity: Warning
Message: call_user_func() expects parameter 1 to be a valid callback, no array or string given
Filename: Extension/Escaper.php
Line Number: 72
Backtrace:
File: /mnt/c/Users/Thibault MARTIN/Documents/sites/Omega/vendor/twig/twig/lib/Twig/Extension/Escaper.php
Line: 72
Function: _error_handler
What's the value of https://github.com/twigphp/Twig/blob/2.x/lib/Twig/Extension/Escaper.php#L14 in your case and where does it get set from?
I have private $defaultStrategy;
I'm interested in the contents of this variable.
Sorry,
The contents = TRUE
So that's the problem. It must not be true. Can you debug now why it is true? You can check setDefaultStrategy and look in the backtrace.
I used Codeigniter, no symfony
Closing as this is apparently not a Twig issue (perhaps a problem with the integration with Codeigniter, but we don't have any information that would help us find the issue).
im having same issue @ThibaultMartinPenbase did you found any fix for that?
In Escaper.php for Codeigniter 3.*
Remplace te constructor by that
public function __construct($defaultStrategy = true){
if (true === $defaultStrategy) {
$defaultStrategy = 'html';
};
$this->setDefaultStrategy($defaultStrategy);
}
I you did it like me and got the CodeIgniter Twig implementation from an online tutorial and got this error, the solution is to change
$config['twig']['environment']['autoescape'] = TRUE;
to
$config['twig']['environment']['autoescape'] = 'html';
in the file ./application/config/twig.php as the solution from @kraven30 won't work when Twig is updated.
Most helpful comment
I you did it like me and got the CodeIgniter Twig implementation from an online tutorial and got this error, the solution is to change
$config['twig']['environment']['autoescape'] = TRUE;to
$config['twig']['environment']['autoescape'] = 'html';in the file ./application/config/twig.php as the solution from @kraven30 won't work when Twig is updated.