Skip to content

Commit

Permalink
fix partial stack position shift bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zordius committed Jun 9, 2019
1 parent 7743be8 commit e232e13
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ protected static function operator($operator, &$context, &$vars)
switch ($operator) {
case '#*':
if (!$context['compile']) {
$context['stack'][] = count($context['parsed'][0]);
$context['stack'][] = count($context['parsed'][0]) + ($context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE] === '' ? 0 : 1);
static::pushStack($context, '#*', $vars);
}
return static::inline($context, $vars);

case '#>':
if (!$context['compile']) {
$context['stack'][] = count($context['parsed'][0]);
$context['stack'][] = count($context['parsed'][0]) + ($context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE] === '' ? 0 : 1);
$vars[Parser::PARTIALBLOCK] = ++$context['usedFeature']['pblock'];
static::pushStack($context, '#>', $vars);
}
Expand Down Expand Up @@ -272,7 +272,7 @@ protected static function inlinePartial(&$context, $vars)
if ($context['currentToken'][Token::POS_OP] === '/') {
if (static::blockEnd($context, $vars, '#*') !== null) {
$context['usedFeature']['inlpartial']++;
$tmpl = array_shift($context['inlinepartial']) . $context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE];
$tmpl = array_shift($context['inlinepartial']) . $context['currentToken'][Token::POS_LOTHER] . $context['currentToken'][Token::POS_LSPACE];
$c = $context['stack'][count($context['stack']) - 4];
$context['parsed'][0] = array_slice($context['parsed'][0], 0, $c + 1);
$P = &$context['parsed'][0][$c];
Expand Down Expand Up @@ -300,6 +300,7 @@ protected static function partialBlock(&$context, $vars)
if ($context['currentToken'][Token::POS_OP] === '/') {
if (static::blockEnd($context, $vars, '#>') !== null) {
$c = $context['stack'][count($context['stack']) - 4];
$context['parsed'][0] = array_slice($context['parsed'][0], 0, $c + 1);
$found = Partial::resolve($context, $vars[0][0]) !== null;
$v = $found ? "@partial-block{$context['parsed'][0][$c][1][Parser::PARTIALBLOCK]}" : "{$vars[0][0]}";
if (count($context['partialblock']) == 1) {
Expand All @@ -314,7 +315,6 @@ protected static function partialBlock(&$context, $vars)
}
}
array_shift($context['partialblock']);
$context['parsed'][0] = array_slice($context['parsed'][0], 0, $c + 1);
$ended = true;
}
}
Expand Down

0 comments on commit e232e13

Please sign in to comment.