diff --git a/src/Types/Scalar.php b/src/PseudoTypes/Scalar.php similarity index 54% rename from src/Types/Scalar.php rename to src/PseudoTypes/Scalar.php index 80241c21..127ef238 100644 --- a/src/Types/Scalar.php +++ b/src/PseudoTypes/Scalar.php @@ -11,17 +11,28 @@ * @link http://phpdoc.org */ -namespace phpDocumentor\Reflection\Types; +namespace phpDocumentor\Reflection\PseudoTypes; +use phpDocumentor\Reflection\PseudoType; use phpDocumentor\Reflection\Type; +use phpDocumentor\Reflection\Types\Boolean; +use phpDocumentor\Reflection\Types\Compound; +use phpDocumentor\Reflection\Types\Float_; +use phpDocumentor\Reflection\Types\Integer; +use phpDocumentor\Reflection\Types\String_; /** * Value Object representing the 'scalar' pseudo-type, which is either a string, integer, float or boolean. * * @psalm-immutable */ -final class Scalar implements Type +final class Scalar implements PseudoType { + public function underlyingType(): Type + { + return new Compound([new String_(), new Integer(), new Float_(), new Boolean()]); + } + /** * Returns a rendered output of the Type as it would be used in a DocBlock. */ diff --git a/src/TypeResolver.php b/src/TypeResolver.php index 79a2ba37..f7ab9bd6 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -50,6 +50,7 @@ use phpDocumentor\Reflection\PseudoTypes\ObjectShapeItem; use phpDocumentor\Reflection\PseudoTypes\OffsetAccess; use phpDocumentor\Reflection\PseudoTypes\PositiveInteger; +use phpDocumentor\Reflection\PseudoTypes\Scalar; use phpDocumentor\Reflection\PseudoTypes\StringValue; use phpDocumentor\Reflection\PseudoTypes\TraitString; use phpDocumentor\Reflection\PseudoTypes\True_; @@ -73,7 +74,6 @@ use phpDocumentor\Reflection\Types\Object_; use phpDocumentor\Reflection\Types\Parent_; use phpDocumentor\Reflection\Types\Resource_; -use phpDocumentor\Reflection\Types\Scalar; use phpDocumentor\Reflection\Types\Self_; use phpDocumentor\Reflection\Types\Static_; use phpDocumentor\Reflection\Types\String_; diff --git a/src/Types/Intersection.php b/src/Types/Intersection.php index ced37b62..80ac822d 100644 --- a/src/Types/Intersection.php +++ b/src/Types/Intersection.php @@ -15,7 +15,7 @@ use phpDocumentor\Reflection\Type; /** - * Value Object representing a Compound Type. + * Value Object representing a Intersection Type. * * A Intersection Type is not so much a special keyword or object reference but is a series of Types that are separated * using an AND operator (`&`). This combination of types signifies that whatever is associated with this Intersection diff --git a/tests/unit/PseudoTypes/ScalarTest.php b/tests/unit/PseudoTypes/ScalarTest.php new file mode 100644 index 00000000..b0eef6c9 --- /dev/null +++ b/tests/unit/PseudoTypes/ScalarTest.php @@ -0,0 +1,39 @@ +assertEquals($expectedUnderlyingType, $type->underlyingType()); + } + + public function testToString(): void + { + $type = new Scalar(); + + $this->assertSame('scalar', (string) $type); + } +} diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 4cd94f4a..6e3b17af 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -50,6 +50,7 @@ use phpDocumentor\Reflection\PseudoTypes\ObjectShapeItem; use phpDocumentor\Reflection\PseudoTypes\OffsetAccess; use phpDocumentor\Reflection\PseudoTypes\PositiveInteger; +use phpDocumentor\Reflection\PseudoTypes\Scalar; use phpDocumentor\Reflection\PseudoTypes\StringValue; use phpDocumentor\Reflection\PseudoTypes\TraitString; use phpDocumentor\Reflection\PseudoTypes\True_; @@ -72,7 +73,6 @@ use phpDocumentor\Reflection\Types\Object_; use phpDocumentor\Reflection\Types\Parent_; use phpDocumentor\Reflection\Types\Resource_; -use phpDocumentor\Reflection\Types\Scalar; use phpDocumentor\Reflection\Types\Self_; use phpDocumentor\Reflection\Types\Static_; use phpDocumentor\Reflection\Types\String_; diff --git a/tests/unit/Types/ScalarTest.php b/tests/unit/Types/ScalarTest.php deleted file mode 100644 index aacd94da..00000000 --- a/tests/unit/Types/ScalarTest.php +++ /dev/null @@ -1,26 +0,0 @@ -assertSame('scalar', (string) $type); - } -}