Exemplo n.º 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);
 }
Exemplo n.º 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)));
 }
Exemplo n.º 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)));
 }
Exemplo n.º 4
0
 /**
  * Construct an instance of a MaybeConstraint.
  *
  * @param AbstractConstraint $other
  */
 public function __construct(AbstractConstraint $other)
 {
     parent::__construct($other, new PrimitiveTypeConstraint(SpecialTypes::SPECIAL_NULL));
 }
Exemplo n.º 5
0
 /**
  * Construct an instance of a TraversableConstraint.
  */
 public function __construct()
 {
     parent::__construct(new ClassTypeConstraint(FoldableInterface::class), new ListConstraint());
 }
Exemplo n.º 6
0
 public function testIsUnion()
 {
     $instance = new EitherConstraint(new PrimitiveTypeConstraint(ScalarTypes::SCALAR_STRING), new PrimitiveTypeConstraint(ScalarTypes::SCALAR_FLOAT));
     $this->assertTrue($instance->isUnion());
 }
Exemplo n.º 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)));
 }