-
Notifications
You must be signed in to change notification settings - Fork 715
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
base: master
Are you sure you want to change the base?
Support unnamed function arguments to compiler plugins in Smarty 5 #1088
Conversation
@@ -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))) { |
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 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.
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.
Well, all the unit tests pass and I haven't found any references to shorttag_order
in the source that suggest other keys. But as you noted, it only looks that way and is not guaranteed. Just to be safe, I'd prefer to allow a mixed type for the key
param to getShorthandOrder
.
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.
Sorry for the slow response. I removed the php type annotations to be on the safe side.
From usage, it very much looks like the type will always be int, but on the off chance there is some code path where this gets called with something else, type was widened to mixed for now, per disussion in smarty-php#1088
9bb3447
to
91dd198
Compare
From usage, it very much looks like the type will always be int, but on the off chance there is some code path where this gets called with something else, type was widened to mixed for now, per disussion in smarty-php#1088
91dd198
to
0d24f1d
Compare
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