Skip to content

Commit 167ac2e

Browse files
committed
Merge branch '2.x' into add-properties-of
2 parents 40ec328 + eab6d97 commit 167ac2e

File tree

7 files changed

+66
-42
lines changed

7 files changed

+66
-42
lines changed

composer.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,28 @@
1111
* @link http://phpdoc.org
1212
*/
1313

14-
namespace phpDocumentor\Reflection\Types;
14+
namespace phpDocumentor\Reflection\PseudoTypes;
1515

16+
use phpDocumentor\Reflection\PseudoType;
1617
use phpDocumentor\Reflection\Type;
18+
use phpDocumentor\Reflection\Types\Boolean;
19+
use phpDocumentor\Reflection\Types\Compound;
20+
use phpDocumentor\Reflection\Types\Float_;
21+
use phpDocumentor\Reflection\Types\Integer;
22+
use phpDocumentor\Reflection\Types\String_;
1723

1824
/**
1925
* Value Object representing the 'scalar' pseudo-type, which is either a string, integer, float or boolean.
2026
*
2127
* @psalm-immutable
2228
*/
23-
final class Scalar implements Type
29+
final class Scalar implements PseudoType
2430
{
31+
public function underlyingType(): Type
32+
{
33+
return new Compound([new String_(), new Integer(), new Float_(), new Boolean()]);
34+
}
35+
2536
/**
2637
* Returns a rendered output of the Type as it would be used in a DocBlock.
2738
*/

src/TypeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
use phpDocumentor\Reflection\PseudoTypes\PropertiesOf;
5555
use phpDocumentor\Reflection\PseudoTypes\ProtectedPropertiesOf;
5656
use phpDocumentor\Reflection\PseudoTypes\PublicPropertiesOf;
57+
use phpDocumentor\Reflection\PseudoTypes\Scalar;
5758
use phpDocumentor\Reflection\PseudoTypes\StringValue;
5859
use phpDocumentor\Reflection\PseudoTypes\TraitString;
5960
use phpDocumentor\Reflection\PseudoTypes\True_;
@@ -77,7 +78,6 @@
7778
use phpDocumentor\Reflection\Types\Object_;
7879
use phpDocumentor\Reflection\Types\Parent_;
7980
use phpDocumentor\Reflection\Types\Resource_;
80-
use phpDocumentor\Reflection\Types\Scalar;
8181
use phpDocumentor\Reflection\Types\Self_;
8282
use phpDocumentor\Reflection\Types\Static_;
8383
use phpDocumentor\Reflection\Types\String_;

src/Types/Intersection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use phpDocumentor\Reflection\Type;
1616

1717
/**
18-
* Value Object representing a Compound Type.
18+
* Value Object representing a Intersection Type.
1919
*
2020
* A Intersection Type is not so much a special keyword or object reference but is a series of Types that are separated
2121
* using an AND operator (`&`). This combination of types signifies that whatever is associated with this Intersection
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of phpDocumentor.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @link http://phpdoc.org
12+
*/
13+
14+
namespace phpDocumentor\Reflection\PseudoTypes;
15+
16+
use phpDocumentor\Reflection\Types\Boolean;
17+
use phpDocumentor\Reflection\Types\Compound;
18+
use phpDocumentor\Reflection\Types\Float_;
19+
use phpDocumentor\Reflection\Types\Integer;
20+
use phpDocumentor\Reflection\Types\String_;
21+
use PHPUnit\Framework\TestCase;
22+
23+
final class ScalarTest extends TestCase
24+
{
25+
public function testCreate(): void
26+
{
27+
$type = new Scalar();
28+
29+
$expectedUnderlyingType = new Compound([new String_(), new Integer(), new Float_(), new Boolean()]);
30+
$this->assertEquals($expectedUnderlyingType, $type->underlyingType());
31+
}
32+
33+
public function testToString(): void
34+
{
35+
$type = new Scalar();
36+
37+
$this->assertSame('scalar', (string) $type);
38+
}
39+
}

tests/unit/TypeResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
use phpDocumentor\Reflection\PseudoTypes\PropertiesOf;
5555
use phpDocumentor\Reflection\PseudoTypes\ProtectedPropertiesOf;
5656
use phpDocumentor\Reflection\PseudoTypes\PublicPropertiesOf;
57+
use phpDocumentor\Reflection\PseudoTypes\Scalar;
5758
use phpDocumentor\Reflection\PseudoTypes\StringValue;
5859
use phpDocumentor\Reflection\PseudoTypes\TraitString;
5960
use phpDocumentor\Reflection\PseudoTypes\True_;
@@ -76,7 +77,6 @@
7677
use phpDocumentor\Reflection\Types\Object_;
7778
use phpDocumentor\Reflection\Types\Parent_;
7879
use phpDocumentor\Reflection\Types\Resource_;
79-
use phpDocumentor\Reflection\Types\Scalar;
8080
use phpDocumentor\Reflection\Types\Self_;
8181
use phpDocumentor\Reflection\Types\Static_;
8282
use phpDocumentor\Reflection\Types\String_;

tests/unit/Types/ScalarTest.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)