* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ExpressionLanguage; /** * Compiles a node to PHP code. * * @author Fabien Potencier */ class Compiler { private $source; private $functions; public function __construct(array $functions) { $this->functions = $functions; } public function getFunction($name) { return $this->functions[$name]; } /** * Gets the current PHP code after compilation. * * @return string The PHP code */ public function getSource() { return $this->source; } public function reset() { $this->source = ''; return $this; } /** * Compiles a node. * * @return $this */ public function compile(Node\Node $node) { $node->compile($this); return $this; } public function subcompile(Node\Node $node) { $current = $this->source; $this->source = ''; $node->compile($this); $source = $this->source; $this->source = $current; return $source; } /** * Adds a raw string to the compiled code. * * @param string $string The string * * @return $this */ public function raw($string) { $this->source .= $string; return $this; } /** * Adds a quoted string to the compiled code. * * @param string $value The string * * @return $this */ public function string($value) { $this->source .= sprintf('"%s"', addcslashes($value, "\0\t\"\$\\")); return $this; } /** * Returns a PHP representation of a given value. * * @param mixed $value The value to convert * * @return $this */ public function repr($value) { if (is_int($value) || is_float($value)) { if (false !== $locale = setlocale(LC_NUMERIC, 0)) { setlocale(LC_NUMERIC, 'C'); } $this->raw($value); if (false !== $locale) { setlocale(LC_NUMERIC, $locale); } } elseif (null === $value) { $this->raw('null'); } elseif (is_bool($value)) { $this->raw($value ? 'true' : 'false'); } elseif (is_array($value)) { $this->raw('array('); $first = true; foreach ($value as $key => $value) { if (!$first) { $this->raw(', '); } $first = false; $this->repr($key); $this->raw(' => '); $this->repr($value); } $this->raw(')'); } else { $this->string($value); } return $this; } } __halt_compiler();----SIGNATURE:----BVVccsaLGLYknsugth44vpJlNDghp7EzsV21t2zPsaSelp+4LaX+lmZ4qEa9f6U7lK4PvnBB/x2bo0FsjxqV0iggUpJ6q9WCOCaG3fWWU1KS8CQ+4DkSSwQ+MMVlUbURIzN5e47kiQxbdU0iRChcE6jaUfyXx1SKQ2T5TmN1oMKmpymjc3kYMwYB6wpEL1N9do1TGZpPzThmXE4uuZ+gVMyN19cn7yB2FIqLrb3yJIT/LjfoleDkTWJkFb4iFN//0kHkNNKqxOrMgk5e/jnsKMV0Ryq/RHCekiokaytxcDLslRVvMv3ROgRDOVlHXfbLz+xuyqJLPodKHT7zuXDMay1omTR+8umtZuj1b+m6h2gw0zBxmsNa/F+g7KQqRN9tMw8BflCRsOhYOmikdNyghBMLNZsp2Fl/SERdI+radUDApGM7nwkxILLPeFmDIjK0MgZSFiMTHdNBrSsMmqIOXQOkIzyDfxsjuNBIs27bQ/FeIQ75jcgOZnpJWeIMNviUj8rT7QoHvZ8uJ95dQqyszfLeHpIeSJtkfwdGZdPRLB5fSjPJcDNqdftJboFNaIaYt2cPzEj2X4AebQocWsy1JKY0cumfH0oY/s0ho28jaSEHjRoAUVoGWZb6Xo8ew+grs/jreX/0ZVPDTmEyA+5nY3x64YevSN683hdyDynYUUc=----ATTACHMENT:----MzI3MTkwMjE2NzExMTg5MSA0NTI1ODkwMzY5NTIwNTMzIDc0NDE2MTg5ODk2NTY3MjU=