Skip to content
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

Support unnamed function arguments to compiler plugins in Smarty 5 #1088

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gkreitz
Copy link
Contributor

@gkreitz gkreitz commented Nov 29, 2024

Fixes the regression in Smarty 5 where a compiler function using unnamed arguments threw a "Too many shorthand
attributes" error, and adds unit test coverage.

Fixes #1085

@@ -91,8 +102,8 @@ protected function getAttributes($compiler, $attributes) {
if (isset($options[trim($mixed, '\'"')])) {
$_indexed_attr[trim($mixed, '\'"')] = true;
// shorthand attribute ?
} elseif (isset($this->shorttag_order[$key])) {
$_indexed_attr[$this->shorttag_order[$key]] = $mixed;
} elseif (!is_null($this->getShorthandOrder($key))) {
Copy link
Contributor Author

@gkreitz gkreitz Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the type of $key is always int here, based on the fact that it looks like $attributes is a list<mixed> from the usage, but I do not know enough about the code base to know. If my assumption is incorrect, the type of the argument to getShorthandOrder needs to be changed to avoid crashing.

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

Successfully merging this pull request may close these issues.

A compiler plugin that takes unnamed arguments throws "Too many shorthand attributes" in Smarty 5
1 participant