1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-12-20 19:35:54 +01:00
vichan/inc/lib/Twig/Node/Expression/GetAttr.php

54 lines
2.2 KiB
PHP
Raw Normal View History

2011-10-05 06:22:53 +02:00
<?php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
{
2013-08-01 21:20:12 +02:00
public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression_Array $arguments, $type, $lineno)
2011-10-05 06:22:53 +02:00
{
2013-08-01 21:20:12 +02:00
parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
2011-10-05 06:22:53 +02:00
}
public function compile(Twig_Compiler $compiler)
{
2013-08-01 21:20:12 +02:00
if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
$compiler->raw('twig_template_get_attributes($this, ');
2011-10-05 06:22:53 +02:00
} else {
2013-08-01 21:20:12 +02:00
$compiler->raw('$this->getAttribute(');
2011-10-05 06:22:53 +02:00
}
2013-08-01 21:20:12 +02:00
if ($this->getAttribute('ignore_strict_check')) {
$this->getNode('node')->setAttribute('ignore_strict_check', true);
2011-10-05 06:22:53 +02:00
}
2013-08-01 21:20:12 +02:00
$compiler->subcompile($this->getNode('node'));
$compiler->raw(', ')->subcompile($this->getNode('attribute'));
2013-09-19 08:08:25 +02:00
if (count($this->getNode('arguments')) || Twig_Template::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
2013-08-01 21:20:12 +02:00
$compiler->raw(', ')->subcompile($this->getNode('arguments'));
2013-09-19 08:08:25 +02:00
if (Twig_Template::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
2013-08-01 21:20:12 +02:00
$compiler->raw(', ')->repr($this->getAttribute('type'));
}
if ($this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
$compiler->raw(', '.($this->getAttribute('is_defined_test') ? 'true' : 'false'));
}
if ($this->getAttribute('ignore_strict_check')) {
$compiler->raw(', '.($this->getAttribute('ignore_strict_check') ? 'true' : 'false'));
}
}
$compiler->raw(')');
2011-10-05 06:22:53 +02:00
}
}