-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
Fix twig_to_array is deprecated #1337
Conversation
WebMamba
commented
Dec 14, 2023
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
Issues | |
License | MIT |
It's the same bug for all the pacakges failing in the CI ? |
With this PR in complement #1330 the CI should be green again! 😁 |
// since twig/twig 3.9.0: Using the internal "twig_to_array" function is deprecated. | ||
$compiler | ||
->write('$toArray = function ($data) {') | ||
->write('if (method_exists(Twig\Extension\CoreExtension::class, \'toArray\')) {') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test should be done on compile time and not on render time... Or we will call method_exists a billion time per render..
So i'd make something like
if (method_exists(...)) {
$compiler->write('return Twig\Extension\CoreExtension::toArray($data);')
} else {
$compiler->write('return twig_to_array'...)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a nice idea 👍
Could we merge this one @weaverryan @kbond ? ( if it's all good for you @WebMamba ) I'd like to bring the green back on the CI, having a better vision of current PR checks |
16f0c79
to
2a2ab7c
Compare
Thanks Matheo. |