示例#1
0
 public function testDefineWithInvalid()
 {
     $definition = Arguments::define(PrimitiveTypeConstraint::forType(ScalarTypes::SCALAR_STRING), EitherConstraint::create(MaybeConstraint::forType(PrimitiveTypeConstraint::forType(CompoundTypes::COMPOUND_ARRAY)), PrimitiveTypeConstraint::forType(ScalarTypes::SCALAR_BOOLEAN)));
     $definition->check('wow', true);
     $definition->check('wow', []);
     $definition->check('wow', null);
     $this->setExpectedException(InvalidArgumentException::class);
     $definition->check('wow', 25);
 }
示例#2
0
 /**
  * Construct an instance of a TraversableConstraint.
  */
 public function __construct()
 {
     parent::__construct(new ClassTypeConstraint(FunctorInterface::class), new EitherConstraint(new ListConstraint(), new ClassTypeConstraint(Traversable::class)));
 }
示例#3
0
 /**
  * Construct an instance of a MapConstraint.
  */
 public function __construct()
 {
     parent::__construct(new ClassTypeConstraint(MapInterface::class), new EitherConstraint(new ListConstraint(), new ClassTypeConstraint(ArrayAccess::class)));
 }
示例#4
0
 /**
  * Construct an instance of a MaybeConstraint.
  *
  * @param AbstractConstraint $other
  */
 public function __construct(AbstractConstraint $other)
 {
     parent::__construct($other, new PrimitiveTypeConstraint(SpecialTypes::SPECIAL_NULL));
 }
示例#5
0
 /**
  * Construct an instance of a TraversableConstraint.
  */
 public function __construct()
 {
     parent::__construct(new ClassTypeConstraint(FoldableInterface::class), new ListConstraint());
 }
 public function testIsUnion()
 {
     $instance = new EitherConstraint(new PrimitiveTypeConstraint(ScalarTypes::SCALAR_STRING), new PrimitiveTypeConstraint(ScalarTypes::SCALAR_FLOAT));
     $this->assertTrue($instance->isUnion());
 }
示例#7
0
 /**
  * Construct an instance of a ListConstraint.
  */
 public function __construct()
 {
     parent::__construct(new ClassTypeConstraint(ListInterface::class), new EitherConstraint(new ClassTypeConstraint(ArrayObject::class), new PrimitiveTypeConstraint(CompoundTypes::COMPOUND_ARRAY)));
 }