diff --git a/src/Types/ArrayKey.php b/src/PseudoTypes/ArrayKey.php similarity index 72% rename from src/Types/ArrayKey.php rename to src/PseudoTypes/ArrayKey.php index fc3641ed..ce3dd805 100644 --- a/src/Types/ArrayKey.php +++ b/src/PseudoTypes/ArrayKey.php @@ -11,15 +11,17 @@ * @link http://phpdoc.org */ -namespace phpDocumentor\Reflection\Types; +namespace phpDocumentor\Reflection\PseudoTypes; use phpDocumentor\Reflection\PseudoType; use phpDocumentor\Reflection\Type; +use phpDocumentor\Reflection\Types\AggregatedType; +use phpDocumentor\Reflection\Types\Compound; +use phpDocumentor\Reflection\Types\Integer; +use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing a array-key Type. - * - * A array-key Type is the supertype (but not a union) of int and string. + * Value Object representing the type `array-key`. * * @psalm-immutable */ diff --git a/src/PseudoTypes/ArrayShape.php b/src/PseudoTypes/ArrayShape.php index e0d0c736..45b7767c 100644 --- a/src/PseudoTypes/ArrayShape.php +++ b/src/PseudoTypes/ArrayShape.php @@ -16,7 +16,6 @@ use phpDocumentor\Reflection\PseudoType; use phpDocumentor\Reflection\Type; use phpDocumentor\Reflection\Types\Array_; -use phpDocumentor\Reflection\Types\ArrayKey; use phpDocumentor\Reflection\Types\Mixed_; use function implode; diff --git a/src/PseudoTypes/CallableString.php b/src/PseudoTypes/CallableString.php index b6934561..ff50497a 100644 --- a/src/PseudoTypes/CallableString.php +++ b/src/PseudoTypes/CallableString.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type 'callable-string'. * * @psalm-immutable */ diff --git a/src/Types/ClassString.php b/src/PseudoTypes/ClassString.php similarity index 89% rename from src/Types/ClassString.php rename to src/PseudoTypes/ClassString.php index fbdd879b..02ee2b8e 100644 --- a/src/Types/ClassString.php +++ b/src/PseudoTypes/ClassString.php @@ -11,14 +11,15 @@ * @link http://phpdoc.org */ -namespace phpDocumentor\Reflection\Types; +namespace phpDocumentor\Reflection\PseudoTypes; use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\PseudoType; use phpDocumentor\Reflection\Type; +use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type 'class-string'. * * @psalm-immutable */ diff --git a/src/PseudoTypes/HtmlEscapedString.php b/src/PseudoTypes/HtmlEscapedString.php index aa4d8db5..295c2758 100644 --- a/src/PseudoTypes/HtmlEscapedString.php +++ b/src/PseudoTypes/HtmlEscapedString.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type 'html-escaped-string'. * * @psalm-immutable */ diff --git a/src/Types/InterfaceString.php b/src/PseudoTypes/InterfaceString.php similarity index 75% rename from src/Types/InterfaceString.php rename to src/PseudoTypes/InterfaceString.php index 9836961f..89248144 100644 --- a/src/Types/InterfaceString.php +++ b/src/PseudoTypes/InterfaceString.php @@ -11,17 +11,19 @@ * @link http://phpdoc.org */ -namespace phpDocumentor\Reflection\Types; +namespace phpDocumentor\Reflection\PseudoTypes; use phpDocumentor\Reflection\Fqsen; +use phpDocumentor\Reflection\PseudoType; use phpDocumentor\Reflection\Type; +use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type `interface-string`. * * @psalm-immutable */ -final class InterfaceString implements Type +final class InterfaceString extends String_ implements PseudoType { /** @var Fqsen|null */ private $fqsen; @@ -34,6 +36,11 @@ public function __construct(?Fqsen $fqsen = null) $this->fqsen = $fqsen; } + public function underlyingType(): Type + { + return new String_(); + } + /** * Returns the FQSEN associated with this object. */ diff --git a/src/PseudoTypes/KeyOf.php b/src/PseudoTypes/KeyOf.php index 6cf5e0a7..0f26b098 100644 --- a/src/PseudoTypes/KeyOf.php +++ b/src/PseudoTypes/KeyOf.php @@ -15,7 +15,6 @@ use phpDocumentor\Reflection\PseudoType; use phpDocumentor\Reflection\Type; -use phpDocumentor\Reflection\Types\ArrayKey; /** * Value Object representing the `key-of` type. diff --git a/src/PseudoTypes/LiteralString.php b/src/PseudoTypes/LiteralString.php index 690f782b..a38518bf 100644 --- a/src/PseudoTypes/LiteralString.php +++ b/src/PseudoTypes/LiteralString.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type 'literal-string'. * * @psalm-immutable */ diff --git a/src/PseudoTypes/LowercaseString.php b/src/PseudoTypes/LowercaseString.php index 6325492a..f73d100f 100644 --- a/src/PseudoTypes/LowercaseString.php +++ b/src/PseudoTypes/LowercaseString.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type 'lowercase-string'. * * @psalm-immutable */ diff --git a/src/PseudoTypes/NonEmptyLowercaseString.php b/src/PseudoTypes/NonEmptyLowercaseString.php index 86400165..c2f2b496 100644 --- a/src/PseudoTypes/NonEmptyLowercaseString.php +++ b/src/PseudoTypes/NonEmptyLowercaseString.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type 'non-empty-lowercase-string'. * * @psalm-immutable */ diff --git a/src/PseudoTypes/NonEmptyString.php b/src/PseudoTypes/NonEmptyString.php index d72d127c..afa782a8 100644 --- a/src/PseudoTypes/NonEmptyString.php +++ b/src/PseudoTypes/NonEmptyString.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type 'non-empty-string'. * * @psalm-immutable */ diff --git a/src/PseudoTypes/NumericString.php b/src/PseudoTypes/NumericString.php index b62aa45a..f45ec1d0 100644 --- a/src/PseudoTypes/NumericString.php +++ b/src/PseudoTypes/NumericString.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type 'numeric-string'. * * @psalm-immutable */ diff --git a/src/PseudoTypes/TraitString.php b/src/PseudoTypes/TraitString.php index ac217c25..409ad0b6 100644 --- a/src/PseudoTypes/TraitString.php +++ b/src/PseudoTypes/TraitString.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\String_; /** - * Value Object representing the type 'string'. + * Value Object representing the type `trait-string`. * * @psalm-immutable */ diff --git a/src/TypeResolver.php b/src/TypeResolver.php index e2b8089b..66b47e83 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -15,9 +15,11 @@ use Doctrine\Deprecations\Deprecation; use InvalidArgumentException; +use phpDocumentor\Reflection\PseudoTypes\ArrayKey; use phpDocumentor\Reflection\PseudoTypes\ArrayShape; use phpDocumentor\Reflection\PseudoTypes\ArrayShapeItem; use phpDocumentor\Reflection\PseudoTypes\CallableString; +use phpDocumentor\Reflection\PseudoTypes\ClassString; use phpDocumentor\Reflection\PseudoTypes\Conditional; use phpDocumentor\Reflection\PseudoTypes\ConditionalForParameter; use phpDocumentor\Reflection\PseudoTypes\ConstExpression; @@ -28,6 +30,7 @@ use phpDocumentor\Reflection\PseudoTypes\HtmlEscapedString; use phpDocumentor\Reflection\PseudoTypes\IntegerRange; use phpDocumentor\Reflection\PseudoTypes\IntegerValue; +use phpDocumentor\Reflection\PseudoTypes\InterfaceString; use phpDocumentor\Reflection\PseudoTypes\IntMask; use phpDocumentor\Reflection\PseudoTypes\IntMaskOf; use phpDocumentor\Reflection\PseudoTypes\KeyOf; @@ -53,17 +56,14 @@ use phpDocumentor\Reflection\PseudoTypes\ValueOf; use phpDocumentor\Reflection\Types\AggregatedType; use phpDocumentor\Reflection\Types\Array_; -use phpDocumentor\Reflection\Types\ArrayKey; use phpDocumentor\Reflection\Types\Boolean; use phpDocumentor\Reflection\Types\Callable_; use phpDocumentor\Reflection\Types\CallableParameter; -use phpDocumentor\Reflection\Types\ClassString; use phpDocumentor\Reflection\Types\Compound; use phpDocumentor\Reflection\Types\Context; use phpDocumentor\Reflection\Types\Expression; use phpDocumentor\Reflection\Types\Float_; use phpDocumentor\Reflection\Types\Integer; -use phpDocumentor\Reflection\Types\InterfaceString; use phpDocumentor\Reflection\Types\Intersection; use phpDocumentor\Reflection\Types\Iterable_; use phpDocumentor\Reflection\Types\Mixed_; diff --git a/tests/unit/Types/ArrayKeyTest.php b/tests/unit/PseudoTypes/ArrayKeyTest.php similarity index 75% rename from tests/unit/Types/ArrayKeyTest.php rename to tests/unit/PseudoTypes/ArrayKeyTest.php index 88d511c1..8702f068 100644 --- a/tests/unit/Types/ArrayKeyTest.php +++ b/tests/unit/PseudoTypes/ArrayKeyTest.php @@ -11,12 +11,14 @@ * @link http://phpdoc.org */ -namespace phpDocumentor\Reflection\Types; +namespace phpDocumentor\Reflection\PseudoTypes; +use phpDocumentor\Reflection\Types\Integer; +use phpDocumentor\Reflection\Types\String_; use PHPUnit\Framework\TestCase; /** - * @coversDefaultClass \phpDocumentor\Reflection\Types\ArrayKey + * @coversDefaultClass \phpDocumentor\Reflection\PseudoTypes\ArrayKey */ final class ArrayKeyTest extends TestCase { @@ -30,7 +32,7 @@ public function testArrayKeyCanBeConstructedAndStringifiedCorrectly(): void } /** - * @uses \phpDocumentor\Reflection\Types\ArrayKey::__construct + * @uses \phpDocumentor\Reflection\PseudoTypes\ArrayKey::__construct * * @covers ::getIterator */ diff --git a/tests/unit/Types/ClassStringTest.php b/tests/unit/PseudoTypes/ClassStringTest.php similarity index 88% rename from tests/unit/Types/ClassStringTest.php rename to tests/unit/PseudoTypes/ClassStringTest.php index 8f77e762..b83ca5c4 100644 --- a/tests/unit/Types/ClassStringTest.php +++ b/tests/unit/PseudoTypes/ClassStringTest.php @@ -11,13 +11,13 @@ * @link http://phpdoc.org */ -namespace phpDocumentor\Reflection\Types; +namespace phpDocumentor\Reflection\PseudoTypes; use phpDocumentor\Reflection\Fqsen; use PHPUnit\Framework\TestCase; /** - * @coversDefaultClass \phpDocumentor\Reflection\Types\ClassString + * @coversDefaultClass \phpDocumentor\Reflection\PseudoTypes\ClassString */ class ClassStringTest extends TestCase { diff --git a/tests/unit/Types/InterfaceStringTest.php b/tests/unit/PseudoTypes/InterfaceStringTest.php similarity index 88% rename from tests/unit/Types/InterfaceStringTest.php rename to tests/unit/PseudoTypes/InterfaceStringTest.php index 19d20012..92e2ee21 100644 --- a/tests/unit/Types/InterfaceStringTest.php +++ b/tests/unit/PseudoTypes/InterfaceStringTest.php @@ -11,13 +11,13 @@ * @link http://phpdoc.org */ -namespace phpDocumentor\Reflection\Types; +namespace phpDocumentor\Reflection\PseudoTypes; use phpDocumentor\Reflection\Fqsen; use PHPUnit\Framework\TestCase; /** - * @coversDefaultClass \phpDocumentor\Reflection\Types\InterfaceString + * @coversDefaultClass \phpDocumentor\Reflection\PseudoTypes\InterfaceString */ class InterfaceStringTest extends TestCase { diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 4cff6369..b1bf9e26 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -15,9 +15,11 @@ use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use InvalidArgumentException; +use phpDocumentor\Reflection\PseudoTypes\ArrayKey; use phpDocumentor\Reflection\PseudoTypes\ArrayShape; use phpDocumentor\Reflection\PseudoTypes\ArrayShapeItem; use phpDocumentor\Reflection\PseudoTypes\CallableString; +use phpDocumentor\Reflection\PseudoTypes\ClassString; use phpDocumentor\Reflection\PseudoTypes\Conditional; use phpDocumentor\Reflection\PseudoTypes\ConditionalForParameter; use phpDocumentor\Reflection\PseudoTypes\ConstExpression; @@ -27,6 +29,7 @@ use phpDocumentor\Reflection\PseudoTypes\HtmlEscapedString; use phpDocumentor\Reflection\PseudoTypes\IntegerRange; use phpDocumentor\Reflection\PseudoTypes\IntegerValue; +use phpDocumentor\Reflection\PseudoTypes\InterfaceString; use phpDocumentor\Reflection\PseudoTypes\IntMask; use phpDocumentor\Reflection\PseudoTypes\IntMaskOf; use phpDocumentor\Reflection\PseudoTypes\KeyOf; @@ -51,17 +54,14 @@ use phpDocumentor\Reflection\PseudoTypes\True_; use phpDocumentor\Reflection\PseudoTypes\ValueOf; use phpDocumentor\Reflection\Types\Array_; -use phpDocumentor\Reflection\Types\ArrayKey; use phpDocumentor\Reflection\Types\Boolean; use phpDocumentor\Reflection\Types\Callable_; use phpDocumentor\Reflection\Types\CallableParameter; -use phpDocumentor\Reflection\Types\ClassString; use phpDocumentor\Reflection\Types\Compound; use phpDocumentor\Reflection\Types\Context; use phpDocumentor\Reflection\Types\Expression; use phpDocumentor\Reflection\Types\Float_; use phpDocumentor\Reflection\Types\Integer; -use phpDocumentor\Reflection\Types\InterfaceString; use phpDocumentor\Reflection\Types\Intersection; use phpDocumentor\Reflection\Types\Iterable_; use phpDocumentor\Reflection\Types\Mixed_;