Example #1
0
 public function __construct(Type $type)
 {
     $described = $type->getTypeDescription()->describe();
     $described[static::$propertyPrefix . 'allowNull'] = true;
     parent::__construct(new TypeDescription("", $described));
     $this->type = $type;
 }
Example #2
0
 public function __construct(Type $type, $defaultValue, $defaultOnWrongType = false, $defaultOnNull = true)
 {
     parent::__construct(new TypeDescription("Either", [static::$propertyPrefix . "expected" => $type->getTypeDescription()->describe(), static::$propertyPrefix . "orDefault" => $defaultValue, static::$propertyPrefix . "defaultOnWrongType" => $defaultOnWrongType, static::$propertyPrefix . "defaultOnNull" => $defaultOnNull]));
     $this->defaultValue = $defaultValue;
     $this->defaultOnWrongType = $defaultOnWrongType;
     $this->defaultOnNull = $defaultOnNull;
     $this->type = $type;
 }
Example #3
0
 /**
  * ArrayList constructor.
  *
  * @param Type|null $arrayMemberType , if it's not null, every element will be validated for type
  */
 public function __construct(Type $arrayMemberType = null)
 {
     $type = new TypeDescription("Array", ["items" => $arrayMemberType->getTypeDescription()]);
     parent::__construct($type, false);
     $this->childrenType = $arrayMemberType;
 }