Volt Compiler is producing broken and horrifically ugly code

Phalcon\Mvc\View\Engine\Volt\Compiler is producing broken and horrifically ugly and BROKEN code.

take this pretty code produced through the view service:

<ul class="nav navbar-nav"><?php $menus = array('about' => $this->translate->gettext('About')); ?><?php foreach ($menus as $key => $value) { ?>
    <?php if ($value == $this->dispatcher->getControllerName()) { ?>
    <li class="active"><?php echo $this->tag->linkTo(array($key, $value)); ?></li>
    <?php } else { ?>
    <li><?php echo $this->tag->linkTo(array($key, $value)); ?></li>
    <?php } ?><?php } ?></ul>

compared to this monstrosity that is also broken:

<ul class="nav navbar-nav"><?php $menus = array('about' => $this->translate->gettext('About')); ?><?php $v82462843106908991761iterator = $menus; $v82462843106908991761incr = 0; $v82462843106908991761loop = new stdClass(); $v82462843106908991761loop->length = count($v82462843106908991761iterator); $v82462843106908991761loop->index = 1; $v82462843106908991761loop->index0 = 1; $v82462843106908991761loop->revindex = $v82462843106908991761loop->length; $v82462843106908991761loop->revindex0 = $v82462843106908991761loop->length - 1; ?><?php foreach ($v82462843106908991761iterator as $key => $value) { ?><?php $v82462843106908991761loop->first = ($v82462843106908991761incr == 0); $v82462843106908991761loop->index = $v82462843106908991761incr + 1; $v82462843106908991761loop->index0 = $v82462843106908991761incr; $v82462843106908991761loop->revindex = $v82462843106908991761loop->length - $v82462843106908991761incr; $v82462843106908991761loop->revindex0 = $v82462843106908991761loop->length - ($v82462843106908991761incr + 1); $v82462843106908991761loop->last = ($v82462843106908991761incr == ($v82462843106908991761loop->length - 1)); ?>
    <?php if ($value == $dispatcher->getControllerName()) { ?>
    <li class="active"><?php echo $this->tag->linkTo(array($key, $value)); ?></li>
    <?php } else { ?>
    <li><?php echo $this->tag->linkTo(array($key, $value)); ?></li>
    <?php } ?><?php $v82462843106908991761incr++; } ?></ul>

I'm wondering why the stand alone Volt compiler is trying to uglify this code so much.



83.4k

When variable "loop" is used inside a "for", Volt has to create hidden variables, it chooses a name like $v82462843106908991761 to ensure that a variable is not created by the developer avoiding cause a naming conflict.