Esempio n. 1
0
 public function __construct($reason, $origin, $others = array())
 {
     C::guardIsString($reason);
     C::guardEach($others, "guardIsErrorValue");
     $this->_reason = $reason;
     $this->_others = $others;
     $this->_dict = null;
     parent::__construct($origin);
 }
Esempio n. 2
0
 public function __construct($function, $unwrap_args = true, $args = null, $arity = null, $reify_exceptions = null, $origin = null)
 {
     if ($origin === null) {
         if (is_string($function)) {
             $origin = $function;
         } else {
             $origin = V::ANONYMUS_FUNCTION_ORIGIN;
         }
     }
     parent::__construct($origin);
     if (is_string($function)) {
         C::guardIsCallable($function);
     } else {
         C::guardIsClosure($function);
     }
     C::guardIsBool($unwrap_args);
     $args = self::defaultTo($args, array());
     $reify_exceptions = self::defaultTo($reify_exceptions, array());
     C::guardIsArray($args);
     C::guardIfNotNull($arity, "guardIsUInt");
     C::guardIsArray($reify_exceptions);
     foreach ($args as $key => $value) {
         $args[$key] = $this->toValue($value, null);
     }
     if ($arity === null) {
         $refl = new ReflectionFunction($function);
         $this->_arity = $refl->getNumberOfParameters() - count($args);
     } else {
         $this->_arity = $arity - count($args);
     }
     if ($this->_arity < 0) {
         throw new Exception("FunctionValue::__construct: more args then parameters.");
     }
     $this->_function = $function;
     $this->_unwrap_args = $unwrap_args;
     $this->_args = $args;
     $this->_reify_exceptions = $reify_exceptions;
 }
Esempio n. 3
0
 public function __construct($id, $action, $attrs, IFormlet $formlet)
 {
     if (!preg_match("#[a-zA-Z][a-zA-Z0-9_]+#", $id)) {
         throw new Exception("Form::__construct: '{$id}' can not be used as " . "id. Only use numbers and digits.");
     }
     C::guardIsFormlet($formlet);
     C::guardIsString($id);
     C::guardIsString($action);
     $attrs = Value::defaultTo($attrs, array());
     C::guardEachAndKeys($attrs, "C::guardIsString", "C::guardIsString");
     $this->_id = $id;
     $this->_input = null;
     $this->_result = null;
     $attrs["method"] = "post";
     $attrs["action"] = $action;
     $formlet = $formlet->mapHTML(V::fn(function ($dict, $html) use($attrs) {
         return H::tag("form", $attrs, $html);
     }));
     $name_source = NameSource::instantiate($this->_id);
     $repr = $formlet->instantiate($name_source);
     $this->_builder = $repr["builder"];
     $this->_collector = $repr["collector"];
 }
Esempio n. 4
0
 /** 
  * An Error value tracks origin.
  * @dataProvider error_values 
  */
 public function testErrorOriginsAreCorrect(Value $value, $reason, $origin)
 {
     $this->assertEquals($value->origin(), $origin ? $origin : null);
 }
Esempio n. 5
0
 public function __construct($value, $origin)
 {
     $this->_value = $value;
     parent::__construct($origin);
 }