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); }
/** * Construct an instance of a TraversableConstraint. */ public function __construct() { parent::__construct(new ClassTypeConstraint(FunctorInterface::class), new EitherConstraint(new ListConstraint(), new ClassTypeConstraint(Traversable::class))); }
/** * Construct an instance of a MapConstraint. */ public function __construct() { parent::__construct(new ClassTypeConstraint(MapInterface::class), new EitherConstraint(new ListConstraint(), new ClassTypeConstraint(ArrayAccess::class))); }
/** * Construct an instance of a MaybeConstraint. * * @param AbstractConstraint $other */ public function __construct(AbstractConstraint $other) { parent::__construct($other, new PrimitiveTypeConstraint(SpecialTypes::SPECIAL_NULL)); }
/** * 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()); }
/** * 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))); }