<commit_before><?php

/*
 * This file is part of Twig.
 *
 * (c) 2009 <NAME>
 * (c) 2009 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * Compiles a node to PHP code.
 *
 * @package    twig
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
class Twig_Compiler implements Twig_CompilerInterface
{
  protected $lastLine;
  protected $source;
  protected $indentation;
  protected $env;

  /**
   * Constructor.
   *
   * @param Twig_Environment $env The twig environment instance
   */
  public function __construct(Twig_Environment $env = null)
  {
    $this->env = $env;
  }

  public function setEnvironment(Twig_Environment $env)
  {
    $this->env = $env;
  }

  /**
   * Gets the current PHP code after compilation.
   *
   * @return string The PHP code
   */
  public function getSource()
  {
    return $this->source;
  }

  /**
   * Compiles a node.
   *
   * @param  Twig_Node $node The node to compile
   *
   * @return Twig_Compiler The current compiler instance
   */
  public function compile(Twig_Node $node)
  {
    $this->lastLine = null;
    $this->source = '';
    $this->indentation = 0;

    $node->compile($this);

    return $this;
  }

  public function subcompile(Twig_Node $node)
  {
    $node->compile($this);

    return $this;
  }

  /**
   * Adds a raw string to the compiled code.
   *
   * @param  string $string The string
   *
   * @return Twig_Compiler The current compiler instance
   */
  public function raw($string)
  {
    $this->source .= $string;

    return $this;
  }

  /**
   * Writes a string to the compiled code by adding indentation.
   *
   * @return Twig_Compiler The current compiler instance
   */
  public function write()
  {
    $strings = func_get_args();
    foreach ($strings as $string)
    {
      $this->source .= str_repeat(' ', $this->indentation * 2).$string;
    }

    return $this;
  }

  /**
   * Adds a quoted string to the compiled code.
   *
   * @param  string $string The string
   *
   * @return Twig_Compiler The current compiler instance
   */
  public function string($value)
  {
    $this->source .= sprintf('"%s"', addcslashes($value, "\t\"\$"));

    return $this;
  }

  /**
   * Returns a PHP representation of a given value.
   *
   * @param  mixed $value The value to convert
   *
   * @return Twig_Compiler The current compiler instance
   */<commit_msg>fixed \ usage in a HTML string<commit_after><?php

/*
 * This file is part of Twig.
 *
 * (c) 2009 <NAME>
 * (c) 2009 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * Compiles a node to PHP code.
 *
 * @package    twig
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
class Twig_Compiler implements Twig_CompilerInterface
{
  protected $lastLine;
  protected $source;
  protected $indentation;
  protected $env;

  /**
   * Constructor.
   *
   * @param Twig_Environment $env The twig environment instance
   */
  public function __construct(Twig_Environment $env = null)
  {
    $this->env = $env;
  }

  public function setEnvironment(Twig_Environment $env)
  {
    $this->env = $env;
  }

  /**
   * Gets the current PHP code after compilation.
   *
   * @return string The PHP code
   */
  public function getSource()
  {
    return $this->source;
  }

  /**
   * Compiles a node.
   *
   * @param  Twig_Node $node The node to compile
   *
   * @return Twig_Compiler The current compiler instance
   */
  public function compile(Twig_Node $node)
  {
    $this->lastLine = null;
    $this->source = '';
    $this->indentation = 0;

    $node->compile($this);

    return $this;
  }

  public function subcompile(Twig_Node $node)
  {
    $node->compile($this);

    return $this;
  }

  /**
   * Adds a raw string to the compiled code.
   *
   * @param  string $string The string
   *
   * @return Twig_Compiler The current compiler instance
   */
  public function raw($string)
  {
    $this->source .= $string;

    return $this;
  }

  /**
   * Writes a string to the compiled code by adding indentation.
   *
   * @return Twig_Compiler The current compiler instance
   */
  public function write()
  {
    $strings = func_get_args();
    foreach ($strings as $string)
    {
      $this->source .= str_repeat(' ', $this->indentation * 2).$string;
    }

    return $this;
  }

  /**
   * Adds a quoted string to the compiled code.
   *
   * @param  string $string The string
   *
   * @return Twig_Compiler The current compiler instance
   */
  public function string($value)
  {
    $this->source .= sprintf('"%s"', str_replace('\\\n', "\n", addcslashes($value, "\t\"\$\\")));

    return $this;
  }

  /**
   * Returns a PHP representation of a given value.
   *
   * @param  mixed $value The value to convert
   *
   * @return Twig_Compiler The current compiler instance
   */
{'fraction_non_alphanumeric': 0.1251516376870198, 'fraction_numerical': 0.0040436716538617065, 'mean_word_length': 2.6004366812227073, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6573447', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1572, 'n_words': 481}