Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/Types/Scalar.php → src/PseudoTypes/Scalar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/TypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand All @@ -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_;
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Intersection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions tests/unit/PseudoTypes/ScalarTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

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_;
use PHPUnit\Framework\TestCase;

final class ScalarTest extends TestCase
{
public function testCreate(): void
{
$type = new Scalar();

$expectedUnderlyingType = new Compound([new String_(), new Integer(), new Float_(), new Boolean()]);
$this->assertEquals($expectedUnderlyingType, $type->underlyingType());
}

public function testToString(): void
{
$type = new Scalar();

$this->assertSame('scalar', (string) $type);
}
}
2 changes: 1 addition & 1 deletion tests/unit/TypeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand All @@ -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_;
Expand Down
26 changes: 0 additions & 26 deletions tests/unit/Types/ScalarTest.php

This file was deleted.