Skip to content

Commit a1d5cf0

Browse files
committed
Add support to True false pseudo types
1 parent 0c62af3 commit a1d5cf0

File tree

6 files changed

+70
-3
lines changed

6 files changed

+70
-3
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ setup: install-phive
1515
phpcs:
1616
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -s
1717

18+
.PHONY: phpcbf
19+
phpcbf:
20+
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf
21+
22+
1823
.PHONY: phpstan
1924
phpstan:
2025
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpstan-ga:latest analyse src --no-progress --configuration phpstan.neon

src/TypeResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ final class TypeResolver
8787
'scalar' => Types\Scalar::class,
8888
'callback' => Types\Callable_::class,
8989
'callable' => Types\Callable_::class,
90-
'false' => Types\Boolean::class,
91-
'true' => Types\Boolean::class,
90+
'false' => Types\False_::class,
91+
'true' => Types\True_::class,
9292
'self' => Types\Self_::class,
9393
'$this' => Types\This::class,
9494
'static' => Types\Static_::class,

src/Types/Boolean.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @psalm-immutable
2222
*/
23-
final class Boolean implements Type
23+
class Boolean implements Type
2424
{
2525
/**
2626
* Returns a rendered output of the Type as it would be used in a DocBlock.

src/Types/False_.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* This file is part of phpDocumentor.
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @link http://phpdoc.org
9+
*/
10+
11+
declare(strict_types=1);
12+
13+
namespace phpDocumentor\Reflection\Types;
14+
15+
/**
16+
* Value Object representing a False pseudo type.
17+
*
18+
* @psalm-immutable
19+
*/
20+
class False_ extends Boolean
21+
{
22+
/**
23+
* Returns a rendered output of the Type as it would be used in a DocBlock.
24+
*/
25+
public function __toString() : string
26+
{
27+
return 'false';
28+
}
29+
}

src/Types/True_.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* This file is part of phpDocumentor.
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @link http://phpdoc.org
9+
*/
10+
11+
declare(strict_types=1);
12+
13+
namespace phpDocumentor\Reflection\Types;
14+
15+
/**
16+
* Value Object representing a True pseudo type.
17+
*
18+
* @psalm-immutable
19+
*/
20+
class True_ extends Boolean
21+
{
22+
/**
23+
* Returns a rendered output of the Type as it would be used in a DocBlock.
24+
*/
25+
public function __toString() : string
26+
{
27+
return 'true';
28+
}
29+
}

tests/unit/TypeResolverTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,10 @@ public function provideKeywords() : array
712712
['double', Types\Float_::class],
713713
['bool', Types\Boolean::class],
714714
['boolean', Types\Boolean::class],
715+
['true', Types\Boolean::class],
716+
['true', Types\True_::class],
717+
['false', Types\Boolean::class],
718+
['false', Types\False_::class],
715719
['resource', Types\Resource_::class],
716720
['null', Types\Null_::class],
717721
['callable', Types\Callable_::class],

0 commit comments

Comments
 (0)