Esempio n. 1
0
 /**
  * Construct a new type cast.
  *
  * @param string $castToType
  * @param ezcTemplateAstNode $value
  */
 public function __construct($castToType, $value)
 {
     parent::__construct();
     // TODO, check for int, string, array, etc.
     $this->type = $castToType;
     $this->value = $value;
 }
Esempio n. 2
0
 /**
  * Constructs a new variable.
  *
  * @param string $name The name of the variable.
  */
 public function __construct($name)
 {
     parent::__construct();
     if (!is_string($name)) {
         throw new ezcBaseValueException("name", $name, 'string');
     }
     $this->name = $name;
     $this->typeHint = self::TYPE_VALUE;
 }
 /**
  * Constructs the ezcTemplateParameterizedAstNode.
  *
  * @param int $minParameterCount The minimum parameters the operator can have, set to false to remove limit.
  * @param int $maxParameterCount The maximum parameters the operator can have, set to false to remove limit.
  */
 public function __construct($minParameterCount = 1, $maxParameterCount = 1)
 {
     parent::__construct();
     if (!is_int($minParameterCount) && $minParameterCount !== false) {
         throw new ezcTemplateInternalException("The parameter \$minParameterCount needs be an integer.");
     }
     if (!is_int($maxParameterCount) && $maxParameterCount !== false) {
         throw new ezcTemplateInternalException("The parameter \$maxParameterCount needs be an integer.");
     }
     $this->minParameterCount = $minParameterCount;
     $this->maxParameterCount = $maxParameterCount;
     $this->parameters = array();
 }
Esempio n. 4
0
 /**
  * Initialize with function name code and optional arguments
  *
  * @param array(ezcTemplateStatementAstNode) $statements
  */
 public function __construct(array $statements = null)
 {
     parent::__construct();
     $this->statements = array();
     if ($statements !== null) {
         foreach ($statements as $statement) {
             if (!$statement instanceof ezcTemplateStatementAstNode) {
                 throw new ezcTemplateInternalException("Body code element can only use objects of instance ezcTemplateStatementAstNode as statements");
             }
         }
         $this->statements = $statements;
     }
 }
Esempio n. 5
0
 /**
  * Constructs a new Literal
  *
  * @param mixed $value The value of PHP type to be stored in code element.
  */
 public function __construct($value)
 {
     parent::__construct();
     $this->value = $value;
     if (is_resource($value)) {
         throw new ezcTemplateInternalException("Cannot use resource for type codes, resources cannot be exported as text strings");
     }
     // Check if the __set_state magic method is implemented
     if (is_object($value) && !method_exists($value, "__set_state")) {
         throw new ezcTemplateInternalException("The magic method __set_state is not implemented for passed object, the type code cannot create a representation of the object without it.");
     }
     $this->checkAndSetTypeHint();
 }
Esempio n. 6
0
 /**
  * Constructs a new ezcTemplate Literal array.
  */
 public function __construct()
 {
     parent::__construct();
     $this->checkAndSetTypeHint();
 }
Esempio n. 7
0
 /**
  * Initialize with function name code and optional arguments
  *
  * @param ezcTemplateAstNode $expression
  */
 public function __construct(ezcTemplateAstNode $expression = null)
 {
     parent::__construct();
     $this->expression = $expression;
 }
Esempio n. 8
0
 /**
  * Constructs a new ezcTemplateConstantAstNode
  *
  * @param mixed $value The value of constant.
  */
 public function __construct($value)
 {
     parent::__construct();
     $this->value = $value;
 }
Esempio n. 9
0
 /**
  * Initialize with condition and body statement.
  *
  * @param ezcTemplateAstNode $condition
  * @param ezcTemplateBodyAstNode $body
  */
 public function __construct(ezcTemplateAstNode $condition = null, ezcTemplateBodyAstNode $body = null)
 {
     parent::__construct();
     $this->condition = $condition;
     $this->body = $body;
 }