mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 04:16:28 +00:00
Fixed somes issues from SensioLabsInsight
This commit is contained in:
@@ -258,12 +258,12 @@ class Twig_Extension_Core extends Twig_Extension
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parseNotTestExpression(Twig_Parser $parser, $node)
|
public function parseNotTestExpression(Twig_Parser $parser, Twig_NodeInterface $node)
|
||||||
{
|
{
|
||||||
return new Twig_Node_Expression_Unary_Not($this->parseTestExpression($parser, $node), $parser->getCurrentToken()->getLine());
|
return new Twig_Node_Expression_Unary_Not($this->parseTestExpression($parser, $node), $parser->getCurrentToken()->getLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parseTestExpression(Twig_Parser $parser, $node)
|
public function parseTestExpression(Twig_Parser $parser, Twig_NodeInterface $node)
|
||||||
{
|
{
|
||||||
$stream = $parser->getStream();
|
$stream = $parser->getStream();
|
||||||
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
|
|||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function optimizeVariables($node, $env)
|
protected function optimizeVariables(Twig_NodeInterface $node, Twig_Environment $env)
|
||||||
{
|
{
|
||||||
if ('Twig_Node_Expression_Name' === get_class($node) && $node->isSimple()) {
|
if ('Twig_Node_Expression_Name' === get_class($node) && $node->isSimple()) {
|
||||||
$this->prependedNodes[0][] = $node->getAttribute('name');
|
$this->prependedNodes[0][] = $node->getAttribute('name');
|
||||||
@@ -129,7 +129,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
|
|||||||
* @param Twig_NodeInterface $node A Node
|
* @param Twig_NodeInterface $node A Node
|
||||||
* @param Twig_Environment $env The current Twig environment
|
* @param Twig_Environment $env The current Twig environment
|
||||||
*/
|
*/
|
||||||
protected function optimizePrintNode($node, $env)
|
protected function optimizePrintNode(Twig_NodeInterface $node, Twig_Environment $env)
|
||||||
{
|
{
|
||||||
if (!$node instanceof Twig_Node_Print) {
|
if (!$node instanceof Twig_Node_Print) {
|
||||||
return $node;
|
return $node;
|
||||||
@@ -153,7 +153,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
|
|||||||
* @param Twig_NodeInterface $node A Node
|
* @param Twig_NodeInterface $node A Node
|
||||||
* @param Twig_Environment $env The current Twig environment
|
* @param Twig_Environment $env The current Twig environment
|
||||||
*/
|
*/
|
||||||
protected function optimizeRawFilter($node, $env)
|
protected function optimizeRawFilter(Twig_NodeInterface $node, Twig_Environment $env)
|
||||||
{
|
{
|
||||||
if ($node instanceof Twig_Node_Expression_Filter && 'raw' == $node->getNode('filter')->getAttribute('value')) {
|
if ($node instanceof Twig_Node_Expression_Filter && 'raw' == $node->getNode('filter')->getAttribute('value')) {
|
||||||
return $node->getNode('node');
|
return $node->getNode('node');
|
||||||
@@ -168,7 +168,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
|
|||||||
* @param Twig_NodeInterface $node A Node
|
* @param Twig_NodeInterface $node A Node
|
||||||
* @param Twig_Environment $env The current Twig environment
|
* @param Twig_Environment $env The current Twig environment
|
||||||
*/
|
*/
|
||||||
protected function enterOptimizeFor($node, $env)
|
protected function enterOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env)
|
||||||
{
|
{
|
||||||
if ($node instanceof Twig_Node_For) {
|
if ($node instanceof Twig_Node_For) {
|
||||||
// disable the loop variable by default
|
// disable the loop variable by default
|
||||||
@@ -217,7 +217,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
|
|||||||
* @param Twig_NodeInterface $node A Node
|
* @param Twig_NodeInterface $node A Node
|
||||||
* @param Twig_Environment $env The current Twig environment
|
* @param Twig_Environment $env The current Twig environment
|
||||||
*/
|
*/
|
||||||
protected function leaveOptimizeFor($node, $env)
|
protected function leaveOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env)
|
||||||
{
|
{
|
||||||
if ($node instanceof Twig_Node_For) {
|
if ($node instanceof Twig_Node_For) {
|
||||||
array_shift($this->loops);
|
array_shift($this->loops);
|
||||||
|
|||||||
+1
-1
@@ -246,7 +246,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||||||
return $this->blocks[$name];
|
return $this->blocks[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlock($name, $value)
|
public function setBlock($name, Twig_Node_Block $value)
|
||||||
{
|
{
|
||||||
$this->blocks[$name] = new Twig_Node_Body(array($value), array(), $value->getLine());
|
$this->blocks[$name] = new Twig_Node_Body(array($value), array(), $value->getLine());
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -121,11 +121,10 @@ class Twig_Token
|
|||||||
*
|
*
|
||||||
* @param integer $type The type as an integer
|
* @param integer $type The type as an integer
|
||||||
* @param Boolean $short Whether to return a short representation or not
|
* @param Boolean $short Whether to return a short representation or not
|
||||||
* @param integer $line The code line
|
|
||||||
*
|
*
|
||||||
* @return string The string representation
|
* @return string The string representation
|
||||||
*/
|
*/
|
||||||
public static function typeToString($type, $short = false, $line = -1)
|
public static function typeToString($type, $short = false)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case self::EOF_TYPE:
|
case self::EOF_TYPE:
|
||||||
@@ -178,11 +177,10 @@ class Twig_Token
|
|||||||
* Returns the english representation of a given type.
|
* Returns the english representation of a given type.
|
||||||
*
|
*
|
||||||
* @param integer $type The type as an integer
|
* @param integer $type The type as an integer
|
||||||
* @param integer $line The code line
|
|
||||||
*
|
*
|
||||||
* @return string The string representation
|
* @return string The string representation
|
||||||
*/
|
*/
|
||||||
public static function typeToEnglish($type, $line = -1)
|
public static function typeToEnglish($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case self::EOF_TYPE:
|
case self::EOF_TYPE:
|
||||||
|
|||||||
Reference in New Issue
Block a user