Twig update to latest Twig 1.x legacy as per vichan

This commit is contained in:
Benjamin Southall 2019-02-26 10:11:12 +10:00
parent 4ecd84f81d
commit e6c07544da
198 changed files with 6150 additions and 2506 deletions

View file

@ -3,8 +3,8 @@
/*
* This file is part of Twig.
*
* (c) 2010 Fabien Potencier
* (c) 2010 Arnaud Le Blanc
* (c) Fabien Potencier
* (c) Arnaud Le Blanc
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -14,6 +14,7 @@
* Default implementation of a token parser broker.
*
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
*
* @deprecated since 1.12 (to be removed in 2.0)
*/
class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
@ -23,42 +24,35 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
protected $brokers = array();
/**
* Constructor.
*
* @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
* @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
* @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
* @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
* @param bool $triggerDeprecationError
*/
public function __construct($parsers = array(), $brokers = array())
public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
}
foreach ($parsers as $parser) {
if (!$parser instanceof Twig_TokenParserInterface) {
throw new LogicException('$parsers must a an array of Twig_TokenParserInterface');
throw new LogicException('$parsers must a an array of Twig_TokenParserInterface.');
}
$this->parsers[$parser->getTag()] = $parser;
}
foreach ($brokers as $broker) {
if (!$broker instanceof Twig_TokenParserBrokerInterface) {
throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface');
throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface.');
}
$this->brokers[] = $broker;
}
}
/**
* Adds a TokenParser.
*
* @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
*/
public function addTokenParser(Twig_TokenParserInterface $parser)
{
$this->parsers[$parser->getTag()] = $parser;
}
/**
* Removes a TokenParser.
*
* @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
*/
public function removeTokenParser(Twig_TokenParserInterface $parser)
{
$name = $parser->getTag();
@ -67,22 +61,12 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
}
}
/**
* Adds a TokenParserBroker.
*
* @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance
*/
public function addTokenParserBroker(Twig_TokenParserBroker $broker)
public function addTokenParserBroker(self $broker)
{
$this->brokers[] = $broker;
}
/**
* Removes a TokenParserBroker.
*
* @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance
*/
public function removeTokenParserBroker(Twig_TokenParserBroker $broker)
public function removeTokenParserBroker(self $broker)
{
if (false !== $pos = array_search($broker, $this->brokers)) {
unset($this->brokers[$pos]);