From 64cc945f683513342d4e62348e7a8dacd0d68d24 Mon Sep 17 00:00:00 2001 From: Bram Leeda Date: Tue, 29 Aug 2023 16:31:32 +0200 Subject: [PATCH] Support non-empty-list and object collections (#53) * Rename NonEmptyStringProvider to NonEmptyValueProvider Add support for non-empty-list type - combines ListProvider with NonEmptyValueProvider to generate non-empty lists (arrays with int keys) Add support for Collection objects using Object syntax * Adjust type-resolver min version to support NonEmptyList type * Add support for hardcoded float/int/string values as typehint --- composer.json | 2 +- .../Pseudo/DirectValueProvider.php | 32 +++++++++++++ .../Pseudo/NonEmptyStringProvider.php | 31 ------------ .../Pseudo/NonEmptyValueProvider.php | 26 ++++++++++ .../PseudoValueProviderFactory.php | 17 +++++-- .../ValueProvider/ValueProviderFactory.php | 3 +- .../Integration/AccessorPairAsserterTest.php | 3 +- .../CompoundTypes/CollectionProperty.php | 31 ++++++++++++ .../Types/PseudoTypes/FloatValueProperty.php | 29 +++++++++++ .../PseudoTypes/IntegerValueProperty.php | 29 +++++++++++ .../PseudoTypes/NonEmptyListProperty.php | 28 +++++++++++ .../Types/PseudoTypes/StringValueProperty.php | 29 +++++++++++ .../NativeValueProviderFactoryTest.php | 2 +- .../Pseudo/CallableStringProviderTest.php | 2 +- .../Pseudo/ClassStringProviderTest.php | 2 +- .../Pseudo/DirectValueProviderTest.php | 25 ++++++++++ .../Pseudo/HtmlEscapedStringProviderTest.php | 2 +- .../ValueProvider/Pseudo/ListProviderTest.php | 2 +- .../Pseudo/LiteralStringProviderTest.php | 2 +- .../Pseudo/LowercaseStringProviderTest.php | 2 +- .../Pseudo/NonEmptyStringProviderTest.php | 32 ------------- .../Pseudo/NonEmptyValueProviderTest.php | 48 +++++++++++++++++++ .../Pseudo/NumericStringProviderTest.php | 2 +- .../Pseudo/TraitStringProviderTest.php | 2 +- .../PseudoValueProviderFactoryTest.php | 18 +++++-- .../ValueProviderFactoryTest.php | 11 ++++- 26 files changed, 329 insertions(+), 83 deletions(-) create mode 100644 src/Constraint/ValueProvider/Pseudo/DirectValueProvider.php delete mode 100644 src/Constraint/ValueProvider/Pseudo/NonEmptyStringProvider.php create mode 100644 src/Constraint/ValueProvider/Pseudo/NonEmptyValueProvider.php create mode 100644 tests/Integration/data/success/Regular/Types/CompoundTypes/CollectionProperty.php create mode 100644 tests/Integration/data/success/Regular/Types/PseudoTypes/FloatValueProperty.php create mode 100644 tests/Integration/data/success/Regular/Types/PseudoTypes/IntegerValueProperty.php create mode 100644 tests/Integration/data/success/Regular/Types/PseudoTypes/NonEmptyListProperty.php create mode 100644 tests/Integration/data/success/Regular/Types/PseudoTypes/StringValueProperty.php create mode 100644 tests/Unit/Constraint/ValueProvider/Pseudo/DirectValueProviderTest.php delete mode 100644 tests/Unit/Constraint/ValueProvider/Pseudo/NonEmptyStringProviderTest.php create mode 100644 tests/Unit/Constraint/ValueProvider/Pseudo/NonEmptyValueProviderTest.php diff --git a/composer.json b/composer.json index f262a50..21bba6d 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "require": { "php": ">=7.4", "doctrine/inflector": "^2.0", - "phpdocumentor/type-resolver": "^1.6", + "phpdocumentor/type-resolver": "^1.7", "phpunit/phpunit": "^9.0 || ^10.0" }, "require-dev": { diff --git a/src/Constraint/ValueProvider/Pseudo/DirectValueProvider.php b/src/Constraint/ValueProvider/Pseudo/DirectValueProvider.php new file mode 100644 index 0000000..c84ce2f --- /dev/null +++ b/src/Constraint/ValueProvider/Pseudo/DirectValueProvider.php @@ -0,0 +1,32 @@ +valueType = $valueType; + } + + /** + * @return float[]|int[]|string[] + */ + public function getValues(): array + { + return [$this->valueType->getValue()]; + } +} diff --git a/src/Constraint/ValueProvider/Pseudo/NonEmptyStringProvider.php b/src/Constraint/ValueProvider/Pseudo/NonEmptyStringProvider.php deleted file mode 100644 index 769877d..0000000 --- a/src/Constraint/ValueProvider/Pseudo/NonEmptyStringProvider.php +++ /dev/null @@ -1,31 +0,0 @@ -stringProvider = $stringProvider; - } - - /** - * @return non-empty-string[] - * @throws Exception - */ - public function getValues(): array - { - return array_filter($this->stringProvider->getValues()); - } -} diff --git a/src/Constraint/ValueProvider/Pseudo/NonEmptyValueProvider.php b/src/Constraint/ValueProvider/Pseudo/NonEmptyValueProvider.php new file mode 100644 index 0000000..a81e5e6 --- /dev/null +++ b/src/Constraint/ValueProvider/Pseudo/NonEmptyValueProvider.php @@ -0,0 +1,26 @@ +valueProvider = $valueProvider; + } + + /** + * @return mixed[] + * @throws Exception + */ + public function getValues(): array + { + return array_filter($this->valueProvider->getValues()); + } +} diff --git a/src/Constraint/ValueProvider/PseudoValueProviderFactory.php b/src/Constraint/ValueProvider/PseudoValueProviderFactory.php index 2aaf155..1a08981 100644 --- a/src/Constraint/ValueProvider/PseudoValueProviderFactory.php +++ b/src/Constraint/ValueProvider/PseudoValueProviderFactory.php @@ -5,11 +5,12 @@ use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\CallableStringProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\ClassStringProvider; +use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\DirectValueProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\HtmlEscapedStringProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\ListProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\LiteralStringProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\LowercaseStringProvider; -use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NonEmptyStringProvider; +use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NonEmptyValueProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NumericStringProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\TraitStringProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Scalar\FloatProvider; @@ -17,17 +18,21 @@ use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Scalar\StringProvider; use LogicException; use phpDocumentor\Reflection\PseudoTypes\CallableString; +use phpDocumentor\Reflection\PseudoTypes\FloatValue; use phpDocumentor\Reflection\PseudoTypes\HtmlEscapedString; use phpDocumentor\Reflection\PseudoTypes\IntegerRange; +use phpDocumentor\Reflection\PseudoTypes\IntegerValue; use phpDocumentor\Reflection\PseudoTypes\List_; use phpDocumentor\Reflection\PseudoTypes\LiteralString; use phpDocumentor\Reflection\PseudoTypes\LowercaseString; use phpDocumentor\Reflection\PseudoTypes\NegativeInteger; +use phpDocumentor\Reflection\PseudoTypes\NonEmptyList; use phpDocumentor\Reflection\PseudoTypes\NonEmptyLowercaseString; use phpDocumentor\Reflection\PseudoTypes\NonEmptyString; use phpDocumentor\Reflection\PseudoTypes\Numeric_; use phpDocumentor\Reflection\PseudoTypes\NumericString; use phpDocumentor\Reflection\PseudoTypes\PositiveInteger; +use phpDocumentor\Reflection\PseudoTypes\StringValue; use phpDocumentor\Reflection\PseudoTypes\TraitString; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\Types\ArrayKey; @@ -57,6 +62,8 @@ public function getProvider(Type $typehint): ?ValueProvider return new IntProvider((int)$typehint->getMinValue(), (int)$typehint->getMaxValue()); case List_::class: return new ListProvider($this->valueProviderFactory->getProvider($typehint->getValueType())); + case NonEmptyList::class: + return new NonEmptyValueProvider(new ListProvider($this->valueProviderFactory->getProvider($typehint->getValueType()))); case NegativeInteger::class: return new IntProvider(PHP_INT_MIN, -1); case Numeric_::class: @@ -84,6 +91,10 @@ protected function getPseudoStringProvider(Type $typehint): ?ValueProvider return new ClassStringProvider($fqsen); case CallableString::class: return new CallableStringProvider(); + case FloatValue::class: + case IntegerValue::class: + case StringValue::class: + return new DirectValueProvider($typehint); case HtmlEscapedString::class: return new HtmlEscapedStringProvider(); case LiteralString::class: @@ -91,9 +102,9 @@ protected function getPseudoStringProvider(Type $typehint): ?ValueProvider case LowercaseString::class: return new LowercaseStringProvider(new StringProvider()); case NonEmptyLowercaseString::class: - return new NonEmptyStringProvider(new LowercaseStringProvider(new StringProvider())); + return new NonEmptyValueProvider(new LowercaseStringProvider(new StringProvider())); case NonEmptyString::class: - return new NonEmptyStringProvider(new StringProvider()); + return new NonEmptyValueProvider(new StringProvider()); case NumericString::class: return new NumericStringProvider(); case TraitString::class: diff --git a/src/Constraint/ValueProvider/ValueProviderFactory.php b/src/Constraint/ValueProvider/ValueProviderFactory.php index 152d63a..1ffc654 100644 --- a/src/Constraint/ValueProvider/ValueProviderFactory.php +++ b/src/Constraint/ValueProvider/ValueProviderFactory.php @@ -8,6 +8,7 @@ use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Special\NullProvider; use LogicException; use phpDocumentor\Reflection\Type; +use phpDocumentor\Reflection\Types\Collection; use phpDocumentor\Reflection\Types\Compound; use phpDocumentor\Reflection\Types\Intersection; use phpDocumentor\Reflection\Types\Nullable; @@ -50,7 +51,7 @@ public function getProvider(Type $typehint): ValueProvider } // Support for fully namespaced class name - if ($typehint instanceof Object_ && $typehint->getFqsen() !== null) { + if (($typehint instanceof Object_ || $typehint instanceof Collection) && $typehint->getFqsen() !== null) { return new InstanceProvider((string)$typehint->getFqsen()); } diff --git a/tests/Integration/AccessorPairAsserterTest.php b/tests/Integration/AccessorPairAsserterTest.php index dfa9cf1..8d50464 100644 --- a/tests/Integration/AccessorPairAsserterTest.php +++ b/tests/Integration/AccessorPairAsserterTest.php @@ -39,11 +39,12 @@ * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Keyword\FalseProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\CallableStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\ClassStringProvider + * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\DirectValueProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\HtmlEscapedStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\ListProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\LiteralStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\LowercaseStringProvider - * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NonEmptyStringProvider + * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NonEmptyValueProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NumericStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\TraitStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Scalar\BoolProvider diff --git a/tests/Integration/data/success/Regular/Types/CompoundTypes/CollectionProperty.php b/tests/Integration/data/success/Regular/Types/CompoundTypes/CollectionProperty.php new file mode 100644 index 0000000..76ad87c --- /dev/null +++ b/tests/Integration/data/success/Regular/Types/CompoundTypes/CollectionProperty.php @@ -0,0 +1,31 @@ + */ + private $property = false; + + /** + * @return ArrayIterator + */ + public function getProperty(): ArrayIterator + { + return $this->property; + } + + /** + * @param ArrayIterator $property + */ + public function setProperty(ArrayIterator $property): self + { + $this->property = $property; + + return $this; + } +} diff --git a/tests/Integration/data/success/Regular/Types/PseudoTypes/FloatValueProperty.php b/tests/Integration/data/success/Regular/Types/PseudoTypes/FloatValueProperty.php new file mode 100644 index 0000000..5a0fe0c --- /dev/null +++ b/tests/Integration/data/success/Regular/Types/PseudoTypes/FloatValueProperty.php @@ -0,0 +1,29 @@ +property; + } + + /** + * @param 1.0|2.0|3.0 $property + */ + public function setProperty(float $property): self + { + $this->property = $property; + + return $this; + } +} diff --git a/tests/Integration/data/success/Regular/Types/PseudoTypes/IntegerValueProperty.php b/tests/Integration/data/success/Regular/Types/PseudoTypes/IntegerValueProperty.php new file mode 100644 index 0000000..41226b8 --- /dev/null +++ b/tests/Integration/data/success/Regular/Types/PseudoTypes/IntegerValueProperty.php @@ -0,0 +1,29 @@ +property; + } + + /** + * @param 1|2|3 $property + */ + public function setProperty(int $property): self + { + $this->property = $property; + + return $this; + } +} diff --git a/tests/Integration/data/success/Regular/Types/PseudoTypes/NonEmptyListProperty.php b/tests/Integration/data/success/Regular/Types/PseudoTypes/NonEmptyListProperty.php new file mode 100644 index 0000000..83e82d7 --- /dev/null +++ b/tests/Integration/data/success/Regular/Types/PseudoTypes/NonEmptyListProperty.php @@ -0,0 +1,28 @@ +property; + } + + /** + * @param non-empty-list $property + */ + public function setProperty(array $property): self + { + $this->property = $property; + + return $this; + } +} diff --git a/tests/Integration/data/success/Regular/Types/PseudoTypes/StringValueProperty.php b/tests/Integration/data/success/Regular/Types/PseudoTypes/StringValueProperty.php new file mode 100644 index 0000000..ad6a234 --- /dev/null +++ b/tests/Integration/data/success/Regular/Types/PseudoTypes/StringValueProperty.php @@ -0,0 +1,29 @@ +property; + } + + /** + * @param 'foo'|'bar' $property + */ + public function setProperty(string $property): self + { + $this->property = $property; + + return $this; + } +} diff --git a/tests/Unit/Constraint/ValueProvider/NativeValueProviderFactoryTest.php b/tests/Unit/Constraint/ValueProvider/NativeValueProviderFactoryTest.php index f4f0d24..c810e49 100644 --- a/tests/Unit/Constraint/ValueProvider/NativeValueProviderFactoryTest.php +++ b/tests/Unit/Constraint/ValueProvider/NativeValueProviderFactoryTest.php @@ -53,7 +53,7 @@ * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\ListProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\LiteralStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\LowercaseStringProvider - * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NonEmptyStringProvider + * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NonEmptyValueProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NumericStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\TraitStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Scalar\BoolProvider diff --git a/tests/Unit/Constraint/ValueProvider/Pseudo/CallableStringProviderTest.php b/tests/Unit/Constraint/ValueProvider/Pseudo/CallableStringProviderTest.php index e09de19..bf7f54e 100644 --- a/tests/Unit/Constraint/ValueProvider/Pseudo/CallableStringProviderTest.php +++ b/tests/Unit/Constraint/ValueProvider/Pseudo/CallableStringProviderTest.php @@ -1,7 +1,7 @@ getValues()); + } +} diff --git a/tests/Unit/Constraint/ValueProvider/Pseudo/HtmlEscapedStringProviderTest.php b/tests/Unit/Constraint/ValueProvider/Pseudo/HtmlEscapedStringProviderTest.php index e83c0b9..8d5cca7 100644 --- a/tests/Unit/Constraint/ValueProvider/Pseudo/HtmlEscapedStringProviderTest.php +++ b/tests/Unit/Constraint/ValueProvider/Pseudo/HtmlEscapedStringProviderTest.php @@ -1,7 +1,7 @@ getValues(); - - static::assertValueTypes($values, ['string']); - foreach ($values as $value) { - static::assertNotEmpty($value); - } - } -} diff --git a/tests/Unit/Constraint/ValueProvider/Pseudo/NonEmptyValueProviderTest.php b/tests/Unit/Constraint/ValueProvider/Pseudo/NonEmptyValueProviderTest.php new file mode 100644 index 0000000..1ade743 --- /dev/null +++ b/tests/Unit/Constraint/ValueProvider/Pseudo/NonEmptyValueProviderTest.php @@ -0,0 +1,48 @@ +getValues(); + + static::assertValueTypes($values, ['string']); + foreach ($values as $value) { + static::assertNotEmpty($value); + } + } + + /** + * @covers ::getValues + * @throws Exception + */ + public function testGetValuesList(): void + { + $valueProvider = new NonEmptyValueProvider(new ListProvider()); + $values = $valueProvider->getValues(); + + foreach ($values as $value) { + static::assertNotEmpty($value); + } + } +} diff --git a/tests/Unit/Constraint/ValueProvider/Pseudo/NumericStringProviderTest.php b/tests/Unit/Constraint/ValueProvider/Pseudo/NumericStringProviderTest.php index be43c27..7f19f7b 100644 --- a/tests/Unit/Constraint/ValueProvider/Pseudo/NumericStringProviderTest.php +++ b/tests/Unit/Constraint/ValueProvider/Pseudo/NumericStringProviderTest.php @@ -1,7 +1,7 @@ [new CallableString(), new CallableStringProvider()]; + yield "PseudoType FloatValue" => [new FloatValue(1.0), new DirectValueProvider(new FloatValue(1.0))]; + yield "PseudoType IntegerValue" => [new IntegerValue(1), new DirectValueProvider(new IntegerValue(1))]; + yield "PseudoType StringValue" => [new StringValue('foo'), new DirectValueProvider(new StringValue('foo'))]; yield "PseudoType HtmlEscapedString" => [new HtmlEscapedString(), new HtmlEscapedStringProvider()]; yield "PseudoType IntegerRange" => [new IntegerRange('0', '5'), new IntProvider(0, 5)]; yield "PseudoType List" => [new List_(), new ListProvider(self::getMixedProvider())]; + yield "PseudoType NonEmptyList" => [new NonEmptyList(), new NonEmptyValueProvider(new ListProvider(self::getMixedProvider()))]; yield "PseudoType LiteralString" => [new LiteralString(), new LiteralStringProvider()]; yield "PseudoType LowercaseString" => [new LowercaseString(), new LowercaseStringProvider(new StringProvider())]; yield "PseudoType NegativeInteger" => [new NegativeInteger(), new IntProvider(PHP_INT_MIN, -1)]; yield "PseudoType NonEmptyLowercaseString" => [ new NonEmptyLowercaseString(), - new NonEmptyStringProvider(new LowercaseStringProvider(new StringProvider())) + new NonEmptyValueProvider(new LowercaseStringProvider(new StringProvider())) ]; - yield "PseudoType NonEmptyString" => [new NonEmptyString(), new NonEmptyStringProvider(new StringProvider())]; + yield "PseudoType NonEmptyString" => [new NonEmptyString(), new NonEmptyValueProvider(new StringProvider())]; yield "PseudoType Numeric" => [ new Numeric_(), new ValueProviderList(new NumericStringProvider(), new IntProvider(), new FloatProvider(new IntProvider())) diff --git a/tests/Unit/Constraint/ValueProvider/ValueProviderFactoryTest.php b/tests/Unit/Constraint/ValueProvider/ValueProviderFactoryTest.php index 8061c6a..982fe01 100644 --- a/tests/Unit/Constraint/ValueProvider/ValueProviderFactoryTest.php +++ b/tests/Unit/Constraint/ValueProvider/ValueProviderFactoryTest.php @@ -3,9 +3,11 @@ namespace DigitalRevolution\AccessorPairConstraint\Tests\Unit\Constraint\ValueProvider; +use Countable; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\ArrayProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\CallableProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\InstanceProvider; +use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\IntersectionProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\IterableProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\ObjectProvider; use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Keyword\FalseProvider; @@ -22,6 +24,7 @@ use DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\ValueProviderList; use DigitalRevolution\AccessorPairConstraint\Tests\TestCase; use Generator; +use Iterator; use LogicException; use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\PseudoTypes\LiteralString; @@ -29,6 +32,7 @@ use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\Compound; use phpDocumentor\Reflection\Types\Integer; +use phpDocumentor\Reflection\Types\Intersection; use phpDocumentor\Reflection\Types\Nullable; use phpDocumentor\Reflection\Types\Object_; use phpDocumentor\Reflection\Types\String_; @@ -41,6 +45,7 @@ * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\IterableProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\ObjectProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\InstanceProvider + * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Compound\IntersectionProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Keyword\TrueProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Keyword\FalseProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\CallableStringProvider @@ -49,7 +54,7 @@ * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\ListProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\LiteralStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\LowercaseStringProvider - * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NonEmptyStringProvider + * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NonEmptyValueProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\NumericStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Pseudo\TraitStringProvider * @uses \DigitalRevolution\AccessorPairConstraint\Constraint\ValueProvider\Scalar\BoolProvider @@ -100,6 +105,10 @@ public function __toString(): string */ public static function dataProvider(): Generator { + yield 'Intersection type' => [ + new Intersection([new Object_(new Fqsen('\\' . Iterator::class)), new Object_(new Fqsen('\\' . Countable::class))]), + new IntersectionProvider([new Object_(new Fqsen('\\' . Iterator::class)), new Object_(new Fqsen('\\' . Countable::class))]) + ]; yield 'Union type' => [ new Compound([new Integer(), new LiteralString()]), new ValueProviderList(new IntProvider(), new LiteralStringProvider())