I got a case where a template was doing {{ value }} and received an empty array as value (due to a bug in my code). The stack trace for that was totally useless:
In the old buffer-based architecture, converting the array to a string would happen in the compiled template at the location of this {{ value }}, allowing to debug this.
The new architecture documents that Template::doDisplay should return an iterable<scalar|\Stringable|null>, but the compiled code does not actually ensure this is respected. PrintNode does not ensure that the expression result satisfies that type before yielding it.
This has 2 impact:
- when using
TemplateWrapper::render or TemplateWrapper::display (or the equivalent block-related methods), you will get warning with a useless stack trace (see my example)
- when using
TemplateWrapper::stream (or TemplateWrapper::streamBlock), the returned iterable will not satisfy the contract (and whether you get an error or warning will depend on how the iterable is consumed, but it won't have a stack trace reaching to the root cause in the PrintNode).
I got a case where a template was doing
{{ value }}and received an empty array asvalue(due to a bug in my code). The stack trace for that was totally useless:In the old buffer-based architecture, converting the array to a string would happen in the compiled template at the location of this
{{ value }}, allowing to debug this.The new architecture documents that
Template::doDisplayshould return aniterable<scalar|\Stringable|null>, but the compiled code does not actually ensure this is respected.PrintNodedoes not ensure that the expression result satisfies that type before yielding it.This has 2 impact:
TemplateWrapper::renderorTemplateWrapper::display(or the equivalent block-related methods), you will get warning with a useless stack trace (see my example)TemplateWrapper::stream(orTemplateWrapper::streamBlock), the returned iterable will not satisfy the contract (and whether you get an error or warning will depend on how the iterable is consumed, but it won't have a stack trace reaching to the root cause in the PrintNode).