for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
*
* This file is part of phpFastCache.
* @license MIT License (MIT)
* For full copyright and license information, please see the docs/CREDITS.txt file.
* @author Georges.L (Geolim4) <[email protected]>
* @author PastisD https://github.com/PastisD
* @author Alexander (asm89) <[email protected]>
* @author Khoa Bui (khoaofgod) <[email protected]> http://www.phpfastcache.com
*/
declare(strict_types=1);
namespace Phpfastcache\Bundle\Twig\CacheExtension\TokenParser;
use Phpfastcache\Bundle\Twig\CacheExtension\Node\CacheNode;
* Parser for cache/endcache blocks.
* @author Alexander <[email protected]>
class Cache extends \Twig_TokenParser
{
* @param \Twig_Token $token
* @return boolean
public function decideCacheEnd(\Twig_Token $token)
return $token->test('endcache');
}
* {@inheritDoc}
public function getTag()
return 'cache';
public function parse(\Twig_Token $token)
$lineno = $token->getLine();
$stream = $this->parser->getStream();
$annotation = $this->parser->getExpressionParser()->parseExpression();
$key = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideCacheEnd'), true);
return new CacheNode($annotation, $key, $body, $lineno, $this->getTag());